1
mirror of https://github.com/rvdbreemen/OTGW-firmware synced 2024-11-16 04:33:49 +01:00

small fixes, template firmware page

This commit is contained in:
Robert van den Breemen 2021-02-14 21:03:36 +01:00
parent 3f8608467f
commit b74c945d58
8 changed files with 78 additions and 26 deletions

View File

@ -132,7 +132,7 @@ void apifirmwarefilelist() {
}
}
s += sprintf(s, "]\n");
DebugTf("filelist response: [%s]\n", buffer);
DebugTf("filelist response: [%s]\r\n", buffer);
httpServer.send(200, "text/json", buffer);
}

View File

@ -77,8 +77,8 @@ int16_t settingMQTTbrokerPort = 1883;
String settingMQTTuser = "";
String settingMQTTpasswd = "";
String settingMQTTtopTopic = "OTGW";
bool settingNTPenable = false;
String settingNTPtimezone = "NL"; //Default
bool settingNTPenable = true;
String settingNTPtimezone = "Europe/Amsterdam"; //Default
//Now load network suff
#include "networkStuff.h"

View File

@ -20,6 +20,7 @@
<div id="displayMainPage" style="display:none">
<div class="nav-container">
<div class='nav-left'>
<a id='tabPICflash' class='nav-item tabButton' style="background: lightblue;">PIC firmware</a>
<a id='tabDeviceInfo' class='nav-item tabButton' style="background: lightblue;">Device Info</a>
<a id='M_FSexplorer' class='nav-img'> <img src='/FSexplorer.png' alt='FSexplorer'></a>
<a id='tabSettings' class='nav-img'> <img src='/settings.png' alt='Settings'></a>
@ -30,6 +31,16 @@
<div id="waiting">Wait for it...</div>
</div>
</div>
<div id="displayPICflash" style="display:none">
<div class="nav-container">
<div class='nav-left'>
<a id='F_back' class='nav-item tabButton' style="background: lightblue;">Back</a>
<a id='F_FSexplorer' class='nav-img'> <img src='/FSexplorer.png' alt='FSexplorer'></a>
</div>
</div>
<br/>
<div id="displayPICpage"></div>
</div>
<div id="displayDeviceInfo" style="display:none">
<div class="nav-container">
<div class='nav-left'>
@ -62,7 +73,7 @@
<div id="message" class="bottom left-0">-</div>
<script>
window.onload=bootsTrapMain;
window.onload=initMainPage;
</script>
</body>

View File

