@@ -31,7 +31,6 @@ void sendStringToWebsocket(const char *stringToSend)
31
31
}
32
32
33
33
// To send content to the webserver, we would call: webserver->sendContent(stringToSend);
34
- //
35
34
// But here we want to send content to the websocket (wsserver)...
36
35
37
36
httpd_ws_frame_t ws_pkt;
@@ -826,48 +825,36 @@ static void handleFirmwareFileUpload()
826
825
}
827
826
}
828
827
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)
834
831
{
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 ];
847
833
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 )
853
842
{
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);
863
846
}
864
847
else
865
848
{
866
849
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," );
868
852
}
853
+
854
+ stringRecord (settingsCSV, " newFirmwareVersion" , newVersionCSV);
855
+
856
+ strcat (settingsCSV, " \0 " );
869
857
}
870
- */
871
858
872
859
// Create a csv string with the dynamic data to update (current coordinates, battery level, etc)
873
860
void createDynamicDataString (char *settingsCSV)
0 commit comments