@@ -1290,38 +1290,56 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
12901290
12911291 sendStringToWebsocket ((char *)" checkingNewFirmware,1," ); // Tell the config page we received their request
12921292
1293- // Indicate to the OTA state machine that we need to do a version check
1294- otaRequestFirmwareVersionCheck = true ;
1293+ // We don't use the OTA state machine here because we need to respond to
1294+ // Web Config immediately of success or failure
1295+
1296+ // If we're in AP only mode (no internet), try WiFi with current SSIDs
1297+ if (networkIsInterfaceStarted (NETWORK_WIFI) && networkHasInternet () == false )
1298+ {
1299+ wifiStart ();
1300+ }
12951301
12961302 // Get firmware version from server
1297- // otaCheckVersion will call wifiConnect if needed
1298- // if (otaCheckVersion(reportedVersion, sizeof(reportedVersion)))
1299- // {
1300- // // We got a version number, now determine if it's newer or not
1301- // char currentVersion[21];
1302- // getFirmwareVersion(currentVersion, sizeof(currentVersion), enableRCFirmware);
1303- // if (isReportedVersionNewer(reportedVersion, currentVersion) == true)
1304- // {
1305- // if (settings.debugWebServer == true)
1306- // systemPrintln("New version detected");
1307- // snprintf(newVersionCSV, sizeof(newVersionCSV), "newFirmwareVersion,%s,", reportedVersion);
1308- // }
1309- // else
1310- // {
1311- // if (settings.debugWebServer == true)
1312- // systemPrintln("No new firmware available");
1313- // snprintf(newVersionCSV, sizeof(newVersionCSV), "newFirmwareVersion,CURRENT,");
1314- // }
1315- // }
1316- // else
1317- // {
1318- // // Failed to get version number
1319- // if (settings.debugWebServer == true)
1320- // systemPrintln("Sending error to AP config page");
1321- // snprintf(newVersionCSV, sizeof(newVersionCSV), "newFirmwareVersion,ERROR,");
1322- // }
1323-
1324- // sendStringToWebsocket(newVersionCSV);
1303+ char newVersionCSV[40 ];
1304+ if (networkHasInternet () == false )
1305+ {
1306+ // No internet. Report error.
1307+ if (settings.debugWebServer == true )
1308+ systemPrintln (" No internet available. Sending error to Web config page." );
1309+ snprintf (newVersionCSV, sizeof (newVersionCSV), " newFirmwareVersion,NO_INTERNET," );
1310+ }
1311+ else
1312+ {
1313+ char otaReportedVersion[50 ];
1314+ if (otaCheckVersion (otaReportedVersion, sizeof (otaReportedVersion)))
1315+ {
1316+ // We got a version number, now determine if it's newer or not
1317+ char currentVersion[40 ];
1318+ getFirmwareVersion (currentVersion, sizeof (currentVersion), enableRCFirmware);
1319+ if (isReportedVersionNewer (otaReportedVersion, currentVersion) == true )
1320+ {
1321+ if (settings.debugWebServer == true )
1322+ systemPrintln (" New version detected" );
1323+ snprintf (newVersionCSV, sizeof (newVersionCSV), " newFirmwareVersion,%s," , otaReportedVersion);
1324+ }
1325+ else
1326+ {
1327+ if (settings.debugWebServer == true )
1328+ systemPrintln (" No new firmware available" );
1329+ snprintf (newVersionCSV, sizeof (newVersionCSV), " newFirmwareVersion,CURRENT," );
1330+ }
1331+ }
1332+ else
1333+ {
1334+ // Failed to get version number
1335+ if (settings.debugWebServer == true )
1336+ systemPrintln (" Sending error to Web config page" );
1337+ snprintf (newVersionCSV, sizeof (newVersionCSV), " newFirmwareVersion,NO_SERVER," );
1338+ }
1339+ }
1340+
1341+ sendStringToWebsocket (newVersionCSV);
1342+
13251343 knownSetting = true ;
13261344 }
13271345 else if (strcmp (settingName, " getNewFirmware" ) == 0 )
@@ -2326,12 +2344,12 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
23262344 break ;
23272345 // System state at power on. Convert various system states to either Rover, Base, NTP, or BaseCast.
23282346 // Manually handled below
2329- // case tSysState: {
2330- // SystemState *ptr = (SystemState *)var;
2331- // writeToString(settingValueStr, (int)*ptr);
2332- // knownSetting = true;
2333- // }
2334- break ;
2347+ // case tSysState: {
2348+ // SystemState *ptr = (SystemState *)var;
2349+ // writeToString(settingValueStr, (int)*ptr);
2350+ // knownSetting = true;
2351+ // }
2352+ break ;
23352353 case tPulseEdg: {
23362354 pulseEdgeType_e *ptr = (pulseEdgeType_e *)var;
23372355 writeToString (settingValueStr, (int )*ptr);
0 commit comments