Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch/better wifi debug #1042

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
51 changes: 48 additions & 3 deletions airrohr-firmware/airrohr-firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,19 @@ IPAddress addr_static_dns;
const char data_first_part[] PROGMEM = "{\"software_version\": \"" SOFTWARE_VERSION_STR "\", \"sensordatavalues\":[";
const char JSON_SENSOR_DATA_VALUES[] PROGMEM = "sensordatavalues";

/*****************************************************************
* local forward declarations *
*****************************************************************/
// send detailed WiFi failure staus to debug
static void debug_outln_WiFi(wl_status_t wl_status);

/*****************************************************************
* display values *
*****************************************************************/
static void display_debug(const String &text1, const String &text2)
{
debug_outln_info(F("output debug text to displays..."));
debug_outln_info(text1);
debug_outln_info(text2);
if (oled_ssd1306)
{
oled_ssd1306->clear();
Expand Down Expand Up @@ -2905,10 +2912,11 @@ static void wifiConfig()
static void waitForWifiToConnect(int maxRetries)
{
int retryCount = 0;
while ((WiFi.status() != WL_CONNECTED) && (retryCount < maxRetries))
wl_status_t wl_status;
while (((wl_status = WiFi.status()) != WL_CONNECTED) && (retryCount < maxRetries))
{
delay(500);
debug_out(".", DEBUG_MIN_INFO);
debug_outln_WiFi(wl_status);
++retryCount;
}
}
Expand Down Expand Up @@ -3010,6 +3018,43 @@ static void connectWifi()
}
}


static void debug_outln_WiFi(wl_status_t wl_status)
{
const __FlashStringHelper* statusmsg;

switch(wl_status)
{
case WL_IDLE_STATUS:
statusmsg = FPSTR("WiFi IDLE");
break;
case WL_NO_SSID_AVAIL:
statusmsg = FPSTR("WRONG|UNAVAIL SSID");
break;
case WL_SCAN_COMPLETED:
statusmsg = FPSTR("SCAN COMPLETED");
break;
case WL_CONNECTED:
statusmsg = FPSTR("CONNECTED");
break;
case WL_CONNECT_FAILED:
statusmsg = FPSTR("CONNECT FAILED");
break;
case WL_CONNECTION_LOST:
statusmsg = FPSTR("CONNECTION LOST");
break;
case WL_DISCONNECTED:
statusmsg = FPSTR("DISCONNECTED");
break;
case WL_NO_SHIELD: // for compatibility with WiFi Shield library
default:
statusmsg = FPSTR("unknown|missing wifi");
break;
} //swend
display_debug(FPSTR("WiFi status:"), String(statusmsg));
}


static WiFiClient *getNewLoggerWiFiClient(const LoggerEntry logger)
{

Expand Down
4 changes: 4 additions & 0 deletions airrohr-firmware/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ void debug_outln_info(const __FlashStringHelper* text, float value) {
debug_outln_info(text, String(value));
}

void debug_outln_info(const __FlashStringHelper* text, int value) {
debug_outln_info(text, String(value));
}

void debug_outln_verbose(const __FlashStringHelper* text, const String& option) {
debug_level_check(DEBUG_MED_INFO);
Debug.print(text);
Expand Down
1 change: 1 addition & 0 deletions airrohr-firmware/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ extern void debug_outln_info(const __FlashStringHelper* text);
extern void debug_outln_verbose(const __FlashStringHelper* text);
extern void debug_outln_info(const __FlashStringHelper* text, const String& option);
extern void debug_outln_info(const __FlashStringHelper* text, float value);
extern void debug_outln_info(const __FlashStringHelper* text, int value);
extern void debug_outln_verbose(const __FlashStringHelper* text, const String& option);
extern void debug_outln_info_bool(const __FlashStringHelper* text, const bool option);

Expand Down