From 9affa6b1c4c22a77dd756217799012d3f7bdcb94 Mon Sep 17 00:00:00 2001 From: TD-er Date: Wed, 19 Dec 2018 15:06:48 +0100 Subject: [PATCH] [TimingStats] Add timing stats for controllers As requested here: https://github.com/esp8266/Arduino/issues/5513#issuecomment-448558292 --- src/Controller.ino | 4 +-- src/ESPEasy-Globals.h | 69 +++++++++++++++++++++++++++++++-------- src/ESPEasy.ino | 6 ++-- src/ESPEasyRules.ino | 2 ++ src/ESPEasyStatistics.ino | 8 ++--- src/ESPEasyStorage.ino | 2 ++ src/Scheduler.ino | 2 +- src/WebServer.ino | 38 ++++++++++++++++----- src/_C001.ino | 4 +-- src/_C002.ino | 4 +-- src/_C003.ino | 6 ++-- src/_C004.ino | 4 +-- src/_C005.ino | 4 +-- src/_C006.ino | 4 +-- src/_C007.ino | 4 +-- src/_C008.ino | 4 +-- src/_C009.ino | 4 +-- src/_C010.ino | 4 +-- src/_C011.ino | 4 +-- src/_C012.ino | 6 ++-- src/_C013.ino | 4 +-- src/__CPlugin.ino | 13 ++++++-- 22 files changed, 138 insertions(+), 62 deletions(-) diff --git a/src/Controller.ino b/src/Controller.ino index c6d8789a4d..46509d9ee2 100644 --- a/src/Controller.ino +++ b/src/Controller.ino @@ -47,12 +47,12 @@ void sendData(struct EventStruct *event) { event->ProtocolIndex = getProtocolIndex(Settings.Protocol[event->ControllerIndex]); if (validUserVar(event)) { - CPlugin_ptr[event->ProtocolIndex](CPLUGIN_PROTOCOL_SEND, event, dummyString); + CPluginCall(event->ProtocolIndex, CPLUGIN_PROTOCOL_SEND, event, dummyString); } else { if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { String log = F("Invalid value detected for controller "); String controllerName; - CPlugin_ptr[event->ProtocolIndex](CPLUGIN_GET_DEVICENAME, event, controllerName); + CPluginCall(event->ProtocolIndex, CPLUGIN_GET_DEVICENAME, event, controllerName); log += controllerName; addLog(LOG_LEVEL_DEBUG, log); } diff --git a/src/ESPEasy-Globals.h b/src/ESPEasy-Globals.h index e590cf1300..40fde2bac8 100644 --- a/src/ESPEasy-Globals.h +++ b/src/ESPEasy-Globals.h @@ -266,17 +266,18 @@ #define PLUGIN_REQUEST 26 #define PLUGIN_TIME_CHANGE 27 -#define CPLUGIN_PROTOCOL_ADD 1 -#define CPLUGIN_PROTOCOL_TEMPLATE 2 -#define CPLUGIN_PROTOCOL_SEND 3 -#define CPLUGIN_PROTOCOL_RECV 4 -#define CPLUGIN_GET_DEVICENAME 5 -#define CPLUGIN_WEBFORM_SAVE 6 -#define CPLUGIN_WEBFORM_LOAD 7 -#define CPLUGIN_GET_PROTOCOL_DISPLAY_NAME 8 -#define CPLUGIN_TASK_CHANGE_NOTIFICATION 9 -#define CPLUGIN_INIT 10 -#define CPLUGIN_UDP_IN 11 +// Make sure the CPLUGIN_* does not overlap PLUGIN_* +#define CPLUGIN_PROTOCOL_ADD 41 +#define CPLUGIN_PROTOCOL_TEMPLATE 42 +#define CPLUGIN_PROTOCOL_SEND 43 +#define CPLUGIN_PROTOCOL_RECV 44 +#define CPLUGIN_GET_DEVICENAME 45 +#define CPLUGIN_WEBFORM_SAVE 46 +#define CPLUGIN_WEBFORM_LOAD 47 +#define CPLUGIN_GET_PROTOCOL_DISPLAY_NAME 48 +#define CPLUGIN_TASK_CHANGE_NOTIFICATION 49 +#define CPLUGIN_INIT 50 +#define CPLUGIN_UDP_IN 51 #define CONTROLLER_HOSTNAME 1 #define CONTROLLER_IP 2 @@ -1624,7 +1625,7 @@ boolean (*Plugin_ptr[PLUGIN_MAX])(byte, struct EventStruct*, String&); std::vector Plugin_id; std::vector Task_id_to_Plugin_id; -boolean (*CPlugin_ptr[CPLUGIN_MAX])(byte, struct EventStruct*, String&); +bool (*CPlugin_ptr[CPLUGIN_MAX])(byte, struct EventStruct*, String&); byte CPlugin_id[CPLUGIN_MAX]; boolean (*NPlugin_ptr[NPLUGIN_MAX])(byte, struct EventStruct*, String&); @@ -1900,7 +1901,42 @@ bool mustLogFunction(int function) { return false; } +String getCPluginCFunctionName(int function) { + switch(function) { + case CPLUGIN_PROTOCOL_ADD: return F("CPLUGIN_PROTOCOL_ADD"); + case CPLUGIN_PROTOCOL_TEMPLATE: return F("CPLUGIN_PROTOCOL_TEMPLATE"); + case CPLUGIN_PROTOCOL_SEND: return F("CPLUGIN_PROTOCOL_SEND"); + case CPLUGIN_PROTOCOL_RECV: return F("CPLUGIN_PROTOCOL_RECV"); + case CPLUGIN_GET_DEVICENAME: return F("CPLUGIN_GET_DEVICENAME"); + case CPLUGIN_WEBFORM_SAVE: return F("CPLUGIN_WEBFORM_SAVE"); + case CPLUGIN_WEBFORM_LOAD: return F("CPLUGIN_WEBFORM_LOAD"); + case CPLUGIN_GET_PROTOCOL_DISPLAY_NAME: return F("CPLUGIN_GET_PROTOCOL_DISPLAY_NAME"); + case CPLUGIN_TASK_CHANGE_NOTIFICATION: return F("CPLUGIN_TASK_CHANGE_NOTIFICATION"); + case CPLUGIN_INIT: return F("CPLUGIN_INIT"); + case CPLUGIN_UDP_IN: return F("CPLUGIN_UDP_IN"); + } + return F("Unknown"); +} + +bool mustLogCFunction(int function) { + switch(function) { + case CPLUGIN_PROTOCOL_ADD: return false; + case CPLUGIN_PROTOCOL_TEMPLATE: return false; + case CPLUGIN_PROTOCOL_SEND: return true; + case CPLUGIN_PROTOCOL_RECV: return true; + case CPLUGIN_GET_DEVICENAME: return false; + case CPLUGIN_WEBFORM_SAVE: return false; + case CPLUGIN_WEBFORM_LOAD: return false; + case CPLUGIN_GET_PROTOCOL_DISPLAY_NAME: return false; + case CPLUGIN_TASK_CHANGE_NOTIFICATION: return false; + case CPLUGIN_INIT: return false; + case CPLUGIN_UDP_IN: return true; + } + return false; +} + std::map pluginStats; +std::map controllerStats; std::map miscStats; unsigned long timediff_calls = 0; unsigned long timediff_cpu_cycles_total = 0; @@ -1939,12 +1975,16 @@ unsigned long timingstats_last_reset = 0; #define CONNECT_CLIENT_STATS 30 #define LOAD_CUSTOM_TASK_STATS 31 #define WIFI_ISCONNECTED_STATS 32 +#define LOAD_TASK_SETTINGS 33 +#define RULES_PROCESSING 34 +#define BACKGROUND_TASKS 35 #define START_TIMER const unsigned statisticsTimerStart(micros()); -#define STOP_TIMER_TASK(T,F) if (mustLogFunction(F)) pluginStats[T*32 + F].add(usecPassedSince(statisticsTimerStart)); +#define STOP_TIMER_TASK(T,F) if (mustLogFunction(F)) pluginStats[T*256 + F].add(usecPassedSince(statisticsTimerStart)); +#define STOP_TIMER_CONTROLLER(T,F) if (mustLogCFunction(F)) controllerStats[T*256 + F].add(usecPassedSince(statisticsTimerStart)); //#define STOP_TIMER_LOADFILE miscStats[LOADFILE_STATS].add(usecPassedSince(statisticsTimerStart)); #define STOP_TIMER(L) miscStats[L].add(usecPassedSince(statisticsTimerStart)); @@ -1971,6 +2011,9 @@ String getMiscStatsName(int stat) { case CONNECT_CLIENT_STATS: return F("connectClient()"); case LOAD_CUSTOM_TASK_STATS: return F("LoadCustomTaskSettings()"); case WIFI_ISCONNECTED_STATS: return F("WiFi.isConnected()"); + case LOAD_TASK_SETTINGS: return F("LoadTaskSettings()"); + case RULES_PROCESSING: return F("rulesProcessing()"); + case BACKGROUND_TASKS: return F("backgroundtasks()"); case C001_DELAY_QUEUE: case C002_DELAY_QUEUE: case C003_DELAY_QUEUE: diff --git a/src/ESPEasy.ino b/src/ESPEasy.ino index 263442ba69..20b842c92e 100644 --- a/src/ESPEasy.ino +++ b/src/ESPEasy.ino @@ -406,7 +406,7 @@ int firstEnabledMQTTController() { bool getControllerProtocolDisplayName(byte ProtocolIndex, byte parameterIdx, String& protoDisplayName) { EventStruct tmpEvent; tmpEvent.idx=parameterIdx; - return CPlugin_ptr[ProtocolIndex](CPLUGIN_GET_PROTOCOL_DISPLAY_NAME, &tmpEvent, protoDisplayName); + return CPluginCall(ProtocolIndex, CPLUGIN_GET_PROTOCOL_DISPLAY_NAME, &tmpEvent, protoDisplayName); } void updateLoopStats() { @@ -836,7 +836,7 @@ void SensorSendTask(byte TaskIndex) { byte varIndex = TaskIndex * VARS_PER_TASK; - boolean success = false; + bool success = false; byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[TaskIndex]); LoadTaskSettings(TaskIndex); @@ -903,6 +903,7 @@ void backgroundtasks() { return; } + START_TIMER runningBackgroundTasks=true; #if defined(ESP8266) @@ -940,4 +941,5 @@ void backgroundtasks() statusLED(false); runningBackgroundTasks=false; + STOP_TIMER(BACKGROUND_TASKS); } diff --git a/src/ESPEasyRules.ino b/src/ESPEasyRules.ino index de10c1ec00..85d9cd2981 100644 --- a/src/ESPEasyRules.ino +++ b/src/ESPEasyRules.ino @@ -59,6 +59,7 @@ void checkRuleSets() { void rulesProcessing(String &event) { if (!Settings.UseRules) return; + START_TIMER checkRAM(F("rulesProcessing")); unsigned long timer = millis(); if (loglevelActiveFor(LOG_LEVEL_INFO)) { @@ -99,6 +100,7 @@ void rulesProcessing(String &event) { log += F(" milliSeconds"); addLog(LOG_LEVEL_DEBUG, log); } + STOP_TIMER(RULES_PROCESSING); backgroundtasks(); } diff --git a/src/ESPEasyStatistics.ino b/src/ESPEasyStatistics.ino index ef8b6ecbaa..0d38187fc8 100644 --- a/src/ESPEasyStatistics.ino +++ b/src/ESPEasyStatistics.ino @@ -5,7 +5,7 @@ void logStatistics(byte loglevel, bool clearStats) { log.reserve(80); for (auto& x: pluginStats) { if (!x.second.isEmpty()) { - const int pluginId = x.first/32; + const int pluginId = x.first/256; String P_name = ""; Plugin_ptr[pluginId](PLUGIN_GET_DEVICENAME, NULL, P_name); log = F("PluginStats P_"); @@ -13,7 +13,7 @@ void logStatistics(byte loglevel, bool clearStats) { log += '_'; log += P_name; log += ' '; - log += getPluginFunctionName(x.first%32); + log += getPluginFunctionName(x.first%256); log += ' '; log += getLogLine(x.second); addLog(loglevel, log); @@ -49,7 +49,7 @@ void jsonStatistics(bool clearStats) { stream_json_start_array(F("plugin")); for (auto& x: pluginStats) { if (!x.second.isEmpty()) { - const int pluginId = x.first/32; + const int pluginId = x.first/256; if (currentPluginId != pluginId) { // new plugin currentPluginId = pluginId; @@ -74,7 +74,7 @@ void jsonStatistics(bool clearStats) { unsigned long minVal, maxVal; unsigned int c = x.second.getMinMax(minVal, maxVal); - stream_plugin_function_timing_stats_json(getPluginFunctionName(x.first%32), + stream_plugin_function_timing_stats_json(getPluginFunctionName(x.first%256), c, minVal, maxVal, x.second.getAvg()); if (clearStats) x.second.reset(); firstFunction = false; diff --git a/src/ESPEasyStorage.ino b/src/ESPEasyStorage.ino index 8bf0f848a4..e684fe89ff 100644 --- a/src/ESPEasyStorage.ino +++ b/src/ESPEasyStorage.ino @@ -419,6 +419,7 @@ String LoadTaskSettings(byte TaskIndex) checkRAM(F("LoadTaskSettings")); if (ExtraTaskSettings.TaskIndex == TaskIndex) return(String()); //already loaded + START_TIMER ExtraTaskSettings.clear(); String result = ""; result = LoadFromFile(TaskSettings_Type, TaskIndex, (char*)FILE_CONFIG, (byte*)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct)); @@ -433,6 +434,7 @@ String LoadTaskSettings(byte TaskIndex) //the plugin call should populate ExtraTaskSettings with its default values. PluginCall(PLUGIN_GET_DEVICEVALUENAMES, &TempEvent, dummyString); } + STOP_TIMER(LOAD_TASK_SETTINGS); return result; } diff --git a/src/Scheduler.ino b/src/Scheduler.ino index 13e2e21091..89bcde1c32 100644 --- a/src/Scheduler.ino +++ b/src/Scheduler.ino @@ -452,7 +452,7 @@ void process_system_event_queue() { Plugin_ptr[Index](Function, &EventQueue.front().event, tmpString); break; case ControllerPluginEnum: - CPlugin_ptr[Index](Function, &EventQueue.front().event, tmpString); + CPluginCall(Index, Function, &EventQueue.front().event, tmpString); break; case NotificationPluginEnum: NPlugin_ptr[Index](Function, &EventQueue.front().event, tmpString); diff --git a/src/WebServer.ino b/src/WebServer.ino index 14ec7df9c5..ab918b7b15 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -1265,7 +1265,7 @@ void handle_controllers() { ControllerSettings.ClientTimeout = CONTROLLER_CLIENTTIMEOUT_DFLT; // ControllerSettings.MaxQueueDepth = 0; if (Protocol[ProtocolIndex].usesTemplate) - CPlugin_ptr[ProtocolIndex](CPLUGIN_PROTOCOL_TEMPLATE, &TempEvent, dummyString); + CPluginCall(ProtocolIndex, CPLUGIN_PROTOCOL_TEMPLATE, &TempEvent, dummyString); safe_strncpy(ControllerSettings.Subscribe, TempEvent.String1.c_str(), sizeof(ControllerSettings.Subscribe)); safe_strncpy(ControllerSettings.Publish, TempEvent.String2.c_str(), sizeof(ControllerSettings.Publish)); safe_strncpy(ControllerSettings.MQTTLwtTopic, TempEvent.String3.c_str(), sizeof(ControllerSettings.MQTTLwtTopic)); @@ -1297,7 +1297,7 @@ void handle_controllers() { byte ProtocolIndex = getProtocolIndex(Settings.Protocol[controllerindex]); TempEvent.ControllerIndex = controllerindex; TempEvent.ProtocolIndex = ProtocolIndex; - CPlugin_ptr[ProtocolIndex](CPLUGIN_WEBFORM_SAVE, &TempEvent, dummyString); + CPluginCall(ProtocolIndex, CPLUGIN_WEBFORM_SAVE, &TempEvent, dummyString); ControllerSettings.UseDNS = usedns.toInt(); if (ControllerSettings.UseDNS) { @@ -1331,7 +1331,7 @@ void handle_controllers() { ControllerSettings.ClientTimeout = clienttimeout; - CPlugin_ptr[ProtocolIndex](CPLUGIN_INIT, &TempEvent, dummyString); + CPluginCall(ProtocolIndex, CPLUGIN_INIT, &TempEvent, dummyString); } } addHtmlError(SaveControllerSettings(controllerindex, ControllerSettings)); @@ -1370,7 +1370,7 @@ void handle_controllers() { html_TD(); byte ProtocolIndex = getProtocolIndex(Settings.Protocol[x]); String ProtocolName = ""; - CPlugin_ptr[ProtocolIndex](CPLUGIN_GET_DEVICENAME, 0, ProtocolName); + CPluginCall(ProtocolIndex, CPLUGIN_GET_DEVICENAME, 0, ProtocolName); TXBuffer += ProtocolName; html_TD(); @@ -1396,7 +1396,7 @@ void handle_controllers() { for (byte x = 0; x <= protocolCount; x++) { String ProtocolName = ""; - CPlugin_ptr[x](CPLUGIN_GET_DEVICENAME, 0, ProtocolName); + CPluginCall(x, CPLUGIN_GET_DEVICENAME, 0, ProtocolName); boolean disabled = false;// !((controllerindex == 0) || !Protocol[x].usesMQTT); addSelector_Item(ProtocolName, Protocol[x].Number, @@ -1521,7 +1521,7 @@ void handle_controllers() { TempEvent.ControllerIndex = controllerindex; TempEvent.ProtocolIndex = ProtocolIndex; - CPlugin_ptr[ProtocolIndex](CPLUGIN_WEBFORM_LOAD, &TempEvent,TXBuffer.buf); + CPluginCall(ProtocolIndex, CPLUGIN_WEBFORM_LOAD, &TempEvent,TXBuffer.buf); } @@ -2072,7 +2072,7 @@ void handle_devices() { Settings.ControllerEnabled[TempEvent.ControllerIndex] && Settings.Protocol[TempEvent.ControllerIndex]) { TempEvent.ProtocolIndex = getProtocolIndex(Settings.Protocol[TempEvent.ControllerIndex]); - CPlugin_ptr[TempEvent.ProtocolIndex](CPLUGIN_TASK_CHANGE_NOTIFICATION, &TempEvent, dummyString); + CPluginCall(TempEvent.ProtocolIndex, CPLUGIN_TASK_CHANGE_NOTIFICATION, &TempEvent, dummyString); } } } @@ -4414,7 +4414,7 @@ long stream_timing_statistics(bool clearStats) { long timeSinceLastReset = timePassedSince(timingstats_last_reset); for (auto& x: pluginStats) { if (!x.second.isEmpty()) { - const int pluginId = x.first/32; + const int pluginId = x.first/256; String P_name = ""; Plugin_ptr[pluginId](PLUGIN_GET_DEVICENAME, NULL, P_name); if (x.second.thresholdExceeded(TIMING_STATS_THRESHOLD)) { @@ -4427,7 +4427,27 @@ long stream_timing_statistics(bool clearStats) { TXBuffer += '_'; TXBuffer += P_name; html_TD(); - TXBuffer += getPluginFunctionName(x.first%32); + TXBuffer += getPluginFunctionName(x.first%256); + stream_html_timing_stats(x.second, timeSinceLastReset); + if (clearStats) x.second.reset(); + } + } + for (auto& x: controllerStats) { + if (!x.second.isEmpty()) { + const int pluginId = x.first/256; + String C_name = ""; + CPluginCall(pluginId, CPLUGIN_GET_DEVICENAME, NULL, C_name); + if (x.second.thresholdExceeded(TIMING_STATS_THRESHOLD)) { + html_TR_TD_highlight(); + } else { + html_TR_TD(); + } + TXBuffer += F("C_"); + TXBuffer += pluginId + 1; + TXBuffer += '_'; + TXBuffer += C_name; + html_TD(); + TXBuffer += getCPluginCFunctionName(x.first%256); stream_html_timing_stats(x.second, timeSinceLastReset); if (clearStats) x.second.reset(); } diff --git a/src/_C001.ino b/src/_C001.ino index b336065f5f..e0b0df5b25 100644 --- a/src/_C001.ino +++ b/src/_C001.ino @@ -8,9 +8,9 @@ #define CPLUGIN_NAME_001 "Domoticz HTTP" -boolean CPlugin_001(byte function, struct EventStruct *event, String& string) +bool CPlugin_001(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C002.ino b/src/_C002.ino index 0a9f4ebee3..832b889d9c 100644 --- a/src/_C002.ino +++ b/src/_C002.ino @@ -9,9 +9,9 @@ #include -boolean CPlugin_002(byte function, struct EventStruct *event, String& string) +bool CPlugin_002(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C003.ino b/src/_C003.ino index f6c5c6385d..940414e183 100644 --- a/src/_C003.ino +++ b/src/_C003.ino @@ -7,9 +7,9 @@ #define CPLUGIN_ID_003 3 #define CPLUGIN_NAME_003 "Nodo Telnet" -boolean CPlugin_003(byte function, struct EventStruct *event, String& string) +bool CPlugin_003(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { @@ -57,7 +57,7 @@ boolean CPlugin_003(byte function, struct EventStruct *event, String& string) } bool do_process_c003_delay_queue(int controller_number, const C003_queue_element& element, ControllerSettingsStruct& ControllerSettings) { - boolean success = false; + bool success = false; char log[80]; addLog(LOG_LEVEL_DEBUG, String(F("TELNT : connecting to ")) + ControllerSettings.getHostPortString()); // Use WiFiClient class to create TCP connections diff --git a/src/_C004.ino b/src/_C004.ino index 5837729677..dbebd084f1 100644 --- a/src/_C004.ino +++ b/src/_C004.ino @@ -7,9 +7,9 @@ #define CPLUGIN_ID_004 4 #define CPLUGIN_NAME_004 "ThingSpeak" -boolean CPlugin_004(byte function, struct EventStruct *event, String& string) +bool CPlugin_004(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C005.ino b/src/_C005.ino index 8179b2b5be..dcaf81aa22 100644 --- a/src/_C005.ino +++ b/src/_C005.ino @@ -7,9 +7,9 @@ #define CPLUGIN_ID_005 5 #define CPLUGIN_NAME_005 "OpenHAB MQTT" -boolean CPlugin_005(byte function, struct EventStruct *event, String& string) +bool CPlugin_005(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C006.ino b/src/_C006.ino index c0b54d609b..97fba195f7 100644 --- a/src/_C006.ino +++ b/src/_C006.ino @@ -7,9 +7,9 @@ #define CPLUGIN_ID_006 6 #define CPLUGIN_NAME_006 "PiDome MQTT" -boolean CPlugin_006(byte function, struct EventStruct *event, String& string) +bool CPlugin_006(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C007.ino b/src/_C007.ino index efc640086b..6a17418ecc 100644 --- a/src/_C007.ino +++ b/src/_C007.ino @@ -7,9 +7,9 @@ #define CPLUGIN_ID_007 7 #define CPLUGIN_NAME_007 "Emoncms" -boolean CPlugin_007(byte function, struct EventStruct *event, String& string) +bool CPlugin_007(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C008.ino b/src/_C008.ino index 7e7baead95..66cce0c8a3 100644 --- a/src/_C008.ino +++ b/src/_C008.ino @@ -8,9 +8,9 @@ #define CPLUGIN_NAME_008 "Generic HTTP" #include -boolean CPlugin_008(byte function, struct EventStruct *event, String& string) +bool CPlugin_008(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C009.ino b/src/_C009.ino index 869828e1ef..30db2fd3ca 100644 --- a/src/_C009.ino +++ b/src/_C009.ino @@ -31,9 +31,9 @@ #define CPLUGIN_NAME_009 "FHEM HTTP" #include -boolean CPlugin_009(byte function, struct EventStruct *event, String& string) +bool CPlugin_009(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C010.ino b/src/_C010.ino index 2a0fde9eb3..c91ad483e2 100644 --- a/src/_C010.ino +++ b/src/_C010.ino @@ -7,9 +7,9 @@ #define CPLUGIN_ID_010 10 #define CPLUGIN_NAME_010 "Generic UDP" -boolean CPlugin_010(byte function, struct EventStruct *event, String& string) +bool CPlugin_010(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C011.ino b/src/_C011.ino index 645b4be26f..a867262418 100644 --- a/src/_C011.ino +++ b/src/_C011.ino @@ -29,9 +29,9 @@ struct C011_ConfigStruct char HttpBody[C011_HTTP_BODY_MAX_LEN] = {0}; }; -boolean CPlugin_011(byte function, struct EventStruct *event, String& string) +bool CPlugin_011(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/_C012.ino b/src/_C012.ino index 9212e42182..0990d68733 100644 --- a/src/_C012.ino +++ b/src/_C012.ino @@ -9,9 +9,9 @@ #define CPLUGIN_ID_012 12 #define CPLUGIN_NAME_012 "Blynk HTTP [TESTING]" -boolean CPlugin_012(byte function, struct EventStruct *event, String& string) +bool CPlugin_012(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { @@ -103,7 +103,7 @@ boolean Blynk_get(const String& command, byte controllerIndex, float *data ) ControllerSettings.getHost().c_str()); addLog(LOG_LEVEL_DEBUG, request); client.print(request); - boolean success = !ControllerSettings.MustCheckReply; + bool success = !ControllerSettings.MustCheckReply; if (ControllerSettings.MustCheckReply || data) { unsigned long timer = millis() + 200; while (!client_available(client) && !timeOutReached(timer)) diff --git a/src/_C013.ino b/src/_C013.ino index 664d3f4465..b3290e1cde 100644 --- a/src/_C013.ino +++ b/src/_C013.ino @@ -34,9 +34,9 @@ struct C013_SensorDataStruct }; -boolean CPlugin_013(byte function, struct EventStruct *event, String& string) +bool CPlugin_013(byte function, struct EventStruct *event, String& string) { - boolean success = false; + bool success = false; switch (function) { diff --git a/src/__CPlugin.ino b/src/__CPlugin.ino index cf5477c647..a7e9ba8ad8 100644 --- a/src/__CPlugin.ino +++ b/src/__CPlugin.ino @@ -136,7 +136,14 @@ void CPluginInit(void) CPluginCall(CPLUGIN_INIT, 0); } -byte CPluginCall(byte Function, struct EventStruct *event) +bool CPluginCall(byte pluginNumber, byte Function, struct EventStruct *event, String& str) { + START_TIMER; + bool ret = CPlugin_ptr[pluginNumber](Function, event, str); + STOP_TIMER_CONTROLLER(pluginNumber, Function); + return ret; +} + +bool CPluginCall(byte Function, struct EventStruct *event) { int x; struct EventStruct TempEvent; @@ -158,7 +165,7 @@ byte CPluginCall(byte Function, struct EventStruct *event) Protocol.resize(newSize); } checkRAM(F("CPluginCallADD"),x); - CPlugin_ptr[x](Function, event, dummyString); + CPluginCall(x, Function, event, dummyString); } } return true; @@ -170,7 +177,7 @@ byte CPluginCall(byte Function, struct EventStruct *event) for (byte x=0; x < CONTROLLER_MAX; x++) if (Settings.Protocol[x] != 0 && Settings.ControllerEnabled[x]) { event->ProtocolIndex = getProtocolIndex(Settings.Protocol[x]); - CPlugin_ptr[event->ProtocolIndex](Function, event, dummyString); + CPluginCall(event->ProtocolIndex, Function, event, dummyString); } return true; break;