From b47a868db3b1e8e1f4ee79066ea6067071e05757 Mon Sep 17 00:00:00 2001 From: diijkstra <16804536+diijkstra@users.noreply.github.com> Date: Sun, 15 Mar 2026 12:18:02 +0100 Subject: [PATCH] Web: Handle missing LOS pin When device has no LOS pin and module has no extended status, the RX LOS value will not be shown. When both are present, the equality check is performed. When only one is present, the present value will be shown. json from the switch, will still contain the field, but can be null for when pin is not available. --- html/main.js | 51 +++++++++++++++++++++++------------------------ httpd/page_impl.c | 6 +++++- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/html/main.js b/html/main.js index badd491..116384d 100644 --- a/html/main.js +++ b/html/main.js @@ -90,11 +90,12 @@ function update(callback) { var iHTML = "
| Link speed | : | " + linkS[p.link + 1] + " |
| Vendor | : | " + p.sfp_vendor + " |
| Model | : | " + p.sfp_model + " |
| Serial | : | " + p.sfp_serial + " |
| Temp | : | " + (Number(p.sfp_temp) >> 8) + "." + ((Number(p.sfp_temp) & 0xff)/256.0 * 100).toFixed(0) + " ℃ |
| Vcc | : | " + (Number(p.sfp_vcc) / 10000.0).toFixed(2) + " V |
| TX-Fault | : | " + (Boolean(Number(p.sfp_state) & 0x4)) + " |
| TX-Power | : | " + (Number(p.sfp_txpower) / 10.0).toFixed(0) + " mW |
| RX-Power | : | " + (Number(p.sfp_rxpower) / 10.0).toFixed(0) + " mW |
| RX-LOS | : | "
- var rx_los_pin = Boolean(Number(p.sfp_los));
- if (p.sfp_options & 0x40) {
- var rx_los_module = Boolean(Number(p.sfp_state) & 0x2);
- if (rx_los_module != rx_los_pin) {
- iHTML += "pin=" + rx_los_pin + " "; - iHTML += "mod=" + rx_los_module + " "; - iHTML += "❗❗❗❗"; - } else { - iHTML += rx_los_pin; - } - } else { - iHTML += Boolean(Number(p.sfp_los)); + // Not all devices & modules have LOS pin... + const rx_los_pin = p.sfp_los !== null ? Boolean(Number(p.sfp_los)) : null; + const rx_los_module = hasExtendedStatus ? Boolean(Number(p.sfp_state) & 0x2) : null; + if (rx_los_module !== null || rx_los_pin !== null) { + iHTML += ` |
| RX-LOS | : | ${rxLosHTML(rx_los_pin, rx_los_module)} |