@@ -581,8 +581,15 @@ void otaDisplayPercentage(int bytesWritten, int totalLength, bool alwaysDisplay)
581
581
if (bytesWritten == totalLength)
582
582
systemPrintln (" ]" );
583
583
584
+ // Display progress on the display
584
585
displayFirmwareUpdateProgress (percent);
585
586
587
+ // Report progress over the BLE Command Channel
588
+ char stringPercent[5 ];
589
+ snprintf (stringPercent, sizeof (stringPercent), " %d" , percent);
590
+ commandSendStringOkResponse ((char *)" SPEXE" , (char *)" UPDATEPROGRESS" , stringPercent);
591
+
592
+ // Report progress to the Web Config socket
586
593
if (apConfigFirmwareUpdateInProcess == true )
587
594
{
588
595
char myProgress[50 ];
@@ -819,7 +826,7 @@ void otaUpdate()
819
826
otaUpdateStop ();
820
827
break ;
821
828
822
- // Wait for a request from a user or from the scheduler
829
+ // Wait for a request from a user, the Web Config, CLI, or from the scheduler
823
830
case OTA_STATE_OFF:
824
831
if (otaRequestFirmwareVersionCheck || otaRequestFirmwareUpdate)
825
832
{
@@ -849,14 +856,31 @@ void otaUpdate()
849
856
850
857
else if ((millis () - connectTimer) > (10 * MILLISECONDS_IN_A_SECOND))
851
858
{
852
- // Report failed connection to web client
859
+ if (settings.debugFirmwareUpdate )
860
+ systemPrintln (" Firmware update failed to connect to network" );
861
+
862
+ // If we are connected to the Web Config or BLE CLI, then we assume the user
863
+ // is requesting the firmware update via those interfaces, thus we attempt an update
864
+ // only once, stopping the state machine on failure
865
+
853
866
if (websocketConnected)
854
867
{
855
- if (settings.debugFirmwareUpdate )
856
- systemPrintln (" Firmware update failed to connect to network" );
868
+ // Report failed connection to web client
857
869
sendStringToWebsocket ((char *)" newFirmwareVersion,NO_INTERNET," );
858
870
otaUpdateStop ();
859
871
}
872
+
873
+ if (bluetoothCommandIsConnected ())
874
+ {
875
+ // Report failure to the CLI
876
+ if (otaRequestFirmwareUpdate)
877
+ commandSendExecuteErrorResponse ((char *)" SPEXE" , (char *)" UPDATEFIRMWARE" , (char *)" No Internet" );
878
+ else if (otaRequestFirmwareVersionCheck)
879
+ commandSendErrorResponse ((char *)" SPGET" , (char *)" rtkRemoteFirmwareVersion" , (char *)" No Internet" );
880
+ otaUpdateStop ();
881
+ }
882
+
883
+
860
884
}
861
885
break ;
862
886
@@ -904,6 +928,12 @@ void otaUpdate()
904
928
sendStringToWebsocket (newVersionCSV);
905
929
}
906
930
931
+ if (bluetoothCommandIsConnected ())
932
+ {
933
+ // Report value over the CLI
934
+ commandSendStringResponse ((char *)" SPGET" , (char *)" rtkRemoteVersion" , otaReportedVersion);
935
+ }
936
+
907
937
otaUpdateStop ();
908
938
return ;
909
939
}
@@ -927,6 +957,12 @@ void otaUpdate()
927
957
systemPrintln (" Failed to get version number from server." );
928
958
if (websocketConnected)
929
959
sendStringToWebsocket ((char *)" newFirmwareVersion,NO_SERVER," );
960
+
961
+ // Report failure over the CLI
962
+ if (bluetoothCommandIsConnected ())
963
+ commandSendExecuteErrorResponse ((char *)" SPGET" , (char *)" rtkRemoteFimrwareVersion" ,
964
+ (char *)" No Server" );
965
+
930
966
otaUpdateStop ();
931
967
}
932
968
break ;
@@ -940,6 +976,11 @@ void otaUpdate()
940
976
941
977
if (websocketConnected)
942
978
sendStringToWebsocket ((char *)" gettingNewFirmware,ERROR," );
979
+
980
+ // Report failure over the CLI
981
+ if (bluetoothCommandIsConnected ())
982
+ commandSendExecuteErrorResponse ((char *)" SPEXE" , (char *)" UPDATEFIRMWARE" ,
983
+ (char *)" Connection Error" );
943
984
}
944
985
else
945
986
{
@@ -950,6 +991,10 @@ void otaUpdate()
950
991
if (websocketConnected)
951
992
sendStringToWebsocket ((char *)" gettingNewFirmware,ERROR," );
952
993
994
+ // Report failure over the CLI
995
+ if (bluetoothCommandIsConnected ())
996
+ commandSendExecuteErrorResponse ((char *)" SPEXE" , (char *)" UPDATEFIRMWARE" , (char *)" OTA Error" );
997
+
953
998
otaUpdateStop ();
954
999
}
955
1000
break ;
0 commit comments