From 4de61e591454cff52390ec4f26e56296b64f55ab Mon Sep 17 00:00:00 2001 From: Gregg Date: Tue, 24 Oct 2023 13:43:04 -0500 Subject: [PATCH] Change webLogCallback() to pass String as reference --- src/HAP.cpp | 2 +- src/HomeSpan.h | 4 ++-- src/src.ino | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/HAP.cpp b/src/HAP.cpp index 3bfd322..66910b3 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1279,7 +1279,7 @@ int HAPClient::getStatusURL(){ response+="Max Log Entries:" + String(homeSpan.webLog.maxEntries) + "\n"; if(homeSpan.weblogCallback) - response+=homeSpan.weblogCallback(); + homeSpan.weblogCallback(response); response+="\n"; response+="

"; diff --git a/src/HomeSpan.h b/src/HomeSpan.h index b87b263..1c05833 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -232,7 +232,7 @@ class Span{ uint16_t tcpPortNum=DEFAULT_TCP_PORT; // port for TCP communications between HomeKit and HomeSpan char qrID[5]=""; // Setup ID used for pairing with QR Code void (*wifiCallback)()=NULL; // optional callback function to invoke once WiFi connectivity is established - String (*weblogCallback)()=NULL; // optional callback function to invoke after header table in Web Log is produced + void (*weblogCallback)(String &)=NULL; // optional callback function to invoke after header table in Web Log is produced void (*pairCallback)(boolean isPaired)=NULL; // optional callback function to invoke when pairing is established (true) or lost (false) boolean autoStartAPEnabled=false; // enables auto start-up of Access Point when WiFi Credentials not found void (*apFunction)()=NULL; // optional function to invoke when starting Access Point @@ -348,7 +348,7 @@ class Span{ } Span& setWebLogCSS(const char *css){webLog.css="\n" + String(css) + "\n";return(*this);} - Span& setWebLogCallback(String (*f)()){weblogCallback=f;return(*this);} + Span& setWebLogCallback(void (*f)(String &)){weblogCallback=f;return(*this);} void autoPoll(uint32_t stackSize=8192, uint32_t priority=1, uint32_t cpu=0){ // start pollTask() xTaskCreateUniversal([](void *parms){for(;;)homeSpan.pollTask();}, "pollTask", stackSize, NULL, priority, &pollTaskHandle, cpu); diff --git a/src/src.ino b/src/src.ino index 478542b..5bf602d 100644 --- a/src/src.ino +++ b/src/src.ino @@ -48,11 +48,9 @@ struct LED_Service : Service::LightBulb { ////////////////////////////////////// -String extraData(){ - String r; +void extraData(String &r){ r+="Free RAM:" + String((double)(esp_get_free_internal_heap_size() / 1024),2) + " Kb (" + String(esp_get_free_internal_heap_size()) + " bytes)\n"; r+="Free PSRAM:" + String((double)(esp_get_free_heap_size() / 1024 / 1024),2) + " Mb (" + String(esp_get_free_heap_size()) + " bytes)\n"; - return(r); } //////////////////////////////////////