From cae714e300014a70bab8cc91cc0116eb7f1c2173 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 19 Aug 2019 11:18:50 +0200 Subject: [PATCH] Optimize rule/script processing Optimize rule/script processing --- sonoff/xdrv_interface.ino | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sonoff/xdrv_interface.ino b/sonoff/xdrv_interface.ino index 4028335c9..be9936c4d 100644 --- a/sonoff/xdrv_interface.ino +++ b/sonoff/xdrv_interface.ino @@ -859,7 +859,7 @@ bool XdrvMqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uint16_t sd bool XdrvRulesProcess(void) { - return XdrvCall(FUNC_RULES_PROCESS); + return XdrvCallDriver(10, FUNC_RULES_PROCESS); } #ifdef USE_DEBUG_DRIVER @@ -872,6 +872,25 @@ void ShowFreeMem(const char *where) } #endif +/*********************************************************************************************\ + * Function call to single xdrv +\*********************************************************************************************/ + +bool XdrvCallDriver(uint32_t driver, uint8_t Function) +{ + for (uint32_t x = 0; x < xdrv_present; x++) { +#ifdef XFUNC_PTR_IN_ROM + uint32_t listed = pgm_read_byte(kXdrvList + x); +#else + uint32_t listed = kXdrvList[x]; +#endif + if (driver == listed) { + return xdrv_func_ptr[x](Function); + } + } + return false; +} + /*********************************************************************************************\ * Function call to all xdrv \*********************************************************************************************/