@@ -916,6 +916,26 @@ int getTime(const uint8_t command[], uint8_t response[])
916
916
return 5 + sizeof (now);
917
917
}
918
918
919
+ int setTime (const uint8_t command[], uint8_t response[])
920
+ {
921
+ // [0] CMD_START < 0xE0 >
922
+ // [1] Command < 1 byte >
923
+ // [2] N args < 1 byte >
924
+ // [3] time size < 1 byte >
925
+ // [4] time < 4 byte >
926
+ time_t unixtime;
927
+ memcpy (&unixtime, &command[4 ], sizeof (unixtime));
928
+
929
+ timeval epoch = {unixtime, 0 };
930
+ int ret = settimeofday ((const timeval*)&epoch, 0 );
931
+
932
+ response[2 ] = 1 ; // number of parameters
933
+ response[3 ] = 1 ; // parameter 1 length
934
+ response[4 ] = ret;
935
+
936
+ return 6 ;
937
+ }
938
+
919
939
int getIdxBSSID (const uint8_t command[], uint8_t response[])
920
940
{
921
941
uint8_t bssid[6 ];
@@ -2165,7 +2185,7 @@ const CommandHandlerType commandHandlers[] = {
2165
2185
setEnt, NULL , NULL , NULL , sendDataTcp, getDataBufTcp, insertDataBuf, NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ,
2166
2186
2167
2187
// 0x50 -> 0x5f
2168
- setPinMode, setDigitalWrite, setAnalogWrite, getDigitalRead, getAnalogRead, NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ,
2188
+ setPinMode, setDigitalWrite, setAnalogWrite, getDigitalRead, getAnalogRead, setTime , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ,
2169
2189
2170
2190
// 0x60 -> 0x6f
2171
2191
writeFile, readFile, deleteFile, existsFile, downloadFile, applyOTA, renameFile, downloadOTA, brSetECTrustAnchor, brErrorCode, NULL , NULL , NULL , NULL , NULL , NULL ,
0 commit comments