feat(sfm): the page's Call Home tab by serial -- state and audited On / Off (phase 4)

device_routing.js (Node-tested): call_home_state / call_home_on / call_home_off
routes (serial required); controlsFor gains callHomeChange (by serial, a
confirmed Series 3 or 4) and callHomeRead now covers a Series 4 by serial;
serialPanes gains callHomeForm / callHomeBox; callHomeRows renders the switch
(On / Off / 'Unknown (byte 5 = 0xNN)'), dial string and series;
changeErrorText takes the whole label ('Start monitoring', 'Enable call-home').

sfm_webapp.js: by serial the Call Home tab hides the legacy multi-field form
(Series 3 by host only) and shows the unit's switch with On / Off.  Each asks
confirm(), sends one audited change, reports it with changeSummary /
changeErrorText, then re-reads quietly so the change's own result stays on
screen.  A different unit's switch is never left showing.  The new buttons are
wired with addEventListener, not onclick= (no inline JS).

Checked in jsdom against the real page: placeholder, read, Off (confirm, the
disable route, 'confirmed -- enabled -> disabled'), a serial edit clearing it,
legacy mode unchanged, no script errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-02 17:05:00 -05:00
1 parent 06fa56db09
commit 84c142f36c
4 files changed
+151 -23

No files matched your search

+25 -9
View File
@@ -44,6 +44,9 @@ const DEVICE_ROUTES = {
slow_drip: ['POST', '/device/stop_monitoring_slow_drip', false],
call_home_read: ['GET', '/device/call_home', false],
call_home_write: ['POST', '/device/call_home', false],
call_home_state: ['GET', '/device/call_home/state', true],
call_home_on: ['POST', '/device/call_home/enable', true],
call_home_off: ['POST', '/device/call_home/disable', true],
config_write: ['POST', '/device/config', false],
event_waveform: ['GET', '/device/event/{index}/waveform', false],
event_file: ['GET', '/device/event/{index}/blastware_file', false],
@@ -82,10 +85,13 @@ function controlsFor(unit) {
startStop: serialMode && (series === 3 || series === 4),
hangup: series === 4,
diagnostics: series === 3,
callHomeRead: series === 3,
// by host, the legacy read is Series 3's; by serial, both series (phase 4)
callHomeRead: series === 3 || (serialMode && series === 4),
callHomeChange: serialMode && (series === 3 || series === 4),
configWrite: false,
callHomeWrite: false,
reasons: { configWrite: 'Coming in phase 5 (#46)', callHomeWrite: 'Coming in phase 4' },
reasons: { configWrite: 'Coming in phase 5 (#46)',
callHomeWrite: 'By serial: use Call-home On / Off (audited). Other call-home fields wait for the THOR round.' },
};
}
@@ -178,18 +184,28 @@ function deviceErrorText(status, body, unit, statusText) {
return status === 504 && !(body || {}).sent && unit && unit.host ? `${text} — ${NO_REPLY_HINT}` : text;
}
// A start/stop that went out (or may have) is not "failed": its body carries
// `sent` (ChangeUnconfirmed, bench finding #10), and its message says what the
// unit did and names the audit record.
function changeErrorText(verb, status, body, unit, statusText) {
if ((body || {}).sent) return `${verb} monitoring not confirmed: ${errorDetail(body, statusText)}`;
return `${verb} monitoring failed: ${deviceErrorText(status, body, unit, statusText)}`;
// A change that went out (or may have) is not "failed": its body carries `sent`
// (ChangeUnconfirmed, bench finding #10), and its message says what the unit
// did and names the audit record. `label` is the whole name: "Start monitoring",
// "Enable call-home".
function changeErrorText(label, status, body, unit, statusText) {
if ((body || {}).sent) return `${label} not confirmed: ${errorDetail(body, statusText)}`;
return `${label} failed: ${deviceErrorText(status, body, unit, statusText)}`;
}
// By serial, settings are read-only until phase 5: no empty legacy edit form or
// legacy tables, and the settings box shows from the start (#6, #12).
function serialPanes(bySerial, settingsRead) {
return { configForm: !bySerial, settingsBox: bySerial, settingsPlaceholder: bySerial && !settingsRead,
legacyDeviceTables: !bySerial };
legacyDeviceTables: !bySerial, callHomeForm: !bySerial, callHomeBox: bySerial };
}
// A unit's call-home switch, read by serial (phase 4). `enabled` null is an
// enable byte never measured -- shown with the byte, never as On or Off.
function callHomeRows(state) {
const s = state || {};
const sw = s.enabled === true ? 'On' : s.enabled === false ? 'Off'
: `Unknown (byte 5 = ${(s.detail || {}).byte5 ?? '?'})`;
return [['Call-home', sw], ['Dial string', s.dial_string || '—'], ['Series', s.series]];
}
/* </device-routing> */