@@ -2362,13 +2362,15 @@ void Wippersnapper::runNetFSM() {
2362
2362
fsmNetwork = FSM_NET_ESTABLISH_NETWORK;
2363
2363
break ;
2364
2364
case FSM_NET_ESTABLISH_NETWORK:
2365
- WS_DEBUG_PRINTLN (" Connecting to WiFi..." );
2365
+ WS_DEBUG_PRINTLN (" Establishing network connection..." );
2366
+ WS_PRINTER.flush ();
2366
2367
#ifdef USE_DISPLAY
2367
2368
if (WS._ui_helper ->getLoadingState ())
2368
2369
WS._ui_helper ->set_label_status (" Connecting to WiFi..." );
2369
2370
#endif
2370
2371
// Perform a WiFi scan and check if SSID within
2371
2372
// secrets.json is within the scanned SSIDs
2373
+ WS_DEBUG_PRINT (" Performing a WiFi scan for SSID..." );
2372
2374
if (!check_valid_ssid ()) {
2373
2375
#ifdef USE_DISPLAY
2374
2376
WS._ui_helper ->show_scr_error (" ERROR" ,
@@ -2378,24 +2380,26 @@ void Wippersnapper::runNetFSM() {
2378
2380
haltError (" ERROR: Unable to find WiFi network, rebooting soon..." ,
2379
2381
WS_LED_STATUS_WIFI_CONNECTING);
2380
2382
}
2383
+ WS_DEBUG_PRINTLN (" SSID found!" );
2381
2384
// Attempt to connect to wireless network
2382
2385
maxAttempts = 5 ;
2383
2386
while (maxAttempts > 0 ) {
2384
2387
// blink before we connect
2385
2388
statusLEDBlink (WS_LED_STATUS_WIFI_CONNECTING);
2386
- WS. feedWDT ();
2389
+ feedWDT ();
2387
2390
// attempt to connect
2388
- WS_DEBUG_PRINTLN (" Attempting to connect to WiFi..." );
2391
+ WS_DEBUG_PRINT (" Connecting to WiFi (attempt #" );
2392
+ WS_DEBUG_PRINT (5 - maxAttempts);
2393
+ WS_DEBUG_PRINTLN (" )" );
2394
+ WS_PRINTER.flush ();
2395
+ feedWDT ();
2389
2396
_connect ();
2390
- WS.feedWDT ();
2391
- // blink to simulate a delay to allow wifi connection to process
2392
- statusLEDBlink (WS_LED_STATUS_WIFI_CONNECTING);
2397
+ feedWDT ();
2393
2398
// did we connect?
2394
2399
if (networkStatus () == WS_NET_CONNECTED)
2395
2400
break ;
2396
2401
maxAttempts--;
2397
2402
}
2398
-
2399
2403
// Validate connection
2400
2404
if (networkStatus () != WS_NET_CONNECTED) {
2401
2405
WS_DEBUG_PRINTLN (" ERROR: Unable to connect to WiFi!" );
@@ -2412,7 +2416,6 @@ void Wippersnapper::runNetFSM() {
2412
2416
fsmNetwork = FSM_NET_CHECK_NETWORK;
2413
2417
break ;
2414
2418
case FSM_NET_ESTABLISH_MQTT:
2415
- WS_DEBUG_PRINTLN (" Attempting to connect to IO..." );
2416
2419
#ifdef USE_DISPLAY
2417
2420
if (WS._ui_helper ->getLoadingState ())
2418
2421
WS._ui_helper ->set_label_status (" Connecting to IO..." );
@@ -2421,16 +2424,25 @@ void Wippersnapper::runNetFSM() {
2421
2424
// Attempt to connect
2422
2425
maxAttempts = 5 ;
2423
2426
while (maxAttempts > 0 ) {
2427
+ WS_DEBUG_PRINT (" Connecting to AIO MQTT (attempt #" );
2428
+ WS_DEBUG_PRINT (5 - maxAttempts);
2429
+ WS_DEBUG_PRINTLN (" )" );
2430
+ WS_PRINTER.flush ();
2431
+ WS_DEBUG_PRINT (" WiFi Status: " );
2432
+ WS_DEBUG_PRINTLN (networkStatus ());
2433
+ WS_PRINTER.flush ();
2434
+ feedWDT ();
2424
2435
statusLEDBlink (WS_LED_STATUS_MQTT_CONNECTING);
2436
+ feedWDT ();
2425
2437
int8_t mqttRC = WS._mqtt ->connect ();
2438
+ feedWDT ();
2426
2439
if (mqttRC == WS_MQTT_CONNECTED) {
2427
2440
fsmNetwork = FSM_NET_CHECK_MQTT;
2428
2441
break ;
2429
2442
}
2430
2443
WS_DEBUG_PRINTLN (
2431
2444
" Unable to connect to Adafruit IO MQTT, retrying in 3 seconds..." );
2432
2445
statusLEDBlink (WS_LED_STATUS_MQTT_CONNECTING);
2433
- delay (1800 );
2434
2446
maxAttempts--;
2435
2447
}
2436
2448
if (fsmNetwork != FSM_NET_CHECK_MQTT) {
0 commit comments