1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681 |
- static void printIP(IPAddress ipa, const char sep, String& response)
- {
- response+=(String)ipa[0]; response+=sep;
- response+=(String)ipa[1]; response+=sep;
- response+=(String)ipa[2]; response+=sep;
- response+=(String)ipa[3];
- }
- #if A_SERVER==1
- boolean YesNo()
- {
- boolean ret = false;
- String response = "";
- response += "<script>";
-
- response += "var ch = \"\"; ";
- response += "function ynDialog(s,y) {";
- response += " try { adddlert(s); }";
- response += " catch(err) {";
- response += " ch = \" \" + s + \".\\n\\n\"; ";
- response += " ch += \"Click OK to continue,\\n\"; ";
- response += " ch += \"or Cancel\\n\\n\"; ";
- response += " if(!confirm(ch)) { ";
- response += " javascript:window.location.reload(true);";
- response += " } ";
- response += " else { ";
- response += " document.location.href = '/'+y; ";
- response += " } ";
- response += " }";
- response += "}";
- response += "</script>";
- server.sendContent(response);
-
-
- return(ret);
- }
- void wwwFile(String fn) {
- if (!SPIFFS.exists(fn)) {
- #if _DUSB>=1
- Serial.print(F("wwwFile:: ERROR: file not found="));
- Serial.println(fn);
- #endif
- return;
- }
- #if _DUSB>=2
- else {
- Serial.print(F("wwwFile:: File existist= "));
- Serial.println(fn);
- }
- #endif
- #if _DUSB>=1
- File f = SPIFFS.open(fn, "r");
-
- int j;
- for (j=0; j<LOGFILEREC; j++) {
-
- String s=f.readStringUntil('\n');
- if (s.length() == 0) {
- Serial.print(F("wwwFile:: String length 0"));
- break;
- }
- server.sendContent(s.substring(12));
- server.sendContent("\n");
- yield();
- }
-
- f.close();
- #endif
-
- }
- void buttonDocu()
- {
- String response = "";
- response += "<script>";
-
- response += "var txt = \"\";";
- response += "function showDocu() {";
- response += " try { adddlert(\"Welcome,\"); }";
- response += " catch(err) {";
- response += " txt = \"Do you want the documentation page.\\n\\n\"; ";
- response += " txt += \"Click OK to continue viewing documentation,\\n\"; ";
- response += " txt += \"or Cancel to return to the home page.\\n\\n\"; ";
- response += " if(confirm(txt)) { ";
- response += " document.location.href = \"https:
- response += " }";
- response += " }";
- response += "}";
-
- response += "</script>";
- server.sendContent(response);
- }
- void buttonLog()
- {
-
- String fn = "";
- int i = 0;
-
- while (i< LOGFILEMAX ) {
- fn = "/log-" + String(gwayConfig.logFileNo - i);
- wwwFile(fn);
- i++;
- }
-
- }
- void buttonSeen()
- {
- String fn = "";
- int i = 0;
-
- printSeen(listSeen);
- #if _DUSB>=1
- if (( debug>=1 ) && ( pdebug & P_MAIN )) {
- Serial.println(F("buttonSeen:: printSeen called"));
- }
- #endif
- }
- static void wwwButtons()
- {
- String response = "";
- String mode = (gwayConfig.expert ? "Basic Mode" : "Expert Mode");
- YesNo();
- buttonDocu();
- response += "<input type=\"button\" value=\"Documentation\" onclick=\"showDocu()\" >";
-
- response += "<a href=\"EXPERT\" download><button type=\"button\">" + mode + "</button></a>";
- response += "<a href=\"SEEN\" download><button type=\"button\">Nodes Seen</button></a>";
- response += "<a href=\"LOG\" download><button type=\"button\">Log Files</button></a>";
- server.sendContent(response);
- }
- static void setVariables(const char *cmd, const char *arg) {
-
- if (strcmp(cmd, "DEBUG")==0) {
- if (atoi(arg) == 1) {
- debug = (debug+1)%4;
- }
- else if (atoi(arg) == -1) {
- debug = (debug+3)%4;
- }
- writeGwayCfg(CONFIGFILE);
- }
-
- if (strcmp(cmd, "CAD")==0) {
- _cad=(bool)atoi(arg);
- writeGwayCfg(CONFIGFILE);
- }
-
- if (strcmp(cmd, "HOP")==0) {
- _hop=(bool)atoi(arg);
- if (! _hop) {
- ifreq=0;
- setFreq(freqs[ifreq].upFreq);
- rxLoraModem();
- sf = SF7;
- cadScanner();
- }
- writeGwayCfg(CONFIGFILE);
- }
-
-
-
- if (strcmp(cmd, "DELAY")==0) {
- gwayConfig.txDelay+=atoi(arg)*1000;
- writeGwayCfg(CONFIGFILE);
- }
-
-
- if (strcmp(cmd, "TRUSTED")==0) {
- gwayConfig.trusted=atoi(arg);
- if (atoi(arg) == 1) {
- gwayConfig.trusted = (gwayConfig.trusted +1)%4;
- }
- else if (atoi(arg) == -1) {
- gwayConfig.trusted = (gwayConfig.trusted -1)%4;
- }
- writeGwayCfg(CONFIGFILE);
- }
-
-
-
- if (strcmp(cmd, "SF")==0) {
- uint8_t sfi = sf;
- if (atoi(arg) == 1) {
- if (sf>=SF12) sf=SF7; else sf= (sf_t)((int)sf+1);
- }
- else if (atoi(arg) == -1) {
- if (sf<=SF7) sf=SF12; else sf= (sf_t)((int)sf-1);
- }
- rxLoraModem();
- writeGwayCfg(CONFIGFILE);
- }
-
-
-
- if (strcmp(cmd, "FREQ")==0) {
- uint8_t nf = sizeof(freqs)/ sizeof(freqs[0]);
-
-
- if (atoi(arg) == 1) {
- if (ifreq==(nf-1)) ifreq=0; else ifreq++;
- }
- else if (atoi(arg) == -1) {
- Serial.println("down");
- if (ifreq==0) ifreq=(nf-1); else ifreq--;
- }
- setFreq(freqs[ifreq].upFreq);
- rxLoraModem();
- writeGwayCfg(CONFIGFILE);
- }
-
-
-
-
-
-
-
-
- if (strcmp(cmd, "HELP")==0) { Serial.println(F("Display Help Topics")); }
-
-
-
- #if GATEWAYNODE==1
- if (strcmp(cmd, "NODE")==0) {
- gwayConfig.isNode =(bool)atoi(arg);
- writeGwayCfg(CONFIGFILE);
- }
-
-
- if (strcmp(cmd, "FCNT")==0) {
- frameCount=0;
- rxLoraModem();
- writeGwayCfg(CONFIGFILE);
- }
- #endif
-
-
-
- #if _WIFIMANAGER==1
- if (strcmp(cmd, "NEWSSID")==0) {
- WiFiManager wifiManager;
- strcpy(wpa[0].login,"");
- strcpy(wpa[0].passw,"");
- WiFi.disconnect();
- wifiManager.autoConnect(AP_NAME, AP_PASSWD );
- }
- #endif
-
- #if A_OTA==1
- if (strcmp(cmd, "UPDATE")==0) {
- if (atoi(arg) == 1) {
- updateOtaa();
- writeGwayCfg(CONFIGFILE);
- }
- }
- #endif
- #if A_REFRESH==1
- if (strcmp(cmd, "REFR")==0) {
- gwayConfig.refresh =(bool)atoi(arg);
- writeGwayCfg(CONFIGFILE);
- }
- #endif
- }
- static void openWebPage()
- {
- ++gwayConfig.views;
- #if A_REFRESH==1
-
- #endif
- String response="";
- server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
- server.sendHeader("Pragma", "no-cache");
- server.sendHeader("Expires", "-1");
-
-
-
-
- server.setContentLength(CONTENT_LENGTH_UNKNOWN);
- server.send(200, "text/html", "");
- #if A_REFRESH==1
- if (gwayConfig.refresh) {
- response += String() + "<!DOCTYPE HTML><HTML><HEAD><meta http-equiv='refresh' content='"+_WWW_INTERVAL+";http://";
- printIP((IPAddress)WiFi.localIP(),'.',response);
- response += "'><TITLE>ESP8266 1ch Gateway</TITLE>";
- }
- else {
- response += String() + "<!DOCTYPE HTML><HTML><HEAD><TITLE>ESP8266 1ch Gateway</TITLE>";
- }
- #else
- response += String() + "<!DOCTYPE HTML><HTML><HEAD><TITLE>ESP8266 1ch Gateway</TITLE>";
- #endif
- response += "<META HTTP-EQUIV='CONTENT-TYPE' CONTENT='text/html; charset=UTF-8'>";
- response += "<META NAME='AUTHOR' CONTENT='M. Westenberg (mw1554@hotmail.com)'>";
- response += "<style>.thead {background-color:green; color:white;} ";
- response += ".cell {border: 1px solid black;}";
- response += ".config_table {max_width:100%; min-width:400px; width:98%; border:1px solid black; border-collapse:collapse;}";
- response += "</style></HEAD><BODY>";
-
- response +="<h1>ESP Gateway Config</h1>";
- response +="<p style='font-size:10px;'>";
- response +="Version: "; response+=VERSION;
- response +="<br>ESP alive since ";
- stringTime(startTime, response);
- response +=", Uptime: ";
- uint32_t secs = millis()/1000;
- uint16_t days = secs / 86400;
- uint8_t _hour = hour(secs);
- uint8_t _minute = minute(secs);
- uint8_t _second = second(secs);
- response += String() + days + "-";
- if (_hour < 10) response += "0";
- response += String() + _hour + ":";
- if (_minute < 10) response += "0";
- response += String() + _minute + ":";
- if (_second < 10) response += "0";
- response += String() + _second;
-
- response +="<br>Current time ";
- stringTime(now(), response);
- response +="<br>";
- response +="</p>";
-
- server.sendContent(response);
- }
- static void gatewaySettings()
- {
- String response="";
- String bg="";
-
- response +="<h2>Gateway Settings</h2>";
-
- response +="<table class=\"config_table\">";
- response +="<tr>";
- response +="<th class=\"thead\">Setting</th>";
- response +="<th colspan=\"2\" style=\"background-color: green; color: white; width:120px;\">Value</th>";
- response +="<th colspan=\"4\" style=\"background-color: green; color: white; width:100px;\">Set</th>";
- response +="</tr>";
-
- bg = " background-color: ";
- bg += ( _cad ? "LightGreen" : "orange" );
- response +="<tr><td class=\"cell\">CAD</td>";
- response +="<td colspan=\"2\" style=\"border: 1px solid black;"; response += bg; response += "\">";
- response += ( _cad ? "ON" : "OFF" );
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"CAD=1\"><button>ON</button></a></td>";
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"CAD=0\"><button>OFF</button></a></td>";
- response +="</tr>";
-
- bg = " background-color: ";
- bg += ( _hop ? "LightGreen" : "orange" );
- response +="<tr><td class=\"cell\">HOP</td>";
- response +="<td colspan=\"2\" style=\"border: 1px solid black;"; response += bg; response += "\">";
- response += ( _hop ? "ON" : "OFF" );
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"HOP=1\"><button>ON</button></a></td>";
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"HOP=0\"><button>OFF</button></a></td>";
- response +="</tr>";
-
- response +="<tr><td class=\"cell\">SF Setting</td><td class=\"cell\" colspan=\"2\">";
- if (_cad) {
- response += "AUTO</td>";
- }
- else {
- response += sf;
- response +="<td class=\"cell\"><a href=\"SF=-1\"><button>-</button></a></td>";
- response +="<td class=\"cell\"><a href=\"SF=1\"><button>+</button></a></td>";
- }
- response +="</tr>";
-
-
- response +="<tr><td class=\"cell\">Channel</td>";
- response +="<td class=\"cell\" colspan=\"2\">";
- if (_hop) {
- response += "AUTO</td>";
- }
- else {
- response += String() + ifreq;
- response +="</td>";
- response +="<td class=\"cell\"><a href=\"FREQ=-1\"><button>-</button></a></td>";
- response +="<td class=\"cell\"><a href=\"FREQ=1\"><button>+</button></a></td>";
- }
- response +="</tr>";
-
- #ifdef _TRUSTED_NODES
- response +="<tr><td class=\"cell\">Trusted Nodes</td><td class=\"cell\" colspan=\"2\">";
- response +=gwayConfig.trusted;
- response +="</td>";
- response +="<td class=\"cell\"><a href=\"TRUSTED=-1\"><button>-</button></a></td>";
- response +="<td class=\"cell\"><a href=\"TRUSTED=1\"><button>+</button></a></td>";
- response +="</tr>";
- #endif
-
-
- #if _DUSB>=1
- response +="<tr><td class=\"cell\">Debug Level</td><td class=\"cell\" colspan=\"2\">";
- response +=debug;
- response +="</td>";
- response +="<td class=\"cell\"><a href=\"DEBUG=-1\"><button>-</button></a></td>";
- response +="<td class=\"cell\"><a href=\"DEBUG=1\"><button>+</button></a></td>";
- response +="</tr>";
-
- if (gwayConfig.expert) {
- response +="<tr><td class=\"cell\">Time Correction (uSec)</td><td class=\"cell\" colspan=\"2\">";
- response += gwayConfig.txDelay;
- response +="</td>";
- response +="<td class=\"cell\"><a href=\"DELAY=-1\"><button>-</button></a></td>";
- response +="<td class=\"cell\"><a href=\"DELAY=1\"><button>+</button></a></td>";
- response +="</tr>";
- }
-
-
- response +="<tr><td class=\"cell\">Debug pattern</td>";
-
- bg = ( (pdebug & P_SCAN) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=SCAN\">";
- response +="<button>SCN</button></a></td>";
-
- bg = ( (pdebug & P_CAD) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=CAD\">";
- response +="<button>CAD</button></a></td>";
- bg = ( (pdebug & P_RX) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=RX\">";
- response +="<button>RX</button></a></td>";
- bg = ( (pdebug & P_TX) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=TX\">";
- response +="<button>TX</button></a></td>";
- response += "</tr>";
-
-
- response +="<tr><td class=\"cell\"></td>";
- bg = ( (pdebug & P_PRE) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=PRE\">";
- response +="<button>PRE</button></a></td>";
- bg = ( (pdebug & P_MAIN) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=MAIN\">";
- response +="<button>MAI</button></a></td>";
-
- bg = ( (pdebug & P_GUI) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=GUI\">";
- response +="<button>GUI</button></a></td>";
- bg = ( (pdebug & P_RADIO) ? "LightGreen" : "orange" );
- response +="<td class=\"cell\" style=\"border: 1px solid black; width:20px; background-color: ";
- response += bg; response += "\">";
- response +="<a href=\"PDEBUG=RADIO\">";
- response +="<button>RDIO</button></a></td>";
- response +="</tr>";
- #endif
-
- response +="<tr><td class=\"cell\">Usb Debug</td><td class=\"cell\" colspan=\"2\">";
- response += _DUSB;
- response +="</td>";
-
-
- response +="</tr>";
-
- #if GATEWAYNODE==1
- response +="<tr><td class=\"cell\">Framecounter Internal Sensor</td>";
- response +="<td class=\"cell\" colspan=\"2\">";
- response +=frameCount;
- response +="</td><td colspan=\"2\" style=\"border: 1px solid black;\">";
- response +="<button><a href=\"/FCNT\">RESET</a></button></td>";
- response +="</tr>";
-
- bg = " background-color: ";
- bg += ( (gwayConfig.isNode == 1) ? "LightGreen" : "orange" );
- response +="<tr><td class=\"cell\">Gateway Node</td>";
- response +="<td class=\"cell\" style=\"border: 1px solid black;" + bg + "\">";
- response += ( (gwayConfig.isNode == true) ? "ON" : "OFF" );
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"NODE=1\"><button>ON</button></a></td>";
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"NODE=0\"><button>OFF</button></a></td>";
- response +="</tr>";
- #endif
-
- #if A_REFRESH==1
- bg = " background-color: ";
- bg += ( (gwayConfig.refresh == 1) ? "LightGreen" : "orange" );
- response +="<tr><td class=\"cell\">WWW Refresh</td>";
- response +="<td class=\"cell\" colspan=\"2\" style=\"border: 1px solid black; " + bg + "\">";
- response += ( (gwayConfig.refresh == 1) ? "ON" : "OFF" );
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"REFR=1\"><button>ON</button></a></td>";
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"REFR=0\"><button>OFF</button></a></td>";
- response +="</tr>";
- #endif
-
- #if _WIFIMANAGER==1
- response +="<tr><td><tr><td>";
- response +="Click <a href=\"/NEWSSID\">here</a> to reset accesspoint<br>";
- response +="</td><td></td></tr>";
- #endif
-
- response +="<tr><td class=\"cell\">Update Firmware</td><td colspan=\"2\"></td>";
- response +="<td class=\"cell\" colspan=\"2\" class=\"cell\"><a href=\"/UPDATE=1\"><button>UPDATE</button></a></td></tr>";
-
- response +="<tr><td class=\"cell\">Format SPIFFS</td>";
- response +=String() + "<td class=\"cell\" colspan=\"2\" >"+""+"</td>";
- response +="<td colspan=\"2\" class=\"cell\"><input type=\"button\" value=\"FORMAT\" onclick=\"ynDialog(\'Do you really want to format?\',\'FORMAT\')\" /></td></tr>";
-
- #if _STATISTICS >= 1
- response +="<tr><td class=\"cell\">Statistics</td>";
- response +=String() + "<td class=\"cell\" colspan=\"2\" >"+statc.resets+"</td>";
- response +="<td colspan=\"2\" class=\"cell\"><input type=\"button\" value=\"RESET\" onclick=\"ynDialog(\'Do you really want to reset statistics?\',\'RESET\')\" /></td></tr>";
-
- response +="<tr><td class=\"cell\">Boots and Resets</td>";
- response +=String() + "<td class=\"cell\" colspan=\"2\" >"+gwayConfig.boots+"</td>";
- response +="<td colspan=\"2\" class=\"cell\"><input type=\"button\" value=\"RESET\" onclick=\"ynDialog(\'Do you want to reset boots?\',\'BOOT\')\" /></td></tr>";
- #endif
-
- response +="</table>";
-
- server.sendContent(response);
- }
- static void statisticsData()
- {
- String response="";
-
- response +="<h2>Package Statistics</h2>";
- response +="<table class=\"config_table\">";
- response +="<tr><th class=\"thead\">Counter</th>";
- #if _STATISTICS == 3
- response +="<th class=\"thead\">C 0</th>";
- response +="<th class=\"thead\">C 1</th>";
- response +="<th class=\"thead\">C 2</th>";
- #endif
- response +="<th class=\"thead\">Pkgs</th>";
- response +="<th class=\"thead\">Pkgs/hr</th>";
- response +="</tr>";
-
-
-
- response +="<tr><td class=\"cell\">Packages Downlink</td>";
- #if _STATISTICS == 3
- response +="<td class=\"cell\">" + String(statc.msg_down_0) + "</td>";
- response +="<td class=\"cell\">" + String(statc.msg_down_1) + "</td>";
- response +="<td class=\"cell\">" + String(statc.msg_down_2) + "</td>";
- #endif
- response += "<td class=\"cell\">" + String(statc.msg_down) + "</td>";
- response +="<td class=\"cell\"></td></tr>";
-
- response +="<tr><td class=\"cell\">Packages Uplink Total</td>";
- #if _STATISTICS == 3
- response +="<td class=\"cell\">" + String(statc.msg_ttl_0) + "</td>";
- response +="<td class=\"cell\">" + String(statc.msg_ttl_1) + "</td>";
- response +="<td class=\"cell\">" + String(statc.msg_ttl_2) + "</td>";
- #endif
- response +="<td class=\"cell\">" + String(statc.msg_ttl) + "</td>";
- response +="<td class=\"cell\">" + String((statc.msg_ttl*3600)/(now() - startTime)) + "</td></tr>";
-
- response +="<tr><td class=\"cell\">Packages Uplink OK </td>";
- #if _STATISTICS == 3
- response +="<td class=\"cell\">" + String(statc.msg_ok_0) + "</td>";
- response +="<td class=\"cell\">" + String(statc.msg_ok_1) + "</td>";
- response +="<td class=\"cell\">" + String(statc.msg_ok_2) + "</td>";
- #endif
- response +="<td class=\"cell\">" + String(statc.msg_ok) + "</td>";
- response +="<td class=\"cell\"></td></tr>";
-
-
- #if _STATISTICS == 2
- response +="<tr><td class=\"cell\">SF7 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf7;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf7/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
- response +="<tr><td class=\"cell\">SF8 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf8;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf8/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
- response +="<tr><td class=\"cell\">SF9 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf9;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf9/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
- response +="<tr><td class=\"cell\">SF10 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf10;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf10/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
- response +="<tr><td class=\"cell\">SF11 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf11;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf11/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
- response +="<tr><td class=\"cell\">SF12 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf12;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf12/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
- #endif
- #if _STATISTICS == 3
- response +="<tr><td class=\"cell\">SF7 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf7_0;
- response +="<td class=\"cell\">"; response +=statc.sf7_1;
- response +="<td class=\"cell\">"; response +=statc.sf7_2;
- response +="<td class=\"cell\">"; response +=statc.sf7;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf7/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
-
- response +="<tr><td class=\"cell\">SF8 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf8_0;
- response +="<td class=\"cell\">"; response +=statc.sf8_1;
- response +="<td class=\"cell\">"; response +=statc.sf8_2;
- response +="<td class=\"cell\">"; response +=statc.sf8;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf8/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
-
- response +="<tr><td class=\"cell\">SF9 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf9_0;
- response +="<td class=\"cell\">"; response +=statc.sf9_1;
- response +="<td class=\"cell\">"; response +=statc.sf9_2;
- response +="<td class=\"cell\">"; response +=statc.sf9;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf9/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
-
- response +="<tr><td class=\"cell\">SF10 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf10_0;
- response +="<td class=\"cell\">"; response +=statc.sf10_1;
- response +="<td class=\"cell\">"; response +=statc.sf10_2;
- response +="<td class=\"cell\">"; response +=statc.sf10;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf10/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
-
- response +="<tr><td class=\"cell\">SF11 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf11_0;
- response +="<td class=\"cell\">"; response +=statc.sf11_1;
- response +="<td class=\"cell\">"; response +=statc.sf11_2;
- response +="<td class=\"cell\">"; response +=statc.sf11;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf11/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
-
- response +="<tr><td class=\"cell\">SF12 rcvd</td>";
- response +="<td class=\"cell\">"; response +=statc.sf12_0;
- response +="<td class=\"cell\">"; response +=statc.sf12_1;
- response +="<td class=\"cell\">"; response +=statc.sf12_1;
- response +="<td class=\"cell\">"; response +=statc.sf12;
- response +="<td class=\"cell\">"; response += String(statc.msg_ttl>0 ? 100*statc.sf12/statc.msg_ttl : 0)+" %";
- response +="</td></tr>";
- #endif
- response +="</table>";
- server.sendContent(response);
- }
- static void messageHistory()
- {
- #if _STATISTICS >= 1
- String response="";
-
- response += "<h2>Message History</h2>";
- response += "<table class=\"config_table\">";
- response += "<tr>";
- response += "<th class=\"thead\">Time</th>";
- response += "<th class=\"thead\">Node</th>";
- #if _LOCALSERVER==1
- response += "<th class=\"thead\">Data</th>";
- #endif
- response += "<th class=\"thead\" style=\"width: 20px;\">C</th>";
- response += "<th class=\"thead\">Freq</th>";
- response += "<th class=\"thead\" style=\"width: 40px;\">SF</th>";
- response += "<th class=\"thead\" style=\"width: 50px;\">pRSSI</th>";
- #if RSSI==1
- if (debug > 1) {
- response += "<th class=\"thead\" style=\"width: 50px;\">RSSI</th>";
- }
- #endif
- response += "</tr>";
- server.sendContent(response);
-
- for (int i=0; i<MAX_STAT; i++) {
- if (statr[i].sf == 0) break;
-
- response = "";
-
- response += String() + "<tr><td class=\"cell\">";
- stringTime((statr[i].tmst), response);
- response += "</td>";
-
- response += String() + "<td class=\"cell\">";
-
- #ifdef _TRUSTED_NODES
- switch (gwayConfig.trusted) {
- case 0: printHEX((char *)(& (statr[i].node)),' ',response);
- break;
- case 1: if (SerialName((char *)(& (statr[i].node)), response) < 0) {
- printHEX((char *)(& (statr[i].node)),' ',response);
- };
- break;
- case 2: if (SerialName((char *)(& (statr[i].node)), response) < 0) {
- continue;
- };
- break;
- case 3:
- default:
- #if _DUSB>=1
- Serial.println("Unknow value for gwayConfig.trusted");
- #endif
- }
-
- #else
- printHEX((char *)(& (statr[i].node)),' ',response);
- #endif
- response += "</td>";
-
- #if _LOCALSERVER==1
- response += String() + "<td class=\"cell\">";
- for (int j=0; j<statr[i].datal; j++) {
- if (statr[i].data[j] <0x10) response+= "0";
- response += String(statr[i].data[j],HEX) + " ";
- }
- response += "</td>";
- #endif
- response += String() + "<td class=\"cell\">" + statr[i].ch + "</td>";
- response += String() + "<td class=\"cell\">" + freqs[statr[i].ch].upFreq + "</td>";
- response += String() + "<td class=\"cell\">" + statr[i].sf + "</td>";
- response += String() + "<td class=\"cell\">" + statr[i].prssi + "</td>";
- #if RSSI==1
- if (debug >= 2) {
- response += String() + "<td class=\"cell\">" + statr[i].rssi + "</td>";
- }
- #endif
- response += "</tr>";
- server.sendContent(response);
- }
-
- server.sendContent("</table>");
-
- #endif
- }
- static void nodeHistory()
- {
- #if _SEENMAX > 0
- if (gwayConfig.expert) {
-
- String response="";
-
- response += "<h2>Node Last Seen History</h2>";
- response += "<table class=\"config_table\">";
- response += "<tr>";
- response += "<th class=\"thead\" style=\"width: 220px;\">Time</th>";
- response += "<th class=\"thead\">Node</th>";
- response += "<th class=\"thead\" style=\"width: 20px;\">C</th>";
- response += "<th class=\"thead\" style=\"width: 40px;\">SF</th>";
- response += "</tr>";
- server.sendContent(response);
-
-
-
- int i;
- for (i=0; i<_SEENMAX; i++) {
- if (listSeen[i].idSeen == 0) break;
- response = "";
-
- response += String() + "<tr><td class=\"cell\">";
- stringTime((listSeen[i].timSeen), response);
- response += "</td>";
-
- response += String() + "<td class=\"cell\">";
- #ifdef _TRUSTED_NODES
- switch (gwayConfig.trusted) {
- case 0: printHEX((char *)(& (listSeen[i].idSeen)),' ',response);
- break;
- case 1: if (SerialName((char *)(& (listSeen[i].idSeen)), response) < 0) {
- printHEX((char *)(& (listSeen[i].idSeen)),' ',response);
- };
- break;
- case 2: if (SerialName((char *)(& (listSeen[i].idSeen)), response) < 0) {
- continue;
- };
- break;
- case 3:
- default:
- #if _DUSB>=1
- Serial.println("Unknow value for gwayConfig.trusted");
- #endif
- }
- #else
- printHEX((char *)(& (listSeen[i].idSeen)),' ',response);
- #endif
-
- response += "</td>";
- response += String() + "<td class=\"cell\">" + 0 + "</td>";
-
- response += String() + "<td class=\"cell\">" + listSeen[i].sfSeen + "</td>";
-
- server.sendContent(response);
- }
- server.sendContent("</table>");
- }
- #endif
- }
- void sendWebPage(const char *cmd, const char *arg)
- {
- openWebPage(); yield();
-
- wwwButtons();
-
- setVariables(cmd,arg); yield();
- statisticsData(); yield();
- messageHistory(); yield();
- nodeHistory(); yield();
- gatewaySettings(); yield();
- wifiConfig(); yield();
-
- systemStatus(); yield();
- interruptData(); yield();
-
- websiteFooter(); yield();
-
-
- server.client().stop();
- }
- void setupWWW()
- {
- server.begin();
-
-
-
-
- server.on("/", []() {
- sendWebPage("","");
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/HELP", []() {
- sendWebPage("HELP","");
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/FORMAT", []() {
- Serial.print(F("FORMAT ..."));
-
- SPIFFS.format();
- initConfig(&gwayConfig);
- writeConfig( CONFIGFILE, &gwayConfig);
- writeSeen( _SEENFILE, listSeen);
- #if _DUSB>=1
- Serial.println(F("DONE"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
-
-
- server.on("/RESET", []() {
- Serial.println(F("RESET"));
- startTime= now() - 1;
-
- statc.msg_ttl = 0;
- statc.msg_ok = 0;
- statc.msg_down = 0;
-
- #if _STATISTICS >= 3
- statc.msg_ttl_0 = 0;
- statc.msg_ttl_1 = 0;
- statc.msg_ttl_2 = 0;
- statc.msg_ok_0 = 0;
- statc.msg_ok_1 = 0;
- statc.msg_ok_2 = 0;
- statc.msg_down_0 = 0;
- statc.msg_down_1 = 0;
- statc.msg_down_2 = 0;
- #endif
- #if _STATISTICS >= 1
- for (int i=0; i<MAX_STAT; i++) { statr[i].sf = 0; }
- #if _STATISTICS >= 2
- statc.sf7 = 0;
- statc.sf8 = 0;
- statc.sf9 = 0;
- statc.sf10= 0;
- statc.sf11= 0;
- statc.sf12= 0;
-
- statc.resets= 0;
- writeGwayCfg(CONFIGFILE);
- #if _STATISTICS >= 3
- statc.sf7_0 = 0; statc.sf7_1 = 0; statc.sf7_2 = 0;
- statc.sf8_0 = 0; statc.sf8_1 = 0; statc.sf8_2 = 0;
- statc.sf9_0 = 0; statc.sf9_1 = 0; statc.sf9_2 = 0;
- statc.sf10_0= 0; statc.sf10_1= 0; statc.sf10_2= 0;
- statc.sf11_0= 0; statc.sf11_1= 0; statc.sf11_2= 0;
- statc.sf12_0= 0; statc.sf12_1= 0; statc.sf12_2= 0;
- #endif
- #endif
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/BOOT", []() {
- #if _STATISTICS >= 2
- gwayConfig.boots = 0;
- gwayConfig.wifis = 0;
- gwayConfig.views = 0;
- gwayConfig.ntpErr = 0;
- gwayConfig.ntpErrTime = 0;
- gwayConfig.ntps = 0;
- #endif
- gwayConfig.reents = 0;
- writeGwayCfg(CONFIGFILE);
- #if _DUSB>=1
- Serial.println(F("BOOT, config written"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/NEWSSID", []() {
- sendWebPage("NEWSSID","");
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/DEBUG=-1", []() {
- debug = (debug+3)%4;
- writeGwayCfg(CONFIGFILE);
- #if _DUSB>=1
- Serial.println(F("DEBUG -1: config written"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/DEBUG=1", []() {
- debug = (debug+1)%4;
- writeGwayCfg(CONFIGFILE);
- #if _DUSB>=1
- Serial.println(F("DEBUG +1: config written"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
-
- server.on("/PDEBUG=SCAN", []() {
- pdebug ^= P_SCAN;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/PDEBUG=CAD", []() {
- pdebug ^= P_CAD;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/PDEBUG=RX", []() {
- pdebug ^= P_RX;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/PDEBUG=TX", []() {
- pdebug ^= P_TX;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/PDEBUG=PRE", []() {
- pdebug ^= P_PRE;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/PDEBUG=MAIN", []() {
- pdebug ^= P_MAIN;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/PDEBUG=GUI", []() {
- pdebug ^= P_GUI;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/PDEBUG=RADIO", []() {
- pdebug ^= P_RADIO;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
-
- server.on("/DELAY=1", []() {
- gwayConfig.txDelay+=5000;
- writeGwayCfg(CONFIGFILE);
- #if _DUSB>=1
- Serial.println(F("DELAY +, config written"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/DELAY=-1", []() {
- gwayConfig.txDelay-=5000;
- writeGwayCfg(CONFIGFILE);
- #if _DUSB>=1
- Serial.println(F("DELAY +, config written"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/TRUSTED=1", []() {
- gwayConfig.trusted = (gwayConfig.trusted +1)%4;
- writeGwayCfg(CONFIGFILE);
- #if _DUSB>=2
- Serial.println(F("TRUSTED +, config written"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/TRUSTED=-1", []() {
- gwayConfig.trusted = (gwayConfig.trusted -1)%4;
- writeGwayCfg(CONFIGFILE);
- #if _DUSB>=2
- Serial.println(F("TRUSTED +, config written"));
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/SF=1", []() {
- if (sf>=SF12) sf=SF7; else sf= (sf_t)((int)sf+1);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/SF=-1", []() {
- if (sf<=SF7) sf=SF12; else sf= (sf_t)((int)sf-1);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/FREQ=1", []() {
- uint8_t nf = sizeof(freqs)/sizeof(freqs[0]);
- #if _DUSB==2
- Serial.print("FREQ==1:: For freq[0] sizeof vector=");
- Serial.print(sizeof(freqs[0]));
- Serial.println();
- #endif
- if (ifreq==(nf-1)) ifreq=0; else ifreq++;
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/FREQ=-1", []() {
- uint8_t nf = sizeof(freqs)/sizeof(freqs[0]);
- if (ifreq==0) ifreq=(nf-1); else ifreq--;
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/CAD=1", []() {
- _cad=(bool)1;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/CAD=0", []() {
- _cad=(bool)0;
- writeGwayCfg(CONFIGFILE);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/NODE=1", []() {
- #if GATEWAYNODE==1
- gwayConfig.isNode =(bool)1;
- writeGwayCfg(CONFIGFILE);
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/NODE=0", []() {
- #if GATEWAYNODE==1
- gwayConfig.isNode =(bool)0;
- writeGwayCfg(CONFIGFILE);
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- #if GATEWAYNODE==1
-
- server.on("/FCNT", []() {
- frameCount=0;
- rxLoraModem();
- writeGwayCfg(CONFIGFILE);
-
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- #endif
-
- server.on("/REFR=1", []() {
- #if A_REFRESH==1
- gwayConfig.refresh =1;
- writeGwayCfg(CONFIGFILE);
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/REFR=0", []() {
- #if A_REFRESH==1
- gwayConfig.refresh =0;
- writeGwayCfg(CONFIGFILE);
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
-
- server.on("/HOP=1", []() {
- _hop=true;
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/HOP=0", []() {
- _hop=false;
- ifreq=0;
- setFreq(freqs[ifreq].upFreq);
- rxLoraModem();
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- #if !defined ESP32_ARCH
-
- server.on("/SPEED=80", []() {
- system_update_cpu_freq(80);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- server.on("/SPEED=160", []() {
- system_update_cpu_freq(160);
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
- #endif
-
- server.on("/DOCU", []() {
- server.sendHeader("Location", String("/"), true);
- buttonDocu();
- server.send ( 302, "text/plain", "");
- });
-
- server.on("/LOG", []() {
- server.sendHeader("Location", String("/"), true);
- #if _DUSB>=2
- Serial.println(F("LOG button"));
- #endif
- buttonLog();
- server.send ( 302, "text/plain", "");
- });
-
-
- server.on("/EXPERT", []() {
- server.sendHeader("Location", String("/"), true);
- gwayConfig.expert = bool(1 - (int) gwayConfig.expert) ;
- server.send ( 302, "text/plain", "");
- });
-
-
- server.on("/SEEN", []() {
- server.sendHeader("Location", String("/"), true);
- #if _DUSB>=1
- Serial.println(F("SEEN button"));
- printSeen(listSeen);
- #endif
- buttonSeen();
- server.send ( 302, "text/plain", "");
- });
-
-
- server.on("/UPDATE=1", []() {
- #if A_OTA==1
- updateOtaa();
- #endif
- server.sendHeader("Location", String("/"), true);
- server.send ( 302, "text/plain", "");
- });
-
-
-
-
-
-
-
- Serial.print(F("WWW Server started on port "));
- Serial.println(A_SERVERPORT);
- return;
- }
- static void wifiConfig()
- {
- if (gwayConfig.expert) {
- String response="";
- response +="<h2>WiFi Config</h2>";
- response +="<table class=\"config_table\">";
- response +="<tr><th class=\"thead\">Parameter</th><th class=\"thead\">Value</th></tr>";
-
- response +="<tr><td class=\"cell\">WiFi host</td><td class=\"cell\">";
- #if ESP32_ARCH==1
- response +=WiFi.getHostname(); response+="</tr>";
- #else
- response +=wifi_station_get_hostname(); response+="</tr>";
- #endif
- response +="<tr><td class=\"cell\">WiFi SSID</td><td class=\"cell\">";
- response +=WiFi.SSID(); response+="</tr>";
-
- response +="<tr><td class=\"cell\">IP Address</td><td class=\"cell\">";
- printIP((IPAddress)WiFi.localIP(),'.',response);
- response +="</tr>";
- response +="<tr><td class=\"cell\">IP Gateway</td><td class=\"cell\">";
- printIP((IPAddress)WiFi.gatewayIP(),'.',response);
- response +="</tr>";
- response +="<tr><td class=\"cell\">NTP Server</td><td class=\"cell\">"; response+=NTP_TIMESERVER; response+="</tr>";
- response +="<tr><td class=\"cell\">LoRa Router</td><td class=\"cell\">"; response+=_TTNSERVER; response+="</tr>";
- response +="<tr><td class=\"cell\">LoRa Router IP</td><td class=\"cell\">";
- printIP((IPAddress)ttnServer,'.',response);
- response +="</tr>";
- #ifdef _THINGSERVER
- response +="<tr><td class=\"cell\">LoRa Router 2</td><td class=\"cell\">"; response+=_THINGSERVER;
- response += String() + ":" + _THINGPORT + "</tr>";
- response +="<tr><td class=\"cell\">LoRa Router 2 IP</td><td class=\"cell\">";
- printIP((IPAddress)thingServer,'.',response);
- response +="</tr>";
- #endif
- response +="</table>";
- server.sendContent(response);
- }
- }
- static void systemStatus()
- {
- if (gwayConfig.expert) {
- String response="";
- response +="<h2>System Status</h2>";
-
- response +="<table class=\"config_table\">";
- response +="<tr>";
- response +="<th class=\"thead\">Parameter</th>";
- response +="<th class=\"thead\">Value</th>";
- response +="<th colspan=\"2\" class=\"thead\">Set</th>";
- response +="</tr>";
-
- response +="<tr><td style=\"border: 1px solid black; width:120px;\">Gateway ID</td>";
- response +="<td class=\"cell\">";
- if (MAC_array[0]< 0x10) response +='0'; response +=String(MAC_array[0],HEX);
- if (MAC_array[1]< 0x10) response +='0'; response +=String(MAC_array[1],HEX);
- if (MAC_array[2]< 0x10) response +='0'; response +=String(MAC_array[2],HEX);
- response +="FFFF";
- if (MAC_array[3]< 0x10) response +='0'; response +=String(MAC_array[3],HEX);
- if (MAC_array[4]< 0x10) response +='0'; response +=String(MAC_array[4],HEX);
- if (MAC_array[5]< 0x10) response +='0'; response +=String(MAC_array[5],HEX);
- response+="</tr>";
-
- response +="<tr><td class=\"cell\">Free heap</td><td class=\"cell\">"; response+=ESP.getFreeHeap(); response+="</tr>";
- #if !defined ESP32_ARCH
- response +="<tr><td class=\"cell\">ESP speed</td><td class=\"cell\">"; response+=ESP.getCpuFreqMHz();
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"SPEED=80\"><button>80</button></a></td>";
- response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"SPEED=160\"><button>160</button></a></td>";
- response+="</tr>";
- response +="<tr><td class=\"cell\">ESP Chip ID</td><td class=\"cell\">"; response+=ESP.getChipId(); response+="</tr>";
- #endif
- response +="<tr><td class=\"cell\">OLED</td><td class=\"cell\">"; response+=OLED; response+="</tr>";
-
- #if _STATISTICS >= 1
- response +="<tr><td class=\"cell\">WiFi Setups</td><td class=\"cell\">"; response+=gwayConfig.wifis; response+="</tr>";
- response +="<tr><td class=\"cell\">WWW Views</td><td class=\"cell\">"; response+=gwayConfig.views; response+="</tr>";
- #endif
- response +="</table>";
- server.sendContent(response);
- }
- }
- static void interruptData()
- {
- if (gwayConfig.expert) {
- uint8_t flags = readRegister(REG_IRQ_FLAGS);
- uint8_t mask = readRegister(REG_IRQ_FLAGS_MASK);
- String response="";
-
- response +="<h2>System State and Interrupt</h2>";
-
- response +="<table class=\"config_table\">";
- response +="<tr>";
- response +="<th class=\"thead\">Parameter</th>";
- response +="<th class=\"thead\">Value</th>";
- response +="<th colspan=\"2\" class=\"thead\">Set</th>";
- response +="</tr>";
-
- response +="<tr><td class=\"cell\">_state</td>";
- response +="<td class=\"cell\">";
- switch (_state) {
- case S_INIT: response +="INIT"; break;
- case S_SCAN: response +="SCAN"; break;
- case S_CAD: response +="CAD"; break;
- case S_RX: response +="RX"; break;
- case S_TX: response +="TX"; break;
- default: response +="unknown"; break;
- }
- response +="</td></tr>";
-
- response +="<tr><td class=\"cell\">_STRICT_1CH</td>";
- response +="<td class=\"cell\">" ;
- response += String() + _STRICT_1CH;
- response +="</td></tr>";
- response +="<tr><td class=\"cell\">flags (8 bits)</td>";
- response +="<td class=\"cell\">0x";
- if (flags <16) response += "0";
- response +=String(flags,HEX); response+="</td></tr>";
-
- response +="<tr><td class=\"cell\">mask (8 bits)</td>";
- response +="<td class=\"cell\">0x";
- if (mask <16) response += "0";
- response +=String(mask,HEX); response+="</td></tr>";
-
- response +="<tr><td class=\"cell\">Re-entrant cntr</td>";
- response +="<td class=\"cell\">";
- response += String() + gwayConfig.reents;
- response +="</td></tr>";
- response +="<tr><td class=\"cell\">ntp call cntr</td>";
- response +="<td class=\"cell\">";
- response += String() + gwayConfig.ntps;
- response+="</td></tr>";
-
- response +="<tr><td class=\"cell\">ntpErr cntr</td>";
- response +="<td class=\"cell\">";
- response += String() + gwayConfig.ntpErr;
- response +="</td>";
- response +="<td colspan=\"2\" style=\"border: 1px solid black;\">";
- stringTime(gwayConfig.ntpErrTime, response);
- response +="</td>";
- response +="</tr>";
-
- response +="</table>";
-
- server.sendContent(response);
- }
- }
- static void websiteFooter()
- {
-
- server.sendContent(String() + "<br><br /><p style='font-size:10px'>Click <a href=\"/HELP\">here</a> to explain Help and REST options</p><br>");
- server.sendContent(String() + "</BODY></HTML>");
-
- server.sendContent(""); yield();
- }
- #endif
|