Is there an implemented way to make the photon could detect why the connection isn’t happening ?
I am intetested in distinguish:
incorrect password
wifi network not available.
With WiFi.scan() I could dduce the last one, but if I try to connect to a hidden wifi it is not useful.
armor
June 21, 2019, 4:47pm
2
Yes there is thanks to @rickkas7
//get the connection error 1007, 1024, etc.
int32_t errorno = getNetworkConnectionError();
// Based upon @rickkas7 code - get network connection error code from WICED
uint32_t getNetworkConnectionError()
{
int32_t value;
if (!getSystemDiagValue(DIAG_ID_NETWORK_CONNECTION_ERROR_CODE, value)) {value = 0;}
return value;
}
//get any system diagnostic value returns false if error or true and value if OK
bool getSystemDiagValue(uint16_t id, int32_t &value)
{
union Data {
struct __attribute__((packed)) {
uint16_t idSize;
uint16_t valueSize;
uint16_t id;
int32_t value;
size_t offset;
} d;
uint8_t b[10];
};
Data data;
data.d.offset = data.d.value = 0;
struct {
static bool appender(void* appender, const uint8_t* data, size_t size) {
Data *d = (Data *)appender;
if ((d->d.offset + size) <= sizeof(Data::b)) {
memcpy(&d->b[d->d.offset], data, size);
d->d.offset += size;
}
return true;
}
} Callback;
system_format_diag_data(&id, 1, 1, Callback.appender, &data, nullptr);
value = data.d.value;
return (data.d.offset == sizeof(Data::b));
}
1 Like
I guess the error codes should be these:
/*
* Broadcom Proprietary and Confidential. Copyright 2016 Broadcom
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
* the contents of this file may not be disclosed to third parties, copied
* or duplicated in any form, in whole or in part, without the prior
* written permission of Broadcom Corporation.
*/
/** @file
* Defines common constants used with WICED
*
*/
#ifndef INCLUDED_WWD_CONSTANTS_H_
#define INCLUDED_WWD_CONSTANTS_H_
#include <stdint.h>
This file has been truncated. show original
But testing some errors I didn’t get the expected. For example with a bad password I’ve got a 1062 code…
armor
July 5, 2019, 11:34am
4
In the end I ditched the approach of trying to interpret the WICED error code because I found like you that the error codes aren’t always consistent to the known cause. I now just hold a couple of global bool flags to know; Bad credentials or not, WiFi was connected(at some stage) or not, and then just use WiFi.ready() [although some say this isn’t reliable hence you need to test for local IP address not zero]. From these and when the connection test one can effectively decide if no WAP connection whether bad credentials OR whether WAP out of range.