Skip to content

Commit a8a415b

Browse files
committed
Report OTA errors to websocket if connected
1 parent 811e9f2 commit a8a415b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,14 @@ void otaUpdate()
886886
// machine
887887
if (otaRequestFirmwareVersionCheck == true)
888888
{
889+
if (websocketConnected)
890+
{
891+
char newVersionCSV[40];
892+
snprintf(newVersionCSV, sizeof(newVersionCSV), "newFirmwareVersion,%s,",
893+
otaReportedVersion);
894+
sendStringToWebsocket(newVersionCSV);
895+
}
896+
889897
otaUpdateStop();
890898
return;
891899
}
@@ -897,13 +905,18 @@ void otaUpdate()
897905
else
898906
{
899907
systemPrintln("Version Check: Firmware is up to date. No new firmware available.");
908+
if (websocketConnected)
909+
sendStringToWebsocket((char *)"newFirmwareVersion,CURRENT,");
910+
900911
otaUpdateStop();
901912
}
902913
}
903914
else
904915
{
905916
// Failed to get version number
906917
systemPrintln("Failed to get version number from server.");
918+
if (websocketConnected)
919+
sendStringToWebsocket((char *)"newFirmwareVersion,NO_SERVER,");
907920
otaUpdateStop();
908921
}
909922
break;
@@ -912,11 +925,21 @@ void otaUpdate()
912925
case OTA_STATE_UPDATE_FIRMWARE:
913926
// Determine if the network has failed
914927
if (!connected)
928+
{
915929
otaUpdateStop();
930+
931+
if (websocketConnected)
932+
sendStringToWebsocket((char *)"gettingNewFirmware,ERROR,");
933+
}
916934
else
917935
{
918936
// Perform the firmware update
919937
otaUpdateFirmware();
938+
939+
// Update triggers ESP.restart(). If we get this far, the firmware update has failed
940+
if (websocketConnected)
941+
sendStringToWebsocket((char *)"gettingNewFirmware,ERROR,");
942+
920943
otaUpdateStop();
921944
}
922945
break;
@@ -927,7 +950,7 @@ void otaUpdate()
927950
if (PERIODIC_DISPLAY(PD_OTA_STATE))
928951
{
929952
char line[30];
930-
const char * state;
953+
const char *state;
931954

932955
PERIODIC_CLEAR(PD_OTA_STATE);
933956
state = otaStateNameGet(otaState, line);

0 commit comments

Comments
 (0)