mirror of https://github.com/arendst/Tasmota.git
commit
cf27cff602
|
@ -114,6 +114,7 @@ void (* const TuyaCommand[])(void) PROGMEM = {
|
|||
|
||||
TuyaSend<x> dpId,data
|
||||
|
||||
TuyaSend0 -> Sends TUYA_CMD_QUERY_STATE
|
||||
TuyaSend1 11,1 -> Sends boolean (Type 1) data 0/1 to dpId 11 (Max data length 1 byte)
|
||||
TuyaSend2 11,100 -> Sends integer (Type 2) data 100 to dpId 11 (Max data length 4 bytes)
|
||||
TuyaSend2 11,0xAABBCCDD -> Sends 4 bytes (Type 2) data to dpId 11 (Max data length 4 bytes)
|
||||
|
@ -124,9 +125,13 @@ TuyaSend4 11,1 -> Sends enum (Type 4) data 0/1/2/3/4/5 to dpId 11 (Max data leng
|
|||
|
||||
|
||||
void CmndTuyaSend(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 4)) {
|
||||
if (XdrvMailbox.index > 4) {
|
||||
return;
|
||||
}
|
||||
if (XdrvMailbox.index == 0) {
|
||||
TuyaRequestState();
|
||||
} else {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
|
||||
char *p;
|
||||
char *data;
|
||||
uint8_t i = 0;
|
||||
|
@ -150,8 +155,8 @@ void CmndTuyaSend(void) {
|
|||
TuyaSendEnum(dpId, strtoul(data, nullptr, 0));
|
||||
}
|
||||
}
|
||||
ResponseCmndDone();
|
||||
}
|
||||
ResponseCmndDone();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -682,10 +687,31 @@ void TuyaSerialInput(void)
|
|||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
||||
uint8_t dpidStart = 6;
|
||||
while (dpidStart + 4 < Tuya.byte_counter) {
|
||||
uint8_t dpId = Tuya.buffer[dpidStart];
|
||||
uint8_t dpDataType = Tuya.buffer[dpidStart + 1];
|
||||
uint16_t dpDataLen = Tuya.buffer[dpidStart + 2] << 8 | Tuya.buffer[dpidStart + 3];
|
||||
ResponseAppend_P(PSTR(",\"%d\":{\"DpId\":%d,\"DpIdType\":%d,\"DpIdData\":\"%s\""), Tuya.buffer[dpidStart], Tuya.buffer[dpidStart], Tuya.buffer[dpidStart + 1], ToHex_P((unsigned char*)&Tuya.buffer[dpidStart + 4], dpDataLen, hex_char, sizeof(hex_char)));
|
||||
if (TUYA_TYPE_STRING == Tuya.buffer[dpidStart + 1]) {
|
||||
ResponseAppend_P(PSTR(",\"Type3Data\":\"%.*s\""), dpDataLen, (char *)&Tuya.buffer[dpidStart + 4]);
|
||||
const unsigned char *dpData = (unsigned char*)&Tuya.buffer[dpidStart + 4];
|
||||
const char *dpHexData = ToHex_P(dpData, dpDataLen, hex_char, sizeof(hex_char));
|
||||
|
||||
if (TUYA_CMD_STATE == Tuya.buffer[3]) {
|
||||
ResponseAppend_P(PSTR(",\"DpType%uId%u\":"), dpDataType, dpId);
|
||||
if (TUYA_TYPE_BOOL == dpDataType && dpDataLen == 1) {
|
||||
ResponseAppend_P(PSTR("%u"), dpData[0]);
|
||||
} else if (TUYA_TYPE_VALUE == dpDataType && dpDataLen == 4) {
|
||||
uint32_t dpValue = (uint32_t)dpData[0] << 24 | (uint32_t)dpData[1] << 16 | (uint32_t)dpData[2] << 8 | (uint32_t)dpData[3] << 0;
|
||||
ResponseAppend_P(PSTR("%u"), dpValue);
|
||||
} else if (TUYA_TYPE_STRING == dpDataType) {
|
||||
ResponseAppend_P(PSTR("\"%.*s\""), dpDataLen, dpData);
|
||||
} else if (TUYA_TYPE_ENUM == dpDataType && dpDataLen == 1) {
|
||||
ResponseAppend_P(PSTR("%u"), dpData[0]);
|
||||
} else {
|
||||
ResponseAppend_P(PSTR("\"0x%s\""), dpHexData);
|
||||
}
|
||||
}
|
||||
|
||||
ResponseAppend_P(PSTR(",\"%d\":{\"DpId\":%d,\"DpIdType\":%d,\"DpIdData\":\"%s\""), dpId, dpId, dpDataType, dpHexData);
|
||||
if (TUYA_TYPE_STRING == dpDataType) {
|
||||
ResponseAppend_P(PSTR(",\"Type3Data\":\"%.*s\""), dpDataLen, dpData);
|
||||
}
|
||||
ResponseAppend_P(PSTR("}"));
|
||||
dpidStart += dpDataLen + 4;
|
||||
|
|
Loading…
Reference in New Issue