mirror of https://github.com/arendst/Tasmota.git
Merge pull request #8252 from Bettman66/development
Support for setting the time in the Tuya MCU
This commit is contained in:
commit
ac15179e21
|
@ -410,6 +410,7 @@
|
|||
#define USE_SONOFF_SC // Add support for Sonoff Sc (+1k1 code)
|
||||
#define USE_TUYA_MCU // Add support for Tuya Serial MCU
|
||||
#define TUYA_DIMMER_ID 0 // Default dimmer Id
|
||||
//#define USE_TUYA_TIME // Add support for Set Time in Tuya MCU
|
||||
#define USE_ARMTRONIX_DIMMERS // Add support for Armtronix Dimmers (+1k4 code)
|
||||
#define USE_PS_16_DZ // Add support for PS-16-DZ Dimmer (+2k code)
|
||||
#define USE_SONOFF_IFAN // Add support for Sonoff iFan02 and iFan03 (+2k code)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#define TUYA_CMD_SET_DP 0x06
|
||||
#define TUYA_CMD_STATE 0x07
|
||||
#define TUYA_CMD_QUERY_STATE 0x08
|
||||
#define TUYA_CMD_SET_TIME 0x1C
|
||||
|
||||
#define TUYA_LOW_POWER_CMD_WIFI_STATE 0x02
|
||||
#define TUYA_LOW_POWER_CMD_WIFI_RESET 0x03
|
||||
|
@ -539,6 +540,9 @@ void TuyaNormalPowerModePacketProcess(void)
|
|||
if (Tuya.buffer[6] == 0) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart"));
|
||||
Tuya.wifi_state = -2;
|
||||
#ifdef USE_TUYA_TIME
|
||||
TuyaSetTime();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -797,6 +801,24 @@ void TuyaSetWifiLed(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_TUYA_TIME
|
||||
void TuyaSetTime(void)
|
||||
{
|
||||
uint16_t payload_len = 8;
|
||||
uint8_t payload_buffer[8];
|
||||
payload_buffer[0] = 0x01;
|
||||
payload_buffer[1] = (uint8_t)RtcTime.year;
|
||||
payload_buffer[2] = RtcTime.month;
|
||||
payload_buffer[3] = RtcTime.day_of_month;
|
||||
payload_buffer[4] = RtcTime.hour;
|
||||
payload_buffer[5] = RtcTime.minute;
|
||||
payload_buffer[6] = RtcTime.second;
|
||||
payload_buffer[7] = RtcTime.day_of_week;
|
||||
|
||||
TuyaSendCmd(TUYA_CMD_SET_TIME, payload_buffer, payload_len);
|
||||
}
|
||||
#endif //USE_TUYA_TIME
|
||||
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
/*********************************************************************************************\
|
||||
* Energy Interface
|
||||
|
|
Loading…
Reference in New Issue