Add check for valid time

This commit is contained in:
Theo Arends 2020-07-16 17:28:47 +02:00
parent 344c091f83
commit 031b04fb53
1 changed files with 6 additions and 5 deletions

View File

@ -802,8 +802,9 @@ void TuyaSetWifiLed(void)
} }
#ifdef USE_TUYA_TIME #ifdef USE_TUYA_TIME
void TuyaSetTime(void) void TuyaSetTime(void) {
{ if (!RtcTime.valid) { return; }
uint16_t payload_len = 8; uint16_t payload_len = 8;
uint8_t payload_buffer[8]; uint8_t payload_buffer[8];
payload_buffer[0] = 0x01; payload_buffer[0] = 0x01;
@ -878,13 +879,13 @@ bool Xdrv16(uint8_t function)
Tuya.heartbeat_timer = 0; Tuya.heartbeat_timer = 0;
TuyaSendCmd(TUYA_CMD_HEARTBEAT); TuyaSendCmd(TUYA_CMD_HEARTBEAT);
} }
#ifdef USE_TUYA_TIME #ifdef USE_TUYA_TIME
if (!(uptime % 60)) { if (!(uptime % 60)) {
TuyaSetTime(); TuyaSetTime();
} }
#endif //USE_TUYA_TIME #endif //USE_TUYA_TIME
} else { } else {
TuyaSendLowPowerSuccessIfNeeded(); TuyaSendLowPowerSuccessIfNeeded();
} }
break; break;
case FUNC_SET_CHANNELS: case FUNC_SET_CHANNELS: