Prepare for LAN adapter settings

* Fix radio pin settings where the old values were being set to the config then reloaded.  This meant that the new pin settings were not being saved.
* Disable the radio when the radio cannot be configured.  This stops the microcontroller from hitting a hard halt and allows the pin settings to be changed.
* Add ethernet configuration options in preparation for boards with ethernet connections.
This commit is contained in:
Robert Strouse 2023-02-23 17:41:58 -08:00
parent 028cce5d8f
commit 7f5463250f
10 changed files with 255 additions and 57 deletions

View file

@ -3,13 +3,14 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="main.css?v=1.2.2" type="text/css" />
<link rel="stylesheet" href="icons.css?v=1.2.2" type="text/css" />
<link rel="stylesheet" href="main.css?v=1.2.3" type="text/css" />
<link rel="stylesheet" href="icons.css?v=1.2.3" type="text/css" />
<link rel="icon" type="image/png" href="favicon.png" />
<script type="text/javascript" src="index.js?v=1.2.2"></script>
<script type="text/javascript" src="index.js?v=1.2.3"></script>
</head>
<body>
<div id="divContainer" class="container" style="user-select:none;position:relative;">
<div id="divRadioError" style="text-align:center;background:gainsboro;color:gray;margin-bottom:7px;text-transform:uppercase;font-weight:bold;padding:4px;border-radius:5px;">Radio Not Initialized</div>
<h1 style="text-align: center;"><span>ESPSomfy RTS</span><span class="button-outline" onclick="general.toggleConfig();" style="float:right;font-size:1.25rem;display:inline-block;vertical-align:middle;width:38px;height:38px;position:relative;padding-top:4px;"><span style="vertical-align:middle;clear:both;text-align:center;display:inline-block;"><i id="icoConfig" class="icss-gear" style=""></i></span></span></h1>
<div id="divConfigPnl" style="display:none;">
<div style="margin-top:-10px;text-align:center;font-size:12px;">
@ -324,7 +325,9 @@
// Only load the networks if we need them.
//if(new Date().getTime() - parseInt(document.getElementById('divAps').getAttribute('data-lastloaded'), 10) > 60000)
// wifi.loadAPs();
wifi.loadNetwork();
}
let grp = document.getElementById(tab.getAttribute('data-grpid'));
if (typeof grp !== 'undefined' && grp) grp.style.display = '';
}

View file

@ -328,7 +328,7 @@ async function reopenSocket() {
await initSockets();
}
class General {
appVersion = 'v1.2.2';
appVersion = 'v1.2.3';
reloadApp = false;
async init() {
this.setAppVersion();
@ -555,6 +555,21 @@ class Wifi {
init() {
document.getElementById("divNetworkStrength").innerHTML = this.displaySignal(-100);
};
loadNetwork() {
let overlay = waitMessage(document.getElementById('fsWiFiSettings'));
getJSON('/networksettings', (err, settings) => {
overlay.remove();
console.log(settings);
if (err) {
serviceError(document.getElementById('fsWiFiSettings'), err);
}
else {
document.getElementById('fldSsid').value = settings.wifi.ssid;
document.getElementById('fldPassphrase').value = settings.wifi.passphrase;
}
});
};
async loadAPs() {
if (document.getElementById('btnScanAPs').classList.contains('disabled')) return;
document.getElementById('divAps').innerHTML = '<div style="display:flex;justify-content:center;align-items:center;"><div class="lds-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>';
@ -657,7 +672,7 @@ class Somfy {
this.loadPins('inout', document.getElementById('selTransMOSIPin'));
this.loadPins('inout', document.getElementById('selTransMISOPin'));
this.loadPins('out', document.getElementById('selTransTXPin'));
this.loadPins('inout', document.getElementById('selTransRXPin'));
this.loadPins('input', document.getElementById('selTransRXPin'));
this.loadSomfy();
}
async loadSomfy() {
@ -685,6 +700,13 @@ class Somfy {
document.getElementById('spanDeviation').innerText = (Math.round(somfy.transceiver.config.deviation * 100) / 100).fmt('#,##0.00');
document.getElementById('slidDeviation').value = Math.round(somfy.transceiver.config.deviation * 100);
document.getElementsByName('enableRadio')[0].checked = somfy.transceiver.config.enabled;
if (somfy.transceiver.config.radioInit) {
document.getElementById('divRadioError').style.display = 'none';
}
else {
document.getElementById('divRadioError').style.display = '';
}
let tx = document.getElementById('slidTxPower');
let lvls = [-30, -20, -15, -10, -6, 0, 5, 7, 10, 11, 12];
@ -756,10 +778,21 @@ class Somfy {
if (valid) valid = fnValDup(obj, 'RXPin');
if (valid) {
let overlay = waitMessage(document.getElementById('fsSomfySettings'));
putJSON('/saveRadio', { config: obj }, (err, response) => {
putJSON('/saveRadio', { config: obj }, (err, trans) => {
overlay.remove();
document.getElementById('btnSaveRadio').classList.remove('disabled');
console.log(response);
if (err) {
serviceError(document.getElementById('fsSomfySettings'), err);
}
else {
document.getElementById('btnSaveRadio').classList.remove('disabled');
if (trans.config.radioInit) {
document.getElementById('divRadioError').style.display = 'none';
}
else {
document.getElementById('divRadioError').style.display = '';
}
}
console.log(trans);
});
}
}
@ -1559,6 +1592,7 @@ class Firmware {
prog.style.setProperty('--progress', `${pct}%`);
prog.setAttribute('data-progress', `${pct}%`);
console.log(evt);
};
xhr.onload = function () {
console.log('File upload load called');