diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 07dd911..f16c4b6 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -153,7 +153,7 @@ void Span::begin(Category catID, const char *displayName, const char *hostNameBa /////////////////////////////// -void Span::poll() { +void Span::poll(int taskDelay) { if(pollTaskHandle){ LOG0("\n** FATAL ERROR: Do not call homeSpan.poll() directly if homeSpan.start() is used!\n** PROGRAM HALTED **\n\n"); @@ -161,12 +161,12 @@ void Span::poll() { while(1); } - pollTask(); + pollTask(taskDelay); } /////////////////////////////// -void Span::pollTask() { +void Span::pollTask(int taskDelay) { if(!strlen(category)){ LOG0("\n** FATAL ERROR: Cannot start homeSpan polling without an initial call to homeSpan.begin()!\n** PROGRAM HALTED **\n\n"); @@ -300,8 +300,8 @@ void Span::pollTask() { } statusLED->check(); - - vTaskDelay(5); + if (taskDelay > 0) + vTaskDelay(taskDelay); } // poll diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 5a22b59..9d044b9 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -254,7 +254,7 @@ class Span{ unordered_map UserCommands; // map of pointers to all UserCommands - void pollTask(); // poll HAP Clients and process any new HAP requests + void pollTask(int taskDelay = 5); // poll HAP Clients and process any new HAP requests with configurable vTaskDelay int getFreeSlot(); // returns free HAPClient slot number. HAPClients slot keep track of each active HAPClient connection void checkConnect(); // check WiFi connection; connect if needed void commandMode(); // allows user to control and reset HomeSpan settings with the control button @@ -285,7 +285,7 @@ class Span{ const char *hostNameBase=DEFAULT_HOST_NAME, const char *modelName=DEFAULT_MODEL_NAME); - void poll(); // calls pollTask() with some error checking + void poll(int taskDelay = 5); // calls pollTask() with some error checking and configurable vTaskDelay void processSerialCommand(const char *c); // process command 'c' (typically from readSerial, though can be called with any 'c') boolean updateDatabase(boolean updateMDNS=true); // updates HAP Configuration Number and Loop vector; if updateMDNS=true and config number has changed, re-broadcasts MDNS 'c#' record; returns true if config number changed