From 947e2af012378eb370f95948d710679c4d95bb25 Mon Sep 17 00:00:00 2001 From: Gregg Date: Sun, 23 Apr 2023 10:01:00 -0500 Subject: [PATCH] Added homeSpan.setWebLogCSS(const char *css) Allows user to define a custom style sheet to change the webLog output. Style sheet is based on pre-defined class: bod1 = main body of web page, including header (in format of

) tabl1 = top table showing general status tab2 = bottom table showing all weblog entries --- src/HAP.cpp | 10 ++++------ src/HomeSpan.h | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/HAP.cpp b/src/HAP.cpp index fa4d743..395da3d 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1246,12 +1246,10 @@ int HAPClient::getStatusURL(){ String response="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; response+="" + String(homeSpan.displayName) + "\n"; - response+="\n"; - response+="\n"; - response+="

" + String(homeSpan.displayName) + "

\n"; + response+="\n"; + response+="

" + String(homeSpan.displayName) + "

\n"; - response+="\n"; + response+="
\n"; response+="\n"; response+="\n"; response+="\n"; @@ -1276,7 +1274,7 @@ int HAPClient::getStatusURL(){ response+="

"; if(homeSpan.webLog.maxEntries>0){ - response+="
Up Time:" + String(uptime) + "
Current Time:" + String(clocktime) + "
Boot Time:" + String(homeSpan.webLog.bootTime) + "
\n"; + response+="
EntryUp TimeLog TimeClientMessage
\n"; int lastIndex=homeSpan.webLog.nEntries-homeSpan.webLog.maxEntries; if(lastIndex<0) lastIndex=0; diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 0edcb76..ceaea9f 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -151,6 +151,7 @@ struct SpanWebLog{ // optional web status/log data char bootTime[33]="Unknown"; // boot time String statusURL; // URL of status log uint32_t waitTime=10000; // number of milliseconds to wait for initial connection to time server + String css=""; // optional user-defined style sheet for web log struct log_t { // log entry type uint64_t upTime; // number of seconds since booting @@ -341,6 +342,8 @@ class Span{ va_end(ap); } + void setWebLogCSS(const char *css){webLog.css="\n" + String(css) + "\n";} + 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); Serial.printf("\n*** AutoPolling Task started with priority=%d\n\n",uxTaskPriorityGet(pollTaskHandle));
EntryUp TimeLog TimeClientMessage