@@ -31,7 +31,6 @@ void sendStringToWebsocket(const char *stringToSend)
3131 }
3232
3333 // To send content to the webserver, we would call: webserver->sendContent(stringToSend);
34- //
3534 // But here we want to send content to the websocket (wsserver)...
3635
3736 httpd_ws_frame_t ws_pkt;
@@ -826,48 +825,36 @@ static void handleFirmwareFileUpload()
826825 }
827826}
828827
829- /*
830- // TODO: delete this. This is the old method - using AsyncWebSocketClient
831- // Events triggered by web sockets
832- void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data,
833- size_t len)
828+ // Report back to the web config page with a CSV that contains the either CURRENT or
829+ // the latest version as obtained by the OTA state machine
830+ void createFirmwareVersionString (char *settingsCSV)
834831{
835- if (type == WS_EVT_CONNECT)
836- {
837- if (settings.debugWebConfig == true)
838- systemPrintln("Websocket client connected");
839- client->text(settingsCSV);
840- lastDynamicDataUpdate = millis();
841- websocketConnected = true;
842- }
843- else if (type == WS_EVT_DISCONNECT)
844- {
845- if (settings.debugWebConfig == true)
846- systemPrintln("Websocket client disconnected");
832+ char newVersionCSV[100 ];
847833
848- // User has either refreshed the page or disconnected. Recompile the current settings.
849- createSettingsString(settingsCSV);
850- websocketConnected = false;
851- }
852- else if (type == WS_EVT_DATA)
834+ settingsCSV[0 ] = ' \0 ' ; // Erase current settings string
835+
836+ // Create a string of the unit's current firmware version
837+ char currentVersion[21 ];
838+ getFirmwareVersion (currentVersion, sizeof (currentVersion), enableRCFirmware);
839+
840+ // Compare the unit's version against the reported version from OTA
841+ if (isReportedVersionNewer (otaReportedVersion, currentVersion) == true )
853842 {
854- if (currentlyParsingData == false)
855- {
856- for (int i = 0; i < len; i++)
857- {
858- incomingSettings[incomingSettingsSpot++] = data[i];
859- incomingSettingsSpot %= AP_CONFIG_SETTING_SIZE;
860- }
861- timeSinceLastIncomingSetting = millis();
862- }
843+ if (settings.debugWebConfig == true )
844+ systemPrintln (" New version detected" );
845+ snprintf (newVersionCSV, sizeof (newVersionCSV), " %s," , otaReportedVersion);
863846 }
864847 else
865848 {
866849 if (settings.debugWebConfig == true )
867- systemPrintf("onWsEvent: unrecognised AwsEventType %d\r\n", type);
850+ systemPrintln (" No new firmware available" );
851+ snprintf (newVersionCSV, sizeof (newVersionCSV), " CURRENT," );
868852 }
853+
854+ stringRecord (settingsCSV, " newFirmwareVersion" , newVersionCSV);
855+
856+ strcat (settingsCSV, " \0 " );
869857}
870- */
871858
872859// Create a csv string with the dynamic data to update (current coordinates, battery level, etc)
873860void createDynamicDataString (char *settingsCSV)
0 commit comments