mirror of https://github.com/arendst/Tasmota.git
tuya: only handle reset GPIO
This commit is contained in:
parent
b958c7b716
commit
256b5cba8e
|
@ -56,9 +56,9 @@ int tuya_byte_counter = 0; // Index in serial receive buffer
|
||||||
|
|
||||||
void TuyaSendCmd(uint8_t cmd, uint8_t payload[] = nullptr, uint16_t payload_len = 0){
|
void TuyaSendCmd(uint8_t cmd, uint8_t payload[] = nullptr, uint16_t payload_len = 0){
|
||||||
uint8_t checksum = (0xFF + cmd + (payload_len >> 8) + (payload_len & 0xFF));
|
uint8_t checksum = (0xFF + cmd + (payload_len >> 8) + (payload_len & 0xFF));
|
||||||
TuyaSerial->write((uint8_t)0x55); // Tuya header 55AA
|
TuyaSerial->write(0x55); // Tuya header 55AA
|
||||||
TuyaSerial->write((uint8_t)0xAA);
|
TuyaSerial->write(0xAA);
|
||||||
TuyaSerial->write((uint8_t)0x00); // version 00
|
TuyaSerial->write(0x00); // version 00
|
||||||
TuyaSerial->write(cmd); // Tuya command
|
TuyaSerial->write(cmd); // Tuya command
|
||||||
TuyaSerial->write(payload_len >> 8); // following data length (Hi)
|
TuyaSerial->write(payload_len >> 8); // following data length (Hi)
|
||||||
TuyaSerial->write(payload_len & 0xFF); // following data length (Lo)
|
TuyaSerial->write(payload_len & 0xFF); // following data length (Lo)
|
||||||
|
@ -74,7 +74,7 @@ void TuyaSendCmd(uint8_t cmd, uint8_t payload[] = nullptr, uint16_t payload_len
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLog(LOG_LEVEL_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuyaSendState(uint8_t type, uint8_t id, uint8_t* value){
|
void TuyaSendState(uint8_t id, uint8_t type, uint8_t* value){
|
||||||
uint16_t payload_len = 4;
|
uint16_t payload_len = 4;
|
||||||
uint8_t payload_buffer[8];
|
uint8_t payload_buffer[8];
|
||||||
payload_buffer[0] = id;
|
payload_buffer[0] = id;
|
||||||
|
@ -101,11 +101,11 @@ void TuyaSendState(uint8_t type, uint8_t id, uint8_t* value){
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuyaSendBool(uint8_t id, boolean value){
|
void TuyaSendBool(uint8_t id, boolean value){
|
||||||
TuyaSendState(TUYA_TYPE_BOOL, id, &value);
|
TuyaSendState(id, TUYA_TYPE_BOOL, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuyaSendValue(uint8_t id, uint32_t value){
|
void TuyaSendValue(uint8_t id, uint32_t value){
|
||||||
TuyaSendState(TUYA_TYPE_VALUE, id, (uint8_t*)(&value));
|
TuyaSendState(id, TUYA_TYPE_VALUE, (uint8_t*)(&value));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean TuyaSetPower()
|
boolean TuyaSetPower()
|
||||||
|
@ -363,14 +363,13 @@ void TuyaResetWifi()
|
||||||
|
|
||||||
boolean TuyaButtonPressed()
|
boolean TuyaButtonPressed()
|
||||||
{
|
{
|
||||||
if ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index])) {
|
if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index]))) {
|
||||||
|
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Reset GPIO triggered"));
|
||||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), XdrvMailbox.index +1);
|
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLog(LOG_LEVEL_DEBUG);
|
||||||
TuyaResetWifi();
|
TuyaResetWifi();
|
||||||
|
return true; // Reset GPIO served here
|
||||||
}
|
}
|
||||||
return true; // Serviced here
|
return false; // Don't serve other buttons
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
|
Loading…
Reference in New Issue