Merge branch 'arendst:development' into partitions

This commit is contained in:
Jason2866 2021-06-02 17:58:33 +02:00
commit bb734c19ef
5 changed files with 26 additions and 7 deletions

View File

@ -419,7 +419,7 @@ void CmndStatusResponse(uint32_t index) {
all_status.replace("}{", ","); all_status.replace("}{", ",");
char cmnd_status[10]; // STATUS11 char cmnd_status[10]; // STATUS11
snprintf_P(cmnd_status, sizeof(cmnd_status), PSTR(D_CMND_STATUS "0")); snprintf_P(cmnd_status, sizeof(cmnd_status), PSTR(D_CMND_STATUS "0"));
MqttPublishPayloadPrefixTopic_P(STAT, cmnd_status, all_status.c_str()); MqttPublishPayloadPrefixTopicRulesProcess_P(STAT, cmnd_status, all_status.c_str());
all_status = (const char*) nullptr; all_status = (const char*) nullptr;
} }
if (0 == index) { if (0 == index) {

View File

@ -719,6 +719,19 @@ void MqttPublishPayloadPrefixTopic_P(uint32_t prefix, const char* subtopic, cons
MqttPublishPayloadPrefixTopic_P(prefix, subtopic, payload, 0, false); MqttPublishPayloadPrefixTopic_P(prefix, subtopic, payload, 0, false);
} }
void MqttPublishPayloadPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic, const char* payload, bool retained) {
// Publish <prefix>/<device>/<RESULT or <subtopic>> payload string with optional retained
// then process rules
MqttPublishPayloadPrefixTopic_P(prefix, subtopic, payload, 0, retained);
XdrvRulesProcess(0, payload);
}
void MqttPublishPayloadPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic, const char* payload) {
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string no retained
// then process rules
MqttPublishPayloadPrefixTopicRulesProcess_P(prefix, subtopic, payload, false);
}
void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retained) { void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retained) {
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string with optional retained // Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string with optional retained
MqttPublishPayloadPrefixTopic_P(prefix, subtopic, TasmotaGlobal.mqtt_data, 0, retained); MqttPublishPayloadPrefixTopic_P(prefix, subtopic, TasmotaGlobal.mqtt_data, 0, retained);

View File

@ -835,9 +835,8 @@ bool RulesProcessEvent(char *json_event)
return serviced; return serviced;
} }
bool RulesProcess(void) bool RulesProcess(void) {
{ return RulesProcessEvent(XdrvMailbox.data);
return RulesProcessEvent(TasmotaGlobal.mqtt_data);
} }
void RulesInit(void) void RulesInit(void)

View File

@ -93,9 +93,9 @@ extern "C" {
bool callBerryRule(void) { bool callBerryRule(void) {
if (berry.rules_busy) { return false; } if (berry.rules_busy) { return false; }
berry.rules_busy = true; berry.rules_busy = true;
char * json_event = TasmotaGlobal.mqtt_data; char * json_event = XdrvMailbox.data;
bool serviced = false; bool serviced = false;
serviced = callBerryEventDispatcher(PSTR("rule"), nullptr, 0, TasmotaGlobal.mqtt_data); serviced = callBerryEventDispatcher(PSTR("rule"), nullptr, 0, XdrvMailbox.data);
berry.rules_busy = false; berry.rules_busy = false;
return serviced; // TODO event not handled return serviced; // TODO event not handled
} }

View File

@ -1079,16 +1079,23 @@ void XsnsDriverState(void)
/*********************************************************************************************/ /*********************************************************************************************/
bool XdrvRulesProcess(bool teleperiod) { bool XdrvRulesProcess(bool teleperiod, const char* payload) {
char* data_save = XdrvMailbox.data;
XdrvMailbox.data = (char*)payload;
bool rule_handled = XdrvCallDriver(10, (teleperiod) ? FUNC_TELEPERIOD_RULES_PROCESS : FUNC_RULES_PROCESS); bool rule_handled = XdrvCallDriver(10, (teleperiod) ? FUNC_TELEPERIOD_RULES_PROCESS : FUNC_RULES_PROCESS);
#ifdef USE_BERRY #ifdef USE_BERRY
// events are passed to both Rules engine AND Berry engine // events are passed to both Rules engine AND Berry engine
bool berry_handled = XdrvCallDriver(52, FUNC_RULES_PROCESS); bool berry_handled = XdrvCallDriver(52, FUNC_RULES_PROCESS);
rule_handled |= berry_handled; rule_handled |= berry_handled;
#endif #endif
XdrvMailbox.data = data_save;
return rule_handled; return rule_handled;
} }
bool XdrvRulesProcess(bool teleperiod) {
return XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data);
}
#ifdef USE_DEBUG_DRIVER #ifdef USE_DEBUG_DRIVER
void ShowFreeMem(const char *where) void ShowFreeMem(const char *where)
{ {