mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Refactor rules processing
This commit is contained in:
parent
460f166bcc
commit
a84ebe552a
@ -288,8 +288,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mqtt_data[0] != '\0') {
|
if (mqtt_data[0] != '\0') {
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, type);
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, type);
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
fallback_topic_flag = false;
|
fallback_topic_flag = false;
|
||||||
}
|
}
|
||||||
|
@ -136,8 +136,7 @@ void RotaryHandler(void) {
|
|||||||
#ifdef USE_LIGHT
|
#ifdef USE_LIGHT
|
||||||
if (!Settings.flag4.rotary_uses_rules) { // SetOption98 - Use rules instead of light control
|
if (!Settings.flag4.rotary_uses_rules) { // SetOption98 - Use rules instead of light control
|
||||||
ResponseLightState(0);
|
ResponseLightState(0);
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_CMND_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
#endif // USE_LIGHT
|
#endif // USE_LIGHT
|
||||||
Encoder[index].direction = 0;
|
Encoder[index].direction = 0;
|
||||||
|
@ -1429,8 +1429,7 @@ void SerialInput(void)
|
|||||||
}
|
}
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SERIALRECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_SERIALRECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
serial_in_byte_counter = 0;
|
serial_in_byte_counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,10 +381,20 @@ void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic)
|
|||||||
MqttPublishPrefixTopic_P(prefix, subtopic, false);
|
MqttPublishPrefixTopic_P(prefix, subtopic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MqttPublishPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic, bool retained)
|
||||||
|
{
|
||||||
|
MqttPublishPrefixTopic_P(prefix, subtopic, retained);
|
||||||
|
XdrvRulesProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MqttPublishPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic)
|
||||||
|
{
|
||||||
|
MqttPublishPrefixTopicRulesProcess_P(prefix, subtopic, false);
|
||||||
|
}
|
||||||
|
|
||||||
void MqttPublishTeleSensor(void)
|
void MqttPublishTeleSensor(void)
|
||||||
{
|
{
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); // CMND_SENSORRETAIN
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); // CMND_SENSORRETAIN
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublishPowerState(uint32_t device)
|
void MqttPublishPowerState(uint32_t device)
|
||||||
|
@ -370,8 +370,7 @@ void EnergyMarginCheck(void)
|
|||||||
}
|
}
|
||||||
if (jsonflg) {
|
if (jsonflg) {
|
||||||
ResponseJsonEndEnd();
|
ResponseJsonEndEnd();
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_MARGINS), MQTT_TELE_RETAIN);
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_MARGINS), MQTT_TELE_RETAIN);
|
||||||
XdrvRulesProcess();
|
|
||||||
EnergyMqttShow();
|
EnergyMqttShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1878,8 +1878,7 @@ void LightAnimate(void)
|
|||||||
Response_P(PSTR("{\"" D_CMND_WAKEUP "\":\"" D_JSON_DONE "\""));
|
Response_P(PSTR("{\"" D_CMND_WAKEUP "\":\"" D_JSON_DONE "\""));
|
||||||
ResponseLightState(1);
|
ResponseLightState(1);
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_WAKEUP));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_CMND_WAKEUP));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
Light.wakeup_active = 0;
|
Light.wakeup_active = 0;
|
||||||
Settings.light_scheme = LS_POWER;
|
Settings.light_scheme = LS_POWER;
|
||||||
|
@ -155,9 +155,8 @@ void IrReceiveCheck(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResponseJsonEndEnd();
|
ResponseJsonEndEnd();
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_IRRECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_IRRECEIVED));
|
||||||
|
|
||||||
XdrvRulesProcess();
|
|
||||||
#ifdef USE_DOMOTICZ
|
#ifdef USE_DOMOTICZ
|
||||||
if (iridx) {
|
if (iridx) {
|
||||||
unsigned long value = results.value | (iridx << 28); // [Protocol:4, Data:28]
|
unsigned long value = results.value | (iridx << 28); // [Protocol:4, Data:28]
|
||||||
|
@ -232,9 +232,7 @@ void IrReceiveCheck(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResponseJsonEndEnd();
|
ResponseJsonEndEnd();
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_IRRECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_IRRECEIVED));
|
||||||
|
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
irrecv->resume();
|
irrecv->resume();
|
||||||
@ -475,7 +473,7 @@ uint32_t IrRemoteCmndIrSendRaw(void)
|
|||||||
for (uint32_t i = 0; i <= count; i++) {
|
for (uint32_t i = 0; i <= count; i++) {
|
||||||
GC[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0);
|
GC[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0);
|
||||||
if (!GC[i]) {
|
if (!GC[i]) {
|
||||||
return IE_INVALID_RAWDATA;
|
return IE_INVALID_RAWDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
irsend_active = true;
|
irsend_active = true;
|
||||||
|
@ -226,9 +226,7 @@ void SonoffBridgeReceivedRaw(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ResponseAppend_P(PSTR("\"}}"));
|
ResponseAppend_P(PSTR("\"}}"));
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_CMND_RFRAW));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_CMND_RFRAW));
|
||||||
|
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
@ -298,8 +296,7 @@ void SonoffBridgeReceived(void)
|
|||||||
}
|
}
|
||||||
ResponseTime_P(PSTR(",\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_SYNC "\":%d,\"" D_JSON_LOW "\":%d,\"" D_JSON_HIGH "\":%d,\"" D_JSON_DATA "\":%s,\"" D_CMND_RFKEY "\":%s}}"),
|
ResponseTime_P(PSTR(",\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_SYNC "\":%d,\"" D_JSON_LOW "\":%d,\"" D_JSON_HIGH "\":%d,\"" D_JSON_DATA "\":%s,\"" D_CMND_RFKEY "\":%s}}"),
|
||||||
sync_time, low_time, high_time, stemp, rfkey);
|
sync_time, low_time, high_time, stemp, rfkey);
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_RFRECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_RFRECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
#ifdef USE_DOMOTICZ
|
#ifdef USE_DOMOTICZ
|
||||||
DomoticzSensor(DZ_COUNT, received_id); // Send rid as Domoticz Counter value
|
DomoticzSensor(DZ_COUNT, received_id); // Send rid as Domoticz Counter value
|
||||||
#endif // USE_DOMOTICZ
|
#endif // USE_DOMOTICZ
|
||||||
|
@ -93,8 +93,7 @@ void SerialBridgeInput(void)
|
|||||||
}
|
}
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
serial_bridge_in_byte_counter = 0;
|
serial_bridge_in_byte_counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,7 @@ void RfReceiveCheck(void)
|
|||||||
}
|
}
|
||||||
ResponseTime_P(PSTR(",\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_RF_DATA "\":%s,\"" D_JSON_RF_BITS "\":%d,\"" D_JSON_RF_PROTOCOL "\":%d,\"" D_JSON_RF_PULSE "\":%d}}"),
|
ResponseTime_P(PSTR(",\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_RF_DATA "\":%s,\"" D_JSON_RF_BITS "\":%d,\"" D_JSON_RF_PROTOCOL "\":%d,\"" D_JSON_RF_PULSE "\":%d}}"),
|
||||||
stemp, bits, protocol, delay);
|
stemp, bits, protocol, delay);
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_RFRECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_RFRECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
#ifdef USE_DOMOTICZ
|
#ifdef USE_DOMOTICZ
|
||||||
DomoticzSensor(DZ_COUNT, data); // Send data as Domoticz Counter value
|
DomoticzSensor(DZ_COUNT, data); // Send data as Domoticz Counter value
|
||||||
#endif // USE_DOMOTICZ
|
#endif // USE_DOMOTICZ
|
||||||
|
@ -622,8 +622,7 @@ public:
|
|||||||
_frame_control, _manuf_code, _transact_seq, _cmd_id,
|
_frame_control, _manuf_code, _transact_seq, _cmd_id,
|
||||||
hex_char);
|
hex_char);
|
||||||
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
XdrvRulesProcess();
|
|
||||||
} else {
|
} else {
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data);
|
||||||
}
|
}
|
||||||
@ -1152,8 +1151,7 @@ void ZCLFrame::parseResponse(void) {
|
|||||||
msg.reserve(100);
|
msg.reserve(100);
|
||||||
json.printTo(msg);
|
json.printTo(msg);
|
||||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RESPONSE "\":%s}"), msg.c_str());
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RESPONSE "\":%s}"), msg.c_str());
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1097,8 +1097,7 @@ void ZigbeeStateMachine_Run(void) {
|
|||||||
const char *f_msg = (const char*) cur_ptr1;
|
const char *f_msg = (const char*) cur_ptr1;
|
||||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{\"Status\":%d,\"Message\":\"%s\"}}"),
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{\"Status\":%d,\"Message\":\"%s\"}}"),
|
||||||
cur_d8, f_msg);
|
cur_d8, f_msg);
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ZGB_INSTR_SEND:
|
case ZGB_INSTR_SEND:
|
||||||
|
@ -43,8 +43,7 @@ int32_t EZ_RSTACK(uint8_t reset_code) {
|
|||||||
",\"Code\":%d}}"),
|
",\"Code\":%d}}"),
|
||||||
ZIGBEE_STATUS_BOOT, reason_str, reset_code);
|
ZIGBEE_STATUS_BOOT, reason_str, reset_code);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EZSP: received ASH "ERROR" frame, indicating that the MCU finished boot
|
// EZSP: received ASH "ERROR" frame, indicating that the MCU finished boot
|
||||||
@ -60,8 +59,7 @@ int32_t EZ_ERROR(uint8_t error_code) {
|
|||||||
",\"Code\":%d}}"),
|
",\"Code\":%d}}"),
|
||||||
ZIGBEE_STATUS_ABORT, reason_str, error_code);
|
ZIGBEE_STATUS_ABORT, reason_str, error_code);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t EZ_ReadAPSUnicastMessage(int32_t res, class SBuffer &buf) {
|
int32_t EZ_ReadAPSUnicastMessage(int32_t res, class SBuffer &buf) {
|
||||||
@ -112,8 +110,7 @@ int32_t EZ_NetworkParameters(int32_t res, class SBuffer &buf) {
|
|||||||
",\"DeviceType\":%d}}"),
|
",\"DeviceType\":%d}}"),
|
||||||
ZIGBEE_STATUS_EZ_INFO, hex, localShortAddr, node_type);
|
ZIGBEE_STATUS_EZ_INFO, hex, localShortAddr, node_type);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -161,8 +158,7 @@ int32_t Z_EZSPNetworkParameters(int32_t res, class SBuffer &buf) {
|
|||||||
",\"DeviceType\":%d}}"),
|
",\"DeviceType\":%d}}"),
|
||||||
ZIGBEE_STATUS_EZ_INFO, hex, localShortAddr, node_type);
|
ZIGBEE_STATUS_EZ_INFO, hex, localShortAddr, node_type);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -212,10 +208,8 @@ int32_t ZNP_ReceiveDeviceInfo(int32_t res, class SBuffer &buf) {
|
|||||||
ResponseAppend_P(PSTR("]"));
|
ResponseAppend_P(PSTR("]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseJsonEnd(); // append '}'
|
ResponseJsonEndEnd(); // append '}}'
|
||||||
ResponseJsonEnd(); // append '}'
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -257,8 +251,7 @@ int32_t ZNP_Reboot(int32_t res, class SBuffer &buf) {
|
|||||||
ZIGBEE_STATUS_BOOT, reason_str,
|
ZIGBEE_STATUS_BOOT, reason_str,
|
||||||
major_rel, minor_rel);
|
major_rel, minor_rel);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
if ((0x02 == major_rel) && (0x06 == minor_rel)) {
|
if ((0x02 == major_rel) && (0x06 == minor_rel)) {
|
||||||
return 0; // version 2.6.x is ok
|
return 0; // version 2.6.x is ok
|
||||||
@ -289,8 +282,7 @@ int32_t ZNP_ReceiveCheckVersion(int32_t res, class SBuffer &buf) {
|
|||||||
ZIGBEE_STATUS_CC_VERSION, major_rel, minor_rel,
|
ZIGBEE_STATUS_CC_VERSION, major_rel, minor_rel,
|
||||||
maint_rel, revision);
|
maint_rel, revision);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
if ((0x02 == major_rel) && (0x06 == minor_rel)) {
|
if ((0x02 == major_rel) && (0x06 == minor_rel)) {
|
||||||
return 0; // version 2.6.x is ok
|
return 0; // version 2.6.x is ok
|
||||||
@ -318,8 +310,7 @@ int32_t EZ_ReceiveCheckVersion(int32_t res, class SBuffer &buf) {
|
|||||||
stack_type
|
stack_type
|
||||||
);
|
);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
if (0x08 == protocol_version) {
|
if (0x08 == protocol_version) {
|
||||||
return 0; // protocol v8 is ok
|
return 0; // protocol v8 is ok
|
||||||
@ -394,8 +385,7 @@ int32_t ZNP_ReceivePermitJoinStatus(int32_t res, const class SBuffer &buf) {
|
|||||||
ResponseAppend_P(message, duration);
|
ResponseAppend_P(message, duration);
|
||||||
ResponseAppend_P(PSTR("\"}}"));
|
ResponseAppend_P(PSTR("\"}}"));
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,8 +425,7 @@ int32_t ZNP_ReceiveNodeDesc(int32_t res, const class SBuffer &buf) {
|
|||||||
complexDescriptorAvailable ? PSTR("true") : PSTR("false")
|
complexDescriptorAvailable ? PSTR("true") : PSTR("false")
|
||||||
);
|
);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -473,8 +462,7 @@ int32_t Z_ReceiveActiveEp(int32_t res, const class SBuffer &buf) {
|
|||||||
ResponseAppend_P(PSTR("\"0x%02X\""), activeEpList[i]);
|
ResponseAppend_P(PSTR("\"0x%02X\""), activeEpList[i]);
|
||||||
}
|
}
|
||||||
ResponseAppend_P(PSTR("]}}"));
|
ResponseAppend_P(PSTR("]}}"));
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
Z_SendAFInfoRequest(nwkAddr); // probe for ModelId and ManufId
|
Z_SendAFInfoRequest(nwkAddr); // probe for ModelId and ManufId
|
||||||
|
|
||||||
@ -515,8 +503,7 @@ int32_t Z_ReceiveIEEEAddr(int32_t res, const class SBuffer &buf) {
|
|||||||
}
|
}
|
||||||
ResponseAppend_P(PSTR("\"}}"));
|
ResponseAppend_P(PSTR("\"}}"));
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -534,8 +521,7 @@ int32_t ZNP_DataConfirm(int32_t res, const class SBuffer &buf) {
|
|||||||
",\"" D_JSON_ZIGBEE_STATUS "\":%d"
|
",\"" D_JSON_ZIGBEE_STATUS "\":%d"
|
||||||
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
||||||
"}}"), endpoint, status, getZigbeeStatusMessage(status).c_str());
|
"}}"), endpoint, status, getZigbeeStatusMessage(status).c_str());
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -591,8 +577,7 @@ int32_t ZNP_ReceiveStateChange(int32_t res, const class SBuffer &buf) {
|
|||||||
ZIGBEE_STATUS_SCANNING, state, msg
|
ZIGBEE_STATUS_SCANNING, state, msg
|
||||||
);
|
);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ZDO_DEV_END_DEVICE == state) || (ZDO_DEV_ROUTER == state) || (ZDO_DEV_ZB_COORD == state)) {
|
if ((ZDO_DEV_END_DEVICE == state) || (ZDO_DEV_ROUTER == state) || (ZDO_DEV_ZB_COORD == state)) {
|
||||||
@ -637,8 +622,7 @@ int32_t Z_ReceiveEndDeviceAnnonce(int32_t res, const class SBuffer &buf) {
|
|||||||
uint32_t wait_ms = 2000; // wait for 2s
|
uint32_t wait_ms = 2000; // wait for 2s
|
||||||
Z_Query_Bulb(nwkAddr, wait_ms);
|
Z_Query_Bulb(nwkAddr, wait_ms);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
Z_SendActiveEpReq(nwkAddr);
|
Z_SendActiveEpReq(nwkAddr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -662,8 +646,7 @@ int32_t ZNP_ReceiveTCDevInd(int32_t res, const class SBuffer &buf) {
|
|||||||
ZIGBEE_STATUS_DEVICE_INDICATION, hex, srcAddr, parentNw
|
ZIGBEE_STATUS_DEVICE_INDICATION, hex, srcAddr, parentNw
|
||||||
);
|
);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,8 +675,7 @@ int32_t Z_BindRsp(int32_t res, const class SBuffer &buf) {
|
|||||||
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
||||||
"}}"), status, msg.c_str());
|
"}}"), status, msg.c_str());
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -723,8 +705,7 @@ int32_t Z_UnbindRsp(int32_t res, const class SBuffer &buf) {
|
|||||||
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
||||||
"}}"), status, msg.c_str());
|
"}}"), status, msg.c_str());
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -799,8 +780,7 @@ int32_t Z_MgmtBindRsp(int32_t res, const class SBuffer &buf) {
|
|||||||
|
|
||||||
ResponseAppend_P(PSTR("]}}"));
|
ResponseAppend_P(PSTR("]}}"));
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_BIND_STATE));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_BIND_STATE));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -880,8 +860,7 @@ int32_t EZ_ReceiveTCJoinHandler(int32_t res, const class SBuffer &buf) {
|
|||||||
status, decision
|
status, decision
|
||||||
);
|
);
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -131,8 +131,7 @@ void ZigbeeInputLoop(void) {
|
|||||||
ToHex_P((unsigned char*)znp_buffer.getBuffer(), znp_buffer.len(), hex_char, sizeof(hex_char));
|
ToHex_P((unsigned char*)znp_buffer.getBuffer(), znp_buffer.len(), hex_char, sizeof(hex_char));
|
||||||
Response_P(PSTR("{\"" D_JSON_ZIGBEEZNPRECEIVED "\":\"%s\"}"), hex_char);
|
Response_P(PSTR("{\"" D_JSON_ZIGBEEZNPRECEIVED "\":\"%s\"}"), hex_char);
|
||||||
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
XdrvRulesProcess();
|
|
||||||
} else {
|
} else {
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data);
|
||||||
}
|
}
|
||||||
@ -194,7 +193,7 @@ void ZigbeeInputLoop(void) {
|
|||||||
if (zigbee_buffer->len() < ZIGBEE_BUFFER_SIZE) {
|
if (zigbee_buffer->len() < ZIGBEE_BUFFER_SIZE) {
|
||||||
if (escape) {
|
if (escape) {
|
||||||
// invert bit 5
|
// invert bit 5
|
||||||
zigbee_in_byte ^= 0x20;
|
zigbee_in_byte ^= 0x20;
|
||||||
escape = false;
|
escape = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +251,7 @@ void ZigbeeInputLoop(void) {
|
|||||||
ToHex_P((unsigned char*)ezsp_buffer.getBuffer(), ezsp_buffer.len(), hex_char, sizeof(hex_char));
|
ToHex_P((unsigned char*)ezsp_buffer.getBuffer(), ezsp_buffer.len(), hex_char, sizeof(hex_char));
|
||||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "2\":\"%s\"}"), hex_char);
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "2\":\"%s\"}"), hex_char);
|
||||||
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
XdrvRulesProcess();
|
|
||||||
} else {
|
} else {
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable
|
||||||
}
|
}
|
||||||
@ -435,7 +433,7 @@ void ZigbeeEZSPSendRaw(const uint8_t *msg, size_t len, bool send_cancel) {
|
|||||||
bool data_frame = (0 == (msg[0] & 0x80));
|
bool data_frame = (0 == (msg[0] & 0x80));
|
||||||
uint8_t rand = 0x42; // pseudo-randomizer initial value
|
uint8_t rand = 0x42; // pseudo-randomizer initial value
|
||||||
uint16_t crc = 0xFFFF; // CRC16 CCITT initialization
|
uint16_t crc = 0xFFFF; // CRC16 CCITT initialization
|
||||||
|
|
||||||
for (uint32_t i=0; i<len; i++) {
|
for (uint32_t i=0; i<len; i++) {
|
||||||
uint8_t out_byte = msg[i];
|
uint8_t out_byte = msg[i];
|
||||||
|
|
||||||
@ -508,7 +506,7 @@ void ZigbeeEZSPSendDATA(const uint8_t *msg, size_t len, bool send_cancel) {
|
|||||||
ZigbeeEZSPSendRaw(buf.getBuffer(), buf.len(), send_cancel);
|
ZigbeeEZSPSendRaw(buf.getBuffer(), buf.len(), send_cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive a high-level EZSP command/response, starting with 16-bits frame ID
|
// Receive a high-level EZSP command/response, starting with 16-bits frame ID
|
||||||
int32_t ZigbeeProcessInputEZSP(class SBuffer &buf) {
|
int32_t ZigbeeProcessInputEZSP(class SBuffer &buf) {
|
||||||
// verify errors in first 2 bytes.
|
// verify errors in first 2 bytes.
|
||||||
// TODO
|
// TODO
|
||||||
@ -534,8 +532,7 @@ int32_t ZigbeeProcessInputEZSP(class SBuffer &buf) {
|
|||||||
ToHex_P((unsigned char*)buf.getBuffer(), buf.len(), hex_char, sizeof(hex_char));
|
ToHex_P((unsigned char*)buf.getBuffer(), buf.len(), hex_char, sizeof(hex_char));
|
||||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "\":\"%s\"}"), hex_char);
|
Response_P(PSTR("{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "\":\"%s\"}"), hex_char);
|
||||||
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR));
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
XdrvRulesProcess();
|
|
||||||
} else {
|
} else {
|
||||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable
|
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "%s"), mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable
|
||||||
}
|
}
|
||||||
@ -562,7 +559,7 @@ int32_t ZigbeeProcessInputRaw(class SBuffer &buf) {
|
|||||||
// NAK
|
// NAK
|
||||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZIG: Received NAK %d, resending not implemented"), ack_num);
|
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZIG: Received NAK %d, resending not implemented"), ack_num);
|
||||||
} else if (control_byte == 0xC1) {
|
} else if (control_byte == 0xC1) {
|
||||||
|
|
||||||
// RSTACK
|
// RSTACK
|
||||||
// received just after boot, either because of Power up, hardware reset or RST
|
// received just after boot, either because of Power up, hardware reset or RST
|
||||||
EZ_RSTACK(buf.get8(2));
|
EZ_RSTACK(buf.get8(2));
|
||||||
@ -576,7 +573,7 @@ int32_t ZigbeeProcessInputRaw(class SBuffer &buf) {
|
|||||||
buf.setLen(3);
|
buf.setLen(3);
|
||||||
ZigbeeProcessInput(buf);
|
ZigbeeProcessInput(buf);
|
||||||
} else if (control_byte == 0xC2) {
|
} else if (control_byte == 0xC2) {
|
||||||
|
|
||||||
// ERROR
|
// ERROR
|
||||||
EZ_ERROR(buf.get8(2));
|
EZ_ERROR(buf.get8(2));
|
||||||
zigbee.active = false; // stop all zigbee activities
|
zigbee.active = false; // stop all zigbee activities
|
||||||
@ -641,7 +638,7 @@ void CmndZbEZSPSendOrReceive(bool send)
|
|||||||
if (2 == XdrvMailbox.index) { ZigbeeEZSPSendDATA(buf.getBuffer(), buf.len(), true); }
|
if (2 == XdrvMailbox.index) { ZigbeeEZSPSendDATA(buf.getBuffer(), buf.len(), true); }
|
||||||
else if (3 == XdrvMailbox.index) { ZigbeeEZSPSendRaw(buf.getBuffer(), buf.len(), true); }
|
else if (3 == XdrvMailbox.index) { ZigbeeEZSPSendRaw(buf.getBuffer(), buf.len(), true); }
|
||||||
else { ZigbeeEZSPSendCmd(buf.getBuffer(), buf.len(), true); }
|
else { ZigbeeEZSPSendCmd(buf.getBuffer(), buf.len(), true); }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Command was `ZbEZSPReceive`
|
// Command was `ZbEZSPReceive`
|
||||||
if (2 == XdrvMailbox.index) { ZigbeeProcessInput(buf); }
|
if (2 == XdrvMailbox.index) { ZigbeeProcessInput(buf); }
|
||||||
|
@ -715,7 +715,7 @@ void ZbBindUnbind(bool unbind) { // false = bind, true = unbind
|
|||||||
|
|
||||||
#ifdef USE_ZIGBEE_EZSP
|
#ifdef USE_ZIGBEE_EZSP
|
||||||
SBuffer buf(24);
|
SBuffer buf(24);
|
||||||
|
|
||||||
// ZDO message payload (see Zigbee spec 2.4.3.2.2)
|
// ZDO message payload (see Zigbee spec 2.4.3.2.2)
|
||||||
buf.add64(srcLongAddr);
|
buf.add64(srcLongAddr);
|
||||||
buf.add8(endpoint);
|
buf.add8(endpoint);
|
||||||
@ -895,8 +895,7 @@ void CmndZbLight(void) {
|
|||||||
String dump = zigbee_devices.dumpLightState(shortaddr);
|
String dump = zigbee_devices.dumpLightState(shortaddr);
|
||||||
Response_P(PSTR("{\"" D_PRFX_ZB D_CMND_ZIGBEE_LIGHT "\":%s}"), dump.c_str());
|
Response_P(PSTR("{\"" D_PRFX_ZB D_CMND_ZIGBEE_LIGHT "\":%s}"), dump.c_str());
|
||||||
|
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_PRFX_ZB D_CMND_ZIGBEE_LIGHT));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_PRFX_ZB D_CMND_ZIGBEE_LIGHT));
|
||||||
XdrvRulesProcess();
|
|
||||||
ResponseCmndDone();
|
ResponseCmndDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1041,7 +1040,7 @@ void CmndZbEZSPListen(void) {
|
|||||||
} else if (group > 0xFFFF) {
|
} else if (group > 0xFFFF) {
|
||||||
group = 0xFFFF;
|
group = 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
SBuffer buf(8);
|
SBuffer buf(8);
|
||||||
buf.add16(EZSP_setMulticastTableEntry);
|
buf.add16(EZSP_setMulticastTableEntry);
|
||||||
buf.add8(index);
|
buf.add8(index);
|
||||||
|
@ -279,8 +279,7 @@ void ShutterReportPosition(bool always, uint32_t index)
|
|||||||
}
|
}
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
if (always || (rules_flag.shutter_moving)) {
|
if (always || (rules_flag.shutter_moving)) {
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_PRFX_SHUTTER));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_PRFX_SHUTTER)); // RulesProcess() now re-entry protected
|
||||||
XdrvRulesProcess(); //RulesProcess() now re-entry protected
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: rules_flag.shutter_moving: %d, moved %d"), rules_flag.shutter_moving, rules_flag.shutter_moved);
|
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: rules_flag.shutter_moving: %d, moved %d"), rules_flag.shutter_moving, rules_flag.shutter_moved);
|
||||||
@ -716,8 +715,7 @@ void ShutterButtonHandler(void)
|
|||||||
Response_P(PSTR("{"));
|
Response_P(PSTR("{"));
|
||||||
ResponseAppend_P(JSON_SHUTTER_BUTTON, shutter_index+1, (buttonState <= SHT_PRESSED_EXT_HOLD) ? (button_index+1) : 0, press_index);
|
ResponseAppend_P(JSON_SHUTTER_BUTTON, shutter_index+1, (buttonState <= SHT_PRESSED_EXT_HOLD) ? (button_index+1) : 0, press_index);
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_PRFX_SHUTTER));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_PRFX_SHUTTER));
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,8 +539,7 @@ void TasmotaClient_ProcessIn(void) {
|
|||||||
Response_P(PSTR("{\"TasmotaClient\":"));
|
Response_P(PSTR("{\"TasmotaClient\":"));
|
||||||
ResponseAppend_P("%s", inbuf);
|
ResponseAppend_P("%s", inbuf);
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, mqtt_data);
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, mqtt_data);
|
||||||
XdrvRulesProcess();
|
|
||||||
}
|
}
|
||||||
if (CMND_EXECUTE_CMND == TClientCommand.command) { // We need to execute the incoming command
|
if (CMND_EXECUTE_CMND == TClientCommand.command) { // We need to execute the incoming command
|
||||||
ExecuteCommand(inbuf, SRC_IGNORE);
|
ExecuteCommand(inbuf, SRC_IGNORE);
|
||||||
|
@ -35,7 +35,7 @@ void (* const PingCommand[])(void) PROGMEM = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
extern uint32 system_relative_time(uint32 time);
|
extern uint32 system_relative_time(uint32 time);
|
||||||
extern void ets_bzero(void *s, size_t n);
|
extern void ets_bzero(void *s, size_t n);
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ extern "C" {
|
|||||||
if ((p->len == p->tot_len) && (p->next == nullptr)) {
|
if ((p->len == p->tot_len) && (p->next == nullptr)) {
|
||||||
ip_addr_t ping_target;
|
ip_addr_t ping_target;
|
||||||
struct icmp_echo_hdr *iecho;
|
struct icmp_echo_hdr *iecho;
|
||||||
|
|
||||||
ping_target.addr = ping->ip;
|
ping_target.addr = ping->ip;
|
||||||
iecho = (struct icmp_echo_hdr *) p->payload;
|
iecho = (struct icmp_echo_hdr *) p->payload;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ extern "C" {
|
|||||||
iecho = (struct icmp_echo_hdr *)p->payload;
|
iecho = (struct icmp_echo_hdr *)p->payload;
|
||||||
|
|
||||||
if ((iecho->id == Ping_ID) && (iecho->seqno == htons(ping->seq_num)) && iecho->type == ICMP_ER) {
|
if ((iecho->id == Ping_ID) && (iecho->seqno == htons(ping->seq_num)) && iecho->type == ICMP_ER) {
|
||||||
|
|
||||||
if (iecho->seqno != ping->seqno){ // debounce already received packet
|
if (iecho->seqno != ping->seqno){ // debounce already received packet
|
||||||
/* do some ping result processing */
|
/* do some ping result processing */
|
||||||
sys_untimeout(t_ping_timeout, ping); // remove time-out handler
|
sys_untimeout(t_ping_timeout, ping); // remove time-out handler
|
||||||
@ -282,9 +282,8 @@ void PingResponsePoll(void) {
|
|||||||
success ? ping->min_time : 0, ping->max_time,
|
success ? ping->min_time : 0, ping->max_time,
|
||||||
success ? ping->sum_time / success : 0
|
success ? ping->sum_time / success : 0
|
||||||
);
|
);
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_PING));
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_PING));
|
||||||
XdrvRulesProcess();
|
|
||||||
|
|
||||||
// remove from linked list
|
// remove from linked list
|
||||||
*prev_link = ping->next;
|
*prev_link = ping->next;
|
||||||
// don't increment prev_link
|
// don't increment prev_link
|
||||||
|
Loading…
x
Reference in New Issue
Block a user