mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-11-20 15:52:12 +01:00
Show the fixed radio pins as read-only in the web UI
On the integrated-radio board the firmware replaces any radio pins a client saves with the board's wiring, yet the web UI let the user edit them and reported success. The radio settings now carry fixedPins (wire key fx), sent only where the radio is wired to the board. The web UI disables the six pin selects, shows "Radio wiring is fixed on this board." and skips the pin duplicate and boot-pin checks for them. Generic builds do not send the field, so their behaviour is unchanged, and applyBoardPins() stays as the safety net for old configs and imports. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
31eda550b9
commit
2b3d556729
13 changed files with 109 additions and 15 deletions
|
|
@ -933,6 +933,7 @@
|
|||
<label for="selTransRXPin">RX</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="divRadioPinsFixed" style="display:none;font-size:12px;margin:-14px 0 14px 0;white-space:normal;">Radio wiring is fixed on this board.</div>
|
||||
<div id="divRadioBootPins" style="display:none;color:#e65100;font-size:12px;margin:-14px 0 14px 0;white-space:normal;"></div>
|
||||
<div class="field-group" style="display:inline-block;width:auto;min-width:247px;margin-top:-20px;vertical-align:top;">
|
||||
<div class="field-group">
|
||||
|
|
|
|||
|
|
@ -1973,13 +1973,16 @@ class Somfy {
|
|||
let config = ProtoViews.radio(proto.schema, radio);
|
||||
ui.toElement(document.getElementById('divTransceiverSettings'), { transceiver: { config: config } });
|
||||
document.getElementById('divRadioError').style.display = config.radioInit ? 'none' : '';
|
||||
this.radioPinsFixed = !!config.fixedPins;
|
||||
ProtoViews.showRadioPins(document, this.radioPinsFixed);
|
||||
this.checkBootPins();
|
||||
});
|
||||
}
|
||||
// Warns of radio pins that can stop the board booting (issue #34).
|
||||
checkBootPins() {
|
||||
let trans = ui.fromElement(document.getElementById('divTransceiverSettings')).transceiver;
|
||||
let warnings = BootPins.radioWarnings(chipModel(), trans.config);
|
||||
// The board's wiring is not the user's to move, so there is nothing to warn of.
|
||||
let warnings = this.radioPinsFixed ? [] : BootPins.radioWarnings(chipModel(), trans.config);
|
||||
let div = document.getElementById('divRadioBootPins');
|
||||
div.innerText = warnings.join('\n');
|
||||
div.style.display = warnings.length > 0 ? '' : 'none';
|
||||
|
|
@ -1993,7 +1996,7 @@ class Somfy {
|
|||
ui.errorMessage('You must select a radio type.');
|
||||
valid = false;
|
||||
}
|
||||
// Check to make sure no pins were duplicated and defined
|
||||
// Check to make sure no pins were duplicated and defined. The board's own wiring is not checked.
|
||||
if (valid) {
|
||||
let fnValDup = (o, name) => {
|
||||
let val = o[name];
|
||||
|
|
@ -2022,12 +2025,12 @@ class Somfy {
|
|||
}
|
||||
return true;
|
||||
};
|
||||
if (valid) valid = fnValDup(trans.config, 'SCKPin');
|
||||
if (valid) valid = fnValDup(trans.config, 'CSNPin');
|
||||
if (valid) valid = fnValDup(trans.config, 'MOSIPin');
|
||||
if (valid) valid = fnValDup(trans.config, 'MISOPin');
|
||||
if (valid) valid = fnValDup(trans.config, 'TXPin');
|
||||
if (valid) valid = fnValDup(trans.config, 'RXPin');
|
||||
if (valid && !this.radioPinsFixed) valid = fnValDup(trans.config, 'SCKPin');
|
||||
if (valid && !this.radioPinsFixed) valid = fnValDup(trans.config, 'CSNPin');
|
||||
if (valid && !this.radioPinsFixed) valid = fnValDup(trans.config, 'MOSIPin');
|
||||
if (valid && !this.radioPinsFixed) valid = fnValDup(trans.config, 'MISOPin');
|
||||
if (valid && !this.radioPinsFixed) valid = fnValDup(trans.config, 'TXPin');
|
||||
if (valid && !this.radioPinsFixed) valid = fnValDup(trans.config, 'RXPin');
|
||||
if (valid) {
|
||||
sendOp('saveSettings', ProtoViews.radioSave(trans.config), (err) => {
|
||||
if (err) ui.serviceError(err);
|
||||
|
|
|
|||
|
|
@ -51,10 +51,20 @@ class ProtoViews {
|
|||
static radioSave(config) {
|
||||
const fields = { section: 'radio', bitLength: config.type };
|
||||
for (const name of ProtoViews.SETTINGS.radio) {
|
||||
if (name !== 'bitLength' && name !== 'radioInit') fields[name] = config[name];
|
||||
if (name !== 'bitLength' && !ProtoViews.RADIO_SHOWN.includes(name)) fields[name] = config[name];
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
// Where the radio is wired to the board (config.fixedPins) its six pins
|
||||
// can't be changed: the pin selects are disabled and the note shown.
|
||||
static showRadioPins(doc, fixed) {
|
||||
for (const id of ProtoViews.RADIO_PIN_SELECTS) {
|
||||
const el = doc.getElementById(id);
|
||||
if (el) el.disabled = !!fixed;
|
||||
}
|
||||
const note = doc.getElementById(ProtoViews.RADIO_PINS_NOTE);
|
||||
if (note) note.style.display = fixed ? '' : 'none';
|
||||
}
|
||||
// An op's refusal as the UI's error box shows it. A shade whose settings
|
||||
// don't add up carries the reason's number, which the errors table
|
||||
// describes.
|
||||
|
|
@ -66,6 +76,10 @@ class ProtoViews {
|
|||
}
|
||||
ProtoViews.WIFI = ['ssid', 'hasPassphrase', 'roaming', 'hidden'];
|
||||
ProtoViews.ETHERNET = ['boardType', 'phyType', 'CLKMode', 'phyAddress', 'PWRPin', 'MDCPin', 'MDIOPin'];
|
||||
// The radio fields the device only sends.
|
||||
ProtoViews.RADIO_SHOWN = ['radioInit', 'fixedPins'];
|
||||
ProtoViews.RADIO_PIN_SELECTS = ['selTransSCKPin', 'selTransCSNPin', 'selTransMOSIPin', 'selTransMISOPin', 'selTransTXPin', 'selTransRXPin'];
|
||||
ProtoViews.RADIO_PINS_NOTE = 'divRadioPinsFixed';
|
||||
ProtoViews.IP = ['dhcp', 'ip', 'gateway', 'subnet', 'dns1', 'dns2'];
|
||||
// The fields of each settings section, as getSettings sends them
|
||||
// (src/DeviceOps.cpp).
|
||||
|
|
@ -75,6 +89,6 @@ ProtoViews.SETTINGS = {
|
|||
mqtt: ['enabled', 'pubDisco', 'protocol', 'hostname', 'port', 'username', 'hasPassword', 'rootTopic', 'discoTopic'],
|
||||
security: ['securityType', 'username', 'hasPassword', 'hasPin'],
|
||||
radio: ['bitLength', 'proto', 'enabled', 'TXPin', 'RXPin', 'SCKPin', 'MOSIPin', 'MISOPin', 'CSNPin', 'frequency', 'rxBandwidth',
|
||||
'deviation', 'txPower', 'noiseDetection', 'radioInit']
|
||||
'deviation', 'txPower', 'noiseDetection', 'radioInit', 'fixedPins']
|
||||
};
|
||||
if (typeof module !== 'undefined' && module.exports) module.exports = { ProtoViews };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue