mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Fix TuyaSend exception
This commit is contained in:
parent
9a66687085
commit
204289e1ab
@ -160,21 +160,23 @@ TuyaSend6 11,ABCD -> Sends raw (Type 0) data to dpId
|
||||
*/
|
||||
|
||||
void CmndTuyaSend(void) {
|
||||
if (XdrvMailbox.index > 5 && XdrvMailbox.index < 8) {
|
||||
if (XdrvMailbox.index > 6 && XdrvMailbox.index < 8) {
|
||||
return;
|
||||
}
|
||||
if (XdrvMailbox.index == 0) {
|
||||
TuyaRequestState(0);
|
||||
ResponseCmndDone();
|
||||
} else if (XdrvMailbox.index == 8) {
|
||||
TuyaRequestState(8);
|
||||
ResponseCmndDone();
|
||||
} else if (XdrvMailbox.index == 9) { // TuyaSend Topic Toggle
|
||||
Settings->tuyamcu_topic = !Settings->tuyamcu_topic;
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("TYA: TuyaMCU Stat Topic %s"), (Settings->tuyamcu_topic ? PSTR("enabled") : PSTR("disabled")));
|
||||
|
||||
ResponseCmndDone();
|
||||
} else {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
char *p;
|
||||
char *data;
|
||||
char *data = nullptr;
|
||||
uint8_t i = 0;
|
||||
uint8_t dpId = 0;
|
||||
for (char *str = strtok_r(XdrvMailbox.data, ", ", &p); str && i < 2; str = strtok_r(nullptr, ", ", &p)) {
|
||||
@ -186,22 +188,25 @@ void CmndTuyaSend(void) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (1 == XdrvMailbox.index) {
|
||||
TuyaSendBool(dpId, strtoul(data, nullptr, 0));
|
||||
} else if (2 == XdrvMailbox.index) {
|
||||
TuyaSendValue(dpId, strtoull(data, nullptr, 0));
|
||||
} else if (3 == XdrvMailbox.index) {
|
||||
TuyaSendString(dpId, data);
|
||||
} else if (5 == XdrvMailbox.index) {
|
||||
TuyaSendHexString(dpId, data);
|
||||
} else if (4 == XdrvMailbox.index) {
|
||||
TuyaSendEnum(dpId, strtoul(data, nullptr, 0));
|
||||
} else if (6 == XdrvMailbox.index) {
|
||||
TuyaSendRaw(dpId, data);
|
||||
if (data) {
|
||||
if (1 == XdrvMailbox.index) {
|
||||
TuyaSendBool(dpId, strtoul(data, nullptr, 0));
|
||||
} else if (2 == XdrvMailbox.index) {
|
||||
TuyaSendValue(dpId, strtoull(data, nullptr, 0));
|
||||
} else if (3 == XdrvMailbox.index) {
|
||||
TuyaSendString(dpId, data);
|
||||
} else if (5 == XdrvMailbox.index) {
|
||||
TuyaSendHexString(dpId, data);
|
||||
} else if (4 == XdrvMailbox.index) {
|
||||
TuyaSendEnum(dpId, strtoul(data, nullptr, 0));
|
||||
} else if (6 == XdrvMailbox.index) {
|
||||
TuyaSendRaw(dpId, data);
|
||||
}
|
||||
ResponseCmndDone();
|
||||
}
|
||||
}
|
||||
}
|
||||
ResponseCmndDone();
|
||||
// {"TuyaSend":"error"}
|
||||
}
|
||||
|
||||
// TuyaMcu fnid,dpid
|
||||
|
Loading…
x
Reference in New Issue
Block a user