@ -15,7 +15,7 @@
let needReload = true;
refreshDevTime();
window.onload=bootsTrapMain;
window.onload=initMainPage;
window.onfocus = function() {
if (needReload) {
window.location.reload(true);
@ -27,8 +27,8 @@
var timeupdate = setInterval(function(){refreshDevTime(); }, 1000); //delay is in milliseconds
//============================================================================
function bootsTrapMain() {
console.log("bootsTrapMain()");
function initMainPage() {
console.log("initMainPage()");
document.getElementById('M_FSexplorer').addEventListener('click',function()
{ console.log("newTab: goFSexplorer");
@ -42,6 +42,10 @@
{ console.log("newTab: goFSexplorer");
location.href = "/FSexplorer";
});
document.getElementById('F_FSexplorer').addEventListener('click',function()
{ console.log("newTab: goFSexplorer");
location.href = "/FSexplorer";
});
document.getElementById('D_back').addEventListener('click',function()
{ console.log("newTab: goBack");
location.href = "/";
@ -50,8 +54,13 @@
{ console.log("newTab: goBack");
location.href = "/";
});
document.getElementById('F_back').addEventListener('click',function()
{ console.log("newTab: goBack");
location.href = "/";
});
document.getElementById('S_saveSettings').addEventListener('click',function(){saveSettings();});
document.getElementById('tabDeviceInfo').addEventListener('click',function(){deviceinfoPage();});
document.getElementById('tabPICflash').addEventListener('click',function(){firmwarePage();});
document.getElementById('tabSettings').addEventListener('click',function(){settingsPage();});
needReload = false;
refreshDevInfo();
@ -61,8 +70,21 @@
document.getElementById("displayMainPage").style.display = "block";
document.getElementById("displaySettingsPage").style.display = "none";
document.getElementById("displayDeviceInfo").style.display = "none";
document.getElementById("displayPICflash").style.display = "none";
} // bootsTrapMain()
} // initMainPage()
function firmwarePage()
{
clearInterval(tid);
refreshDevTime();
document.getElementById("displayMainPage").style.display = "none";
document.getElementById("displaySettingsPage").style.display = "none";
document.getElementById("displayDeviceInfo").style.display = "none";
var firmwarePage = document.getElementById("displayPICflash");
refreshFirmware();
document.getElementById("displayPICflash").style.display = "block";
} // deviceinfoPage()
function deviceinfoPage()
{
@ -70,18 +92,20 @@
refreshDevTime();
document.getElementById("displayMainPage").style.display = "none";
document.getElementById("displaySettingsPage").style.display = "none";
document.getElementById("displayPICflash").style.display = "none";
var deviceinfoPage = document.getElementById("deviceinfoPage");
refreshDeviceInfo();
document.getElementById("displayDeviceInfo").style.display = "block";
} // settingsPage()
} // deviceinfoPage()
function settingsPage()
{
clearInterval(tid);
refreshDevTime();
document.getElementById("displayMainPage").style.display = "none";
document.getElementById("displayDeviceInfo").style.display = "none";
document.getElementById("displayDeviceInfo").style.display = "none";
document.getElementById("displayPICflash").style.display = "none";
var settingsPage = document.getElementById("settingsPage");
refreshSettings();
document.getElementById("displaySettingsPage").style.display = "block";
@ -113,7 +137,21 @@
} // refreshDevTime()
function refreshFirmware(){
console.log("refreshFirmware() .. "+APIGW+"firmwarefilelist");
fetch(APIGW+"firmwarefilelist")
.then(response => response.json())
.then(data => {
console.log(data);
console.log("parsed .., data is ["+ JSON.stringify(data)+"]");
})
.catch(function(error) {
var p = document.createElement('p');
p.appendChild(
document.createTextNode('Error: ' + error.message)
);
});
}
//============================================================================
function refreshDevInfo()
{
@ -542,11 +580,11 @@
,[ "wifirssi", "Wifi Receive Power (dB)"]
,[ "lastreset", "Last Reset Reason"]
,[ "mqttconnected", "MQTT Connected"]
,[ "mqttenable", "MQTT Enable"]
,[ "mqttenabled", "MQTT Enable"]
,[ "ntpenable", "NTP Enable"]
,[ "ntptimezone", "NTP Timezone"]
,[ "uptime", "Uptime since boot"]
,[ "bootcount", "Nr. Reboots"]
];
/*

View File

@ -161,7 +161,7 @@ void startNTP(){
DebugTf("GeoIP located your timezone to be: %s\r\n", CSTR(settingNTPtimezone));
} else {
DebugTln(errorString());
settingNTPtimezone = "NL";
settingNTPtimezone = "PICFIRMWARE";
}
} else {
if (myTZ.setLocation(settingNTPtimezone)){
@ -169,7 +169,7 @@ void startNTP(){
settingNTPtimezone = myTZ.getTimezoneName();
} else {
DebugTln(errorString());
settingNTPtimezone = "NL";
settingNTPtimezone = "Europe/Amsterdam";
}
}
// }

View File

@ -267,8 +267,7 @@ void sendDeviceInfo()
sendNestedJsonObj("author", "Robert van den Breemen");
sendNestedJsonObj("fwversion", _FW_VERSION);
sendNestedJsonObj("picfwversion", OTGWSerial.firmwareVersion());
sendNestedJsonObj("picfwversion", CSTR(sPICfwversion));
snprintf(cMsg, sizeof(cMsg), "%s %s", __DATE__, __TIME__);
sendNestedJsonObj("compiled", cMsg);
sendNestedJsonObj("hostname", CSTR(settingHostname));
@ -277,8 +276,8 @@ void sendDeviceInfo()
sendNestedJsonObj("freeheap", ESP.getFreeHeap());
sendNestedJsonObj("maxfreeblock", ESP.getMaxFreeBlockSize());
sendNestedJsonObj("chipid", CSTR(String( ESP.getChipId(), HEX )));
sendNestedJsonObj("coreversion", String( ESP.getCoreVersion() ).c_str() );
sendNestedJsonObj("sdkversion", String( ESP.getSdkVersion() ).c_str());
sendNestedJsonObj("coreversion", CSTR(ESP.getCoreVersion()) );
sendNestedJsonObj("sdkversion", ESP.getSdkVersion());
sendNestedJsonObj("cpufreq", ESP.getCpuFreqMHz());
sendNestedJsonObj("sketchsize", formatFloat( (ESP.getSketchSize() / 1024.0), 3));
sendNestedJsonObj("freesketchspace", formatFloat( (ESP.getFreeSketchSpace() / 1024.0), 3));
@ -309,13 +308,16 @@ void sendDeviceInfo()
"ESP8266_ESP12"
#endif
);
sendNestedJsonObj("ssid", WiFi.SSID().c_str());
sendNestedJsonObj("ssid", CSTR(WiFi.SSID()));
sendNestedJsonObj("wifirssi", WiFi.RSSI());
sendNestedJsonObj("mqttconnected", String(CBOOLEAN(statusMQTTconnection)));
sendNestedJsonObj("ntpenabled", String(CBOOLEAN(settingNTPenable)));
sendNestedJsonObj("ntptimezone", CSTR(settingNTPtimezone));
sendNestedJsonObj("uptime", upTime());
sendNestedJsonObj("lastreset", lastReset);
sendNestedJsonObj("bootcount", rebootCount);
httpServer.sendContent("\r\n]}\r\n");
} // sendDeviceInfo()

View File

@ -84,6 +84,7 @@ void readSettings(bool show)
if (settingMQTTtopTopic.length()==0) settingMQTTtopTopic = _HOSTNAME;
settingNTPenable = doc["NTPenable"];
settingNTPtimezone = doc["NTPtimezone"].as<String>();
if (settingNTPtimezone=="null") settingNTPtimezone = "Europe/Amsterdam"; //default to amsterdam timezone
// Close the file (Curiously, File's destructor doesn't close the file)
file.close();

View File

@ -2,13 +2,13 @@
#define _VERSION_MAJOR 0
#define _VERSION_MINOR 7
#define _VERSION_PATCH 6
#define _VERSION_BUILD 619
#define _VERSION_BUILD 624
//#define _VERSION_PRERELEASE beta //uncomment to define prerelease labels: alpha - beta - rc
#define _VERSION_DATE "14-02-2021"
#define _VERSION_TIME "19:22:28"
#define _VERSION_TIME "20:55:09"
#define _SEMVER_CORE "0.7.6"
#define _SEMVER_BUILD "0.7.6+619"
#define _SEMVER_FULL "0.7.6+619"
#define _SEMVER_BUILD "0.7.6+624"
#define _SEMVER_FULL "0.7.6+624"
#define _SEMVER_NOBUILD "0.7.6 (14-02-2021)"
#define _VERSION "0.7.6+619 (14-02-2021)"
#define _VERSION "0.7.6+624 (14-02-2021)"
//The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver