diff --git a/src/HAP.cpp b/src/HAP.cpp index 5a4c4d9..3bfd322 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1277,6 +1277,10 @@ int HAPClient::getStatusURL(){ response+="HomeKit Status:" + String(HAPClient::nAdminControllers()?"PAIRED":"NOT PAIRED") + "\n"; response+="Max Log Entries:" + String(homeSpan.webLog.maxEntries) + "\n"; + + if(homeSpan.weblogCallback) + response+=homeSpan.weblogCallback(); + response+="\n"; response+="

"; diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 99a58ea..b87b263 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -232,6 +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 (*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 @@ -347,6 +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);} 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 431500e..478542b 100644 --- a/src/src.ino +++ b/src/src.ino @@ -39,12 +39,22 @@ struct LED_Service : Service::LightBulb { } boolean update(){ - digitalWrite(ledPin,power->getNewVal()); + digitalWrite(ledPin,power->getNewVal()); + WEBLOG("Power = %s",power->getNewVal()?"ON":"OFF"); return(true); } }; - + +////////////////////////////////////// + +String 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); +} + ////////////////////////////////////// void setup() { @@ -55,7 +65,7 @@ void setup() { // homeSpan.setControlPin(21); - homeSpan.setLogLevel(2); + homeSpan.setLogLevel(2).enableWebLog(20).setWebLogCallback(extraData); // homeSpan.reserveSocketConnections(10); // homeSpan.setApSSID("HS_Setup");