mirror of https://github.com/arendst/Tasmota.git
Merge pull request #7601 from s-hadinger/zigbee_zb
Change Zigbee commands renamed to ``Zb*``
This commit is contained in:
commit
022a6a05ab
|
@ -11,6 +11,7 @@
|
||||||
- Add SoftwareSerial to CSE7766 driver allowing different GPIOs (#7563)
|
- Add SoftwareSerial to CSE7766 driver allowing different GPIOs (#7563)
|
||||||
- Add optional parameter <startcolor> to command ``Scheme <scheme>, <startcolor>`` to control initial start color
|
- Add optional parameter <startcolor> to command ``Scheme <scheme>, <startcolor>`` to control initial start color
|
||||||
- Add rule trigger on one level deeper using syntax with two ``#`` like ``on zigbeereceived#vibration_sensor#aqaracubeside=0 do ...``
|
- Add rule trigger on one level deeper using syntax with two ``#`` like ``on zigbeereceived#vibration_sensor#aqaracubeside=0 do ...``
|
||||||
|
- Change Zigbee commands renamed to ``Zb*``
|
||||||
|
|
||||||
### 8.1.0.3 20200106
|
### 8.1.0.3 20200106
|
||||||
|
|
||||||
|
|
|
@ -467,29 +467,32 @@
|
||||||
#define D_JSON_TUYA_MCU_RECEIVED "TuyaReceived"
|
#define D_JSON_TUYA_MCU_RECEIVED "TuyaReceived"
|
||||||
|
|
||||||
// Commands xdrv_23_zigbee.ino
|
// Commands xdrv_23_zigbee.ino
|
||||||
|
#define D_PRFX_ZB "Zb"
|
||||||
|
#define D_PRFX_ZIGBEE "Zigbee"
|
||||||
#define D_ZIGBEE_NOT_STARTED "Zigbee not started (yet)"
|
#define D_ZIGBEE_NOT_STARTED "Zigbee not started (yet)"
|
||||||
#define D_CMND_ZIGBEE_PERMITJOIN "ZigbeePermitJoin"
|
#define D_CMND_ZIGBEE_PERMITJOIN "PermitJoin"
|
||||||
#define D_CMND_ZIGBEE_STATUS "ZigbeeStatus"
|
#define D_CMND_ZIGBEE_STATUS "Status"
|
||||||
#define D_CMND_ZIGBEE_RESET "ZigbeeReset"
|
#define D_CMND_ZIGBEE_RESET "Reset"
|
||||||
#define D_JSON_ZIGBEE_CC2530 "CC2530"
|
#define D_JSON_ZIGBEE_CC2530 "CC2530"
|
||||||
#define D_CMND_ZIGBEEZNPRECEIVE "ZigbeeZNPReceive" // only for debug
|
#define D_CMND_ZIGBEEZNPRECEIVE "ZNPReceive" // only for debug
|
||||||
#define D_CMND_ZIGBEEZNPSEND "ZigbeeZNPSend"
|
#define D_CMND_ZIGBEEZNPSEND "ZNPSend"
|
||||||
#define D_JSON_ZIGBEE_STATE "ZigbeeState"
|
#define D_JSON_ZIGBEE_STATE "ZbState"
|
||||||
#define D_JSON_ZIGBEEZNPRECEIVED "ZigbeeZNPReceived"
|
#define D_JSON_ZIGBEEZNPRECEIVED "ZbZNPReceived"
|
||||||
#define D_JSON_ZIGBEEZNPSENT "ZigbeeZNPSent"
|
#define D_JSON_ZIGBEEZNPSENT "ZbZNPSent"
|
||||||
#define D_JSON_ZIGBEEZCL_RECEIVED "ZigbeeZCLReceived"
|
#define D_JSON_ZIGBEEZCL_RECEIVED "ZbZCLReceived"
|
||||||
#define D_JSON_ZIGBEEZCL_RAW_RECEIVED "ZigbeeZCLRawReceived"
|
#define D_JSON_ZIGBEEZCL_RAW_RECEIVED "ZbZCLRawReceived"
|
||||||
#define D_JSON_ZIGBEE_DEVICE "Device"
|
#define D_JSON_ZIGBEE_DEVICE "Device"
|
||||||
#define D_JSON_ZIGBEE_NAME "Name"
|
#define D_JSON_ZIGBEE_NAME "Name"
|
||||||
#define D_CMND_ZIGBEE_NAME "ZigbeeName"
|
#define D_CMND_ZIGBEE_NAME "Name"
|
||||||
#define D_CMND_ZIGBEE_PROBE "ZigbeeProbe"
|
#define D_CMND_ZIGBEE_PROBE "Probe"
|
||||||
#define D_CMND_ZIGBEE_FORGET "ZigbeeForget"
|
#define D_CMND_ZIGBEE_FORGET "Forget"
|
||||||
#define D_CMND_ZIGBEE_SAVE "ZigbeeSave"
|
#define D_CMND_ZIGBEE_SAVE "Save"
|
||||||
#define D_CMND_ZIGBEE_RECEIVED "ZigbeeReceived"
|
|
||||||
#define D_CMND_ZIGBEE_LINKQUALITY "LinkQuality"
|
#define D_CMND_ZIGBEE_LINKQUALITY "LinkQuality"
|
||||||
#define D_CMND_ZIGBEE_READ "ZigbeeRead"
|
#define D_CMND_ZIGBEE_READ "Read"
|
||||||
#define D_CMND_ZIGBEE_SEND "ZigbeeSend"
|
#define D_CMND_ZIGBEE_SEND "Send"
|
||||||
#define D_JSON_ZIGBEE_ZCL_SENT "ZigbeeZCLSent"
|
#define D_JSON_ZIGBEE_ZCL_SENT "ZbZCLSent"
|
||||||
|
#define D_JSON_ZIGBEE_RECEIVED "ZbReceived"
|
||||||
|
#define D_JSON_ZIGBEE_RECEIVED_LEGACY "ZigbeeReceived"
|
||||||
|
|
||||||
// Commands xdrv_25_A4988_Stepper.ino
|
// Commands xdrv_25_A4988_Stepper.ino
|
||||||
#define D_CMND_MOTOR "MOTOR"
|
#define D_CMND_MOTOR "MOTOR"
|
||||||
|
|
|
@ -594,7 +594,7 @@
|
||||||
#define IR_RCV_MIN_UNKNOWN_SIZE 6 // Set the smallest sized "UNKNOWN" message packets we actually care about (default 6, max 255)
|
#define IR_RCV_MIN_UNKNOWN_SIZE 6 // Set the smallest sized "UNKNOWN" message packets we actually care about (default 6, max 255)
|
||||||
|
|
||||||
// -- Zigbee interface ----------------------------
|
// -- Zigbee interface ----------------------------
|
||||||
//#define USE_ZIGBEE // Enable serial communication with Zigbee CC2530 flashed with ZNP
|
//#define USE_ZIGBEE // Enable serial communication with Zigbee CC2530 flashed with ZNP (+35k code, +3.2k mem)
|
||||||
#define USE_ZIGBEE_PANID 0x1A63 // arbitrary PAN ID for Zigbee network, must be unique in the home
|
#define USE_ZIGBEE_PANID 0x1A63 // arbitrary PAN ID for Zigbee network, must be unique in the home
|
||||||
#define USE_ZIGBEE_EXTPANID 0xCCCCCCCCCCCCCCCCL // arbitrary extended PAN ID
|
#define USE_ZIGBEE_EXTPANID 0xCCCCCCCCCCCCCCCCL // arbitrary extended PAN ID
|
||||||
#define USE_ZIGBEE_CHANNEL 11 // Zigbee Channel (11-26)
|
#define USE_ZIGBEE_CHANNEL 11 // Zigbee Channel (11-26)
|
||||||
|
|
|
@ -681,12 +681,24 @@ void Z_Devices::jsonPublishFlush(uint16_t shortaddr) {
|
||||||
zigbee_devices.jsonClear(shortaddr);
|
zigbee_devices.jsonClear(shortaddr);
|
||||||
|
|
||||||
if (use_fname) {
|
if (use_fname) {
|
||||||
Response_P(PSTR("{\"" D_CMND_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname->c_str(), msg.c_str());
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname->c_str(), msg.c_str());
|
||||||
|
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
|
XdrvRulesProcess();
|
||||||
|
// DEPRECATED TODO
|
||||||
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED_LEGACY "\":{\"%s\":%s}}"), fname->c_str(), msg.c_str());
|
||||||
|
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
|
XdrvRulesProcess();
|
||||||
} else {
|
} else {
|
||||||
Response_P(PSTR("{\"" D_CMND_ZIGBEE_RECEIVED "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str());
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str());
|
||||||
|
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
|
XdrvRulesProcess();
|
||||||
|
// DEPRECATED TODO
|
||||||
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED_LEGACY "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str());
|
||||||
|
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
|
XdrvRulesProcess();
|
||||||
}
|
}
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
// MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
XdrvRulesProcess();
|
// XdrvRulesProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Z_Devices::jsonPublishNow(uint16_t shortaddr, JsonObject & values) {
|
void Z_Devices::jsonPublishNow(uint16_t shortaddr, JsonObject & values) {
|
||||||
|
|
|
@ -184,7 +184,7 @@ class SBuffer hibernateDevices(void) {
|
||||||
// Log
|
// Log
|
||||||
char *hex_char = (char*) malloc((buf_len * 2) + 2);
|
char *hex_char = (char*) malloc((buf_len * 2) + 2);
|
||||||
if (hex_char) {
|
if (hex_char) {
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "ZigbeeFlashStore %s"),
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "ZbFlashStore %s"),
|
||||||
ToHex_P(buf.getBuffer(), buf_len, hex_char, (buf_len * 2) + 2));
|
ToHex_P(buf.getBuffer(), buf_len, hex_char, (buf_len * 2) + 2));
|
||||||
free(hex_char);
|
free(hex_char);
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,7 +483,7 @@ void ZCLFrame::parseClusterSpecificCommand(JsonObject& json, uint8_t offset) {
|
||||||
uint32_t len = _payload.len();
|
uint32_t len = _payload.len();
|
||||||
|
|
||||||
char attrid_str[12];
|
char attrid_str[12];
|
||||||
snprintf_P(attrid_str, sizeof(attrid_str), PSTR("%04X!%02X"), _cmd_id, _cluster_id);
|
snprintf_P(attrid_str, sizeof(attrid_str), PSTR("%04X!%02X"), _cluster_id, _cmd_id);
|
||||||
|
|
||||||
char hex_char[_payload.len()*2+2];
|
char hex_char[_payload.len()*2+2];
|
||||||
ToHex_P((unsigned char*)_payload.getBuffer(), _payload.len(), hex_char, sizeof(hex_char));
|
ToHex_P((unsigned char*)_payload.getBuffer(), _payload.len(), hex_char, sizeof(hex_char));
|
||||||
|
|
|
@ -545,7 +545,7 @@ void ZigbeeStateMachine_Run(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// load current instruction details
|
// load current instruction details
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Executing instruction pc=%d"), zigbee.pc);
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Executing instruction pc=%d"), zigbee.pc);
|
||||||
const Zigbee_Instruction *cur_instr_line = &zb_prog[zigbee.pc];
|
const Zigbee_Instruction *cur_instr_line = &zb_prog[zigbee.pc];
|
||||||
cur_instr = pgm_read_byte(&cur_instr_line->i.i);
|
cur_instr = pgm_read_byte(&cur_instr_line->i.i);
|
||||||
cur_d8 = pgm_read_byte(&cur_instr_line->i.d8);
|
cur_d8 = pgm_read_byte(&cur_instr_line->i.d8);
|
||||||
|
|
|
@ -445,7 +445,7 @@ int32_t Z_ReceiveAfIncomingMessage(int32_t res, const class SBuffer &buf) {
|
||||||
String msg("");
|
String msg("");
|
||||||
msg.reserve(100);
|
msg.reserve(100);
|
||||||
json.printTo(msg);
|
json.printTo(msg);
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "ZigbeeZCLRawReceived: {\"0x%04X\":%s}"), srcaddr, msg.c_str());
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZCL_RAW_RECEIVED ": {\"0x%04X\":%s}"), srcaddr, msg.c_str());
|
||||||
|
|
||||||
zcl_received.postProcessAttributes(srcaddr, json);
|
zcl_received.postProcessAttributes(srcaddr, json);
|
||||||
// Add linkquality
|
// Add linkquality
|
||||||
|
|
|
@ -28,12 +28,18 @@ const uint8_t ZIGBEE_SOF_ALT = 0xFF;
|
||||||
#include <TasmotaSerial.h>
|
#include <TasmotaSerial.h>
|
||||||
TasmotaSerial *ZigbeeSerial = nullptr;
|
TasmotaSerial *ZigbeeSerial = nullptr;
|
||||||
|
|
||||||
const char kZigbeeCommands[] PROGMEM = "|"
|
|
||||||
|
const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix
|
||||||
D_CMND_ZIGBEEZNPSEND "|" D_CMND_ZIGBEE_PERMITJOIN "|"
|
D_CMND_ZIGBEEZNPSEND "|" D_CMND_ZIGBEE_PERMITJOIN "|"
|
||||||
D_CMND_ZIGBEE_STATUS "|" D_CMND_ZIGBEE_RESET "|" D_CMND_ZIGBEE_SEND "|"
|
D_CMND_ZIGBEE_STATUS "|" D_CMND_ZIGBEE_RESET "|" D_CMND_ZIGBEE_SEND "|"
|
||||||
D_CMND_ZIGBEE_PROBE "|" D_CMND_ZIGBEE_READ "|" D_CMND_ZIGBEEZNPRECEIVE "|"
|
D_CMND_ZIGBEE_PROBE "|" D_CMND_ZIGBEE_READ "|" D_CMND_ZIGBEEZNPRECEIVE "|"
|
||||||
D_CMND_ZIGBEE_FORGET "|" D_CMND_ZIGBEE_SAVE "|" D_CMND_ZIGBEE_NAME
|
D_CMND_ZIGBEE_FORGET "|" D_CMND_ZIGBEE_SAVE "|" D_CMND_ZIGBEE_NAME ;
|
||||||
;
|
|
||||||
|
const char kZigbeeCommands[] PROGMEM = D_PRFX_ZIGBEE "|" // legacy prefix -- deprecated
|
||||||
|
D_CMND_ZIGBEEZNPSEND "|" D_CMND_ZIGBEE_PERMITJOIN "|"
|
||||||
|
D_CMND_ZIGBEE_STATUS "|" D_CMND_ZIGBEE_RESET "|" D_CMND_ZIGBEE_SEND "|"
|
||||||
|
D_CMND_ZIGBEE_PROBE "|" D_CMND_ZIGBEE_READ "|" D_CMND_ZIGBEEZNPRECEIVE "|"
|
||||||
|
D_CMND_ZIGBEE_FORGET "|" D_CMND_ZIGBEE_SAVE "|" D_CMND_ZIGBEE_NAME ;
|
||||||
|
|
||||||
void (* const ZigbeeCommand[])(void) PROGMEM = {
|
void (* const ZigbeeCommand[])(void) PROGMEM = {
|
||||||
&CmndZigbeeZNPSend, &CmndZigbeePermitJoin,
|
&CmndZigbeeZNPSend, &CmndZigbeePermitJoin,
|
||||||
|
@ -64,7 +70,7 @@ int32_t ZigbeeProcessInput(class SBuffer &buf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "ZigbeeProcessInput: recv_prefix_match = %d, recv_filter_match = %d"), recv_prefix_match, recv_filter_match);
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "ZbProcessInput: recv_prefix_match = %d, recv_filter_match = %d"), recv_prefix_match, recv_filter_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is a recv_callback, call it now
|
// if there is a recv_callback, call it now
|
||||||
|
@ -103,7 +109,7 @@ int32_t ZigbeeProcessInput(class SBuffer &buf) {
|
||||||
res = (*zigbee.recv_unexpected)(res, buf);
|
res = (*zigbee.recv_unexpected)(res, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "ZigbeeProcessInput: res = %d"), res);
|
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "ZbProcessInput: res = %d"), res);
|
||||||
|
|
||||||
// change state accordingly
|
// change state accordingly
|
||||||
if (0 == res) {
|
if (0 == res) {
|
||||||
|
@ -136,7 +142,7 @@ void ZigbeeInput(void)
|
||||||
while (ZigbeeSerial->available()) {
|
while (ZigbeeSerial->available()) {
|
||||||
yield();
|
yield();
|
||||||
uint8_t zigbee_in_byte = ZigbeeSerial->read();
|
uint8_t zigbee_in_byte = ZigbeeSerial->read();
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZigbeeInput byte=%d len=%d"), zigbee_in_byte, zigbee_buffer->len());
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZbInput byte=%d len=%d"), zigbee_in_byte, zigbee_buffer->len());
|
||||||
|
|
||||||
if (0 == zigbee_buffer->len()) { // make sure all variables are correctly initialized
|
if (0 == zigbee_buffer->len()) { // make sure all variables are correctly initialized
|
||||||
zigbee_frame_len = 5;
|
zigbee_frame_len = 5;
|
||||||
|
@ -145,14 +151,14 @@ void ZigbeeInput(void)
|
||||||
// in this case the first bit (lsb) is missed and Tasmota receives 0xFF instead of 0xFE
|
// in this case the first bit (lsb) is missed and Tasmota receives 0xFF instead of 0xFE
|
||||||
// We forgive this mistake, and next bytes are automatically resynchronized
|
// We forgive this mistake, and next bytes are automatically resynchronized
|
||||||
if (ZIGBEE_SOF_ALT == zigbee_in_byte) {
|
if (ZIGBEE_SOF_ALT == zigbee_in_byte) {
|
||||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeInput forgiven first byte %02X (only for statistics)"), zigbee_in_byte);
|
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZbInput forgiven first byte %02X (only for statistics)"), zigbee_in_byte);
|
||||||
zigbee_in_byte = ZIGBEE_SOF;
|
zigbee_in_byte = ZIGBEE_SOF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((0 == zigbee_buffer->len()) && (ZIGBEE_SOF != zigbee_in_byte)) {
|
if ((0 == zigbee_buffer->len()) && (ZIGBEE_SOF != zigbee_in_byte)) {
|
||||||
// waiting for SOF (Start Of Frame) byte, discard anything else
|
// waiting for SOF (Start Of Frame) byte, discard anything else
|
||||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeInput discarding byte %02X"), zigbee_in_byte);
|
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZbInput discarding byte %02X"), zigbee_in_byte);
|
||||||
continue; // discard
|
continue; // discard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +218,7 @@ void ZigbeeInit(void)
|
||||||
{
|
{
|
||||||
zigbee.active = false;
|
zigbee.active = false;
|
||||||
if ((pin[GPIO_ZIGBEE_RX] < 99) && (pin[GPIO_ZIGBEE_TX] < 99)) {
|
if ((pin[GPIO_ZIGBEE_RX] < 99) && (pin[GPIO_ZIGBEE_TX] < 99)) {
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("Zigbee: GPIOs Rx:%d Tx:%d"), pin[GPIO_ZIGBEE_RX], pin[GPIO_ZIGBEE_TX]);
|
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "GPIOs Rx:%d Tx:%d"), pin[GPIO_ZIGBEE_RX], pin[GPIO_ZIGBEE_TX]);
|
||||||
// if seriallog_level is 0, we allow GPIO 13/15 to switch to Hardware Serial
|
// if seriallog_level is 0, we allow GPIO 13/15 to switch to Hardware Serial
|
||||||
ZigbeeSerial = new TasmotaSerial(pin[GPIO_ZIGBEE_RX], pin[GPIO_ZIGBEE_TX], seriallog_level ? 1 : 2, 0, 256); // set a receive buffer of 256 bytes
|
ZigbeeSerial = new TasmotaSerial(pin[GPIO_ZIGBEE_RX], pin[GPIO_ZIGBEE_TX], seriallog_level ? 1 : 2, 0, 256); // set a receive buffer of 256 bytes
|
||||||
ZigbeeSerial->begin(115200);
|
ZigbeeSerial->begin(115200);
|
||||||
|
@ -316,17 +322,17 @@ void ZigbeeZNPSend(const uint8_t *msg, size_t len) {
|
||||||
uint8_t fcs = data_len;
|
uint8_t fcs = data_len;
|
||||||
|
|
||||||
ZigbeeSerial->write(ZIGBEE_SOF); // 0xFE
|
ZigbeeSerial->write(ZIGBEE_SOF); // 0xFE
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend SOF %02X"), ZIGBEE_SOF);
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend SOF %02X"), ZIGBEE_SOF);
|
||||||
ZigbeeSerial->write(data_len);
|
ZigbeeSerial->write(data_len);
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend LEN %02X"), data_len);
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend LEN %02X"), data_len);
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
uint8_t b = pgm_read_byte(msg + i);
|
uint8_t b = pgm_read_byte(msg + i);
|
||||||
ZigbeeSerial->write(b);
|
ZigbeeSerial->write(b);
|
||||||
fcs ^= b;
|
fcs ^= b;
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend byt %02X"), b);
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend byt %02X"), b);
|
||||||
}
|
}
|
||||||
ZigbeeSerial->write(fcs); // finally send fcs checksum byte
|
ZigbeeSerial->write(fcs); // finally send fcs checksum byte
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend FCS %02X"), fcs);
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend FCS %02X"), fcs);
|
||||||
}
|
}
|
||||||
// Now send a MQTT message to report the sent message
|
// Now send a MQTT message to report the sent message
|
||||||
char hex_char[(len * 2) + 2];
|
char hex_char[(len * 2) + 2];
|
||||||
|
@ -417,13 +423,13 @@ void zigbeeZCLSendStr(uint16_t dstAddr, uint8_t endpoint, const char *data) {
|
||||||
if (0 == endpoint) {
|
if (0 == endpoint) {
|
||||||
// endpoint is not specified, let's try to find it from shortAddr
|
// endpoint is not specified, let's try to find it from shortAddr
|
||||||
endpoint = zigbee_devices.findClusterEndpointIn(dstAddr, cluster);
|
endpoint = zigbee_devices.findClusterEndpointIn(dstAddr, cluster);
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZigbeeSend: guessing endpoint 0x%02X"), endpoint);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: guessing endpoint 0x%02X"), endpoint);
|
||||||
}
|
}
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZigbeeSend: dstAddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %s"),
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: dstAddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %s"),
|
||||||
dstAddr, cluster, endpoint, cmd, data);
|
dstAddr, cluster, endpoint, cmd, data);
|
||||||
|
|
||||||
if (0 == endpoint) {
|
if (0 == endpoint) {
|
||||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeSend: unspecified endpoint"));
|
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZbSend: unspecified endpoint"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,9 +524,9 @@ void CmndZigbeeSend(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZigbeeSend: command_template = %s"), cmd_str.c_str());
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: command_template = %s"), cmd_str.c_str());
|
||||||
cmd_str = zigbeeCmdAddParams(cmd_str.c_str(), x, y, z); // fill in parameters
|
cmd_str = zigbeeCmdAddParams(cmd_str.c_str(), x, y, z); // fill in parameters
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZigbeeSend: command_final = %s"), cmd_str.c_str());
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: command_final = %s"), cmd_str.c_str());
|
||||||
} else {
|
} else {
|
||||||
// we have zero command, pass through until last error for missing command
|
// we have zero command, pass through until last error for missing command
|
||||||
}
|
}
|
||||||
|
@ -531,7 +537,7 @@ void CmndZigbeeSend(void) {
|
||||||
// we have an unsupported command type, just ignore it and fallback to missing command
|
// we have an unsupported command type, just ignore it and fallback to missing command
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZigbeeCmd_actual: ZigbeeZCLSend {\"device\":\"0x%04X\",\"endpoint\":%d,\"send\":\"%s\"}"),
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbCmd_actual: ZigbeeZCLSend {\"device\":\"0x%04X\",\"endpoint\":%d,\"send\":\"%s\"}"),
|
||||||
device, endpoint, cmd_str.c_str());
|
device, endpoint, cmd_str.c_str());
|
||||||
zigbeeZCLSendStr(device, endpoint, cmd_str.c_str());
|
zigbeeZCLSendStr(device, endpoint, cmd_str.c_str());
|
||||||
} else {
|
} else {
|
||||||
|
@ -717,7 +723,8 @@ bool Xdrv23(uint8_t function)
|
||||||
ZigbeeInit();
|
ZigbeeInit();
|
||||||
break;
|
break;
|
||||||
case FUNC_COMMAND:
|
case FUNC_COMMAND:
|
||||||
result = DecodeCommand(kZigbeeCommands, ZigbeeCommand);
|
result = DecodeCommand(kZbCommands, ZigbeeCommand);
|
||||||
|
result = result || DecodeCommand(kZigbeeCommands, ZigbeeCommand); // deprecated
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue