Added extra details to weblog webserver.
Display libsodium and MbedTLS version. Allow specifying a custom stylesheet to start customizing the output.
This commit is contained in:
parent
97a69b4981
commit
6e82e8ad0d
19
src/HAP.cpp
19
src/HAP.cpp
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <ESPmDNS.h>
|
||||
#include <sodium.h>
|
||||
#include <mbedtls/version.h>
|
||||
#include <MD5Builder.h>
|
||||
|
||||
#include "HAP.h"
|
||||
|
|
@ -1239,18 +1240,20 @@ int HAPClient::getStatusURL(){
|
|||
int mins=(seconds/=60)%60;
|
||||
int hours=(seconds/=60)%24;
|
||||
int days=(seconds/=24);
|
||||
|
||||
char mbtlsv[32];
|
||||
mbedtls_version_get_string_full(mbtlsv);
|
||||
|
||||
sprintf(uptime,"%d:%02d:%02d:%02d",days,hours,mins,secs);
|
||||
|
||||
String response="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
|
||||
String response="HTTP/1.1 200 OK\r\nContent-type: text/html; charset=utf-8\r\n\r\n";
|
||||
|
||||
response+="<html><head><title>" + String(homeSpan.displayName) + "</title>\n";
|
||||
response+="<style>th, td {padding-right: 10px; padding-left: 10px; border:1px solid black;}";
|
||||
response+="</style></head>\n";
|
||||
response+="<body style=\"background-color:lightblue;\">\n";
|
||||
response+= String(homeSpan.webLog.cssStyle);
|
||||
response+="</head>\n";
|
||||
response+="<body>\n";
|
||||
response+="<p><b>" + String(homeSpan.displayName) + "</b></p>\n";
|
||||
|
||||
response+="<table>\n";
|
||||
response+="<table id=homespan_hap_properties>\n";
|
||||
response+="<tr><td>Up Time:</td><td>" + String(uptime) + "</td></tr>\n";
|
||||
response+="<tr><td>Current Time:</td><td>" + String(clocktime) + "</td></tr>\n";
|
||||
response+="<tr><td>Boot Time:</td><td>" + String(homeSpan.webLog.bootTime) + "</td></tr>\n";
|
||||
|
|
@ -1262,13 +1265,15 @@ int HAPClient::getStatusURL(){
|
|||
response+="<tr><td>Arduino-ESP Version:</td><td>" + String(ARDUINO_ESP_VERSION) + "</td></tr>\n";
|
||||
response+="<tr><td>ESP-IDF Version:</td><td>" + String(ESP_IDF_VERSION_MAJOR) + "." + String(ESP_IDF_VERSION_MINOR) + "." + String(ESP_IDF_VERSION_PATCH) + "</td></tr>\n";
|
||||
response+="<tr><td>HomeSpan Version:</td><td>" + String(HOMESPAN_VERSION) + "</td></tr>\n";
|
||||
response+="<tr><td>Sodium Version:</td><td>" + String(sodium_version_string()) + " Lib " + String(sodium_library_version_major()) + "." + String(sodium_library_version_minor()) + "</td></tr>\n";
|
||||
response+="<tr><td>MbedTLS:</td><td>" + String(mbtlsv) + "</td></tr>\n";
|
||||
response+="<tr><td>Sketch Version:</td><td>" + String(homeSpan.getSketchVersion()) + "</td></tr>\n";
|
||||
response+="<tr><td>Max Log Entries:</td><td>" + String(homeSpan.webLog.maxEntries) + "</td></tr>\n";
|
||||
response+="</table>\n";
|
||||
response+="<p></p>";
|
||||
|
||||
if(homeSpan.webLog.maxEntries>0){
|
||||
response+="<table><tr><th>Entry</th><th>Up Time</th><th>Log Time</th><th>Client</th><th>Message</th></tr>\n";
|
||||
response+="<table id=homespan_weblogs><tr><th>Entry</th><th>Up Time</th><th>Log Time</th><th>Client</th><th>Message</th></tr>\n";
|
||||
int lastIndex=homeSpan.webLog.nEntries-homeSpan.webLog.maxEntries;
|
||||
if(lastIndex<0)
|
||||
lastIndex=0;
|
||||
|
|
|
|||
|
|
@ -2169,12 +2169,13 @@ SpanUserCommand::SpanUserCommand(char c, const char *s, void (*f)(const char *,
|
|||
// SpanWebLog //
|
||||
///////////////////////////////
|
||||
|
||||
void SpanWebLog::init(uint16_t maxEntries, const char *serv, const char *tz, const char *url){
|
||||
void SpanWebLog::init(uint16_t maxEntries, const char *serv, const char *tz, const char *url, String css){
|
||||
isEnabled=true;
|
||||
this->maxEntries=maxEntries;
|
||||
timeServer=serv;
|
||||
timeZone=tz;
|
||||
statusURL="GET /" + String(url) + " ";
|
||||
cssStyle=css;
|
||||
log = (log_t *)calloc(maxEntries,sizeof(log_t));
|
||||
if(timeServer)
|
||||
homeSpan.reserveSocketConnections(1);
|
||||
|
|
|
|||
|
|
@ -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 cssStyle; // Default CSS style.
|
||||
|
||||
struct log_t { // log entry type
|
||||
uint64_t upTime; // number of seconds since booting
|
||||
|
|
@ -159,7 +160,7 @@ struct SpanWebLog{ // optional web status/log data
|
|||
String clientIP; // IP address of client making request (or "0.0.0.0" if not applicable)
|
||||
} *log=NULL; // array of log entries
|
||||
|
||||
void init(uint16_t maxEntries, const char *serv, const char *tz, const char *url);
|
||||
void init(uint16_t maxEntries, const char *serv, const char *tz, const char *url, String css);
|
||||
void initTime();
|
||||
void vLog(boolean sysMsg, const char *fmr, va_list ap);
|
||||
};
|
||||
|
|
@ -330,8 +331,8 @@ class Span{
|
|||
int enableOTA(boolean auth=true, boolean safeLoad=true){return(spanOTA.init(auth, safeLoad, NULL));} // enables Over-the-Air updates, with (auth=true) or without (auth=false) authorization password
|
||||
int enableOTA(const char *pwd, boolean safeLoad=true){return(spanOTA.init(true, safeLoad, pwd));} // enables Over-the-Air updates, with custom authorization password (overrides any password stored with the 'O' command)
|
||||
|
||||
void enableWebLog(uint16_t maxEntries=0, const char *serv=NULL, const char *tz="UTC", const char *url=DEFAULT_WEBLOG_URL){ // enable Web Logging
|
||||
webLog.init(maxEntries, serv, tz, url);
|
||||
void enableWebLog(uint16_t maxEntries=0, const char *serv=NULL, const char *tz="UTC", const char *url=DEFAULT_WEBLOG_URL, String css="<style>th, td {padding-right: 10px; padding-left: 10px; border:1px solid black;}</style>\n"){ // enable Web Logging
|
||||
webLog.init(maxEntries, serv, tz, url, css);
|
||||
}
|
||||
|
||||
void addWebLog(boolean sysMsg, const char *fmt, ...){ // add Web Log entry
|
||||
|
|
|
|||
Loading…
Reference in New Issue