feat: sequences v2, driver frame sync and submodule updates

- Sequences v2, bridges and sim-controller changes from the working tree.
- Records the led-driver, led-tool and led-simulator commits above.
- Includes dmx-driver/ and graphify-out/.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Haiku 5.5 committed 2026-11-11 14:10:56 +13:00
1 parent 3f8f67823b
commit 50ca46fee6
657 files changed
+15818 -1107

No files matched your search

-99
View File
@@ -44,7 +44,6 @@
}
espnowSend.disabled = !espnowDevice.options.length;
showEspnowDevice();
showOtaTargets();
}
function espnowChanges() {
@@ -89,103 +88,5 @@
}
});
// Driver code: the session tools/driver_ota.py runs, one driver at a time
const otaTarget = document.getElementById('ota-target');
const otaStart = document.getElementById('ota-start');
const otaStatus = document.getElementById('ota-status');
function showOtaTargets() {
otaTarget.innerHTML = '<option value="all">All drivers</option>';
for (const [id, dev] of Object.entries(espnowDevices)) {
const opt = document.createElement('option');
opt.value = id;
opt.textContent = `${dev.name || id} (${id})`;
otaTarget.appendChild(opt);
}
otaStart.disabled = !Object.keys(espnowDevices).length;
}
async function otaRequest(action, mac, sess, params = '', body) {
// The controller does not URL-decode, so the query goes as it is
const res = await fetch(`/drivers/ota/${action}?mac=${mac}&sess=${sess}${params}`, {
method: 'POST',
headers: body ? { 'Content-Type': 'application/octet-stream' } : {},
body,
});
const data = await res.json();
if (!res.ok) throw new Error(data.error || `${action} failed (${res.status})`);
return data[mac] || { result: 'error', code: 'missing from reply' };
}
async function otaFile(path) {
const res = await fetch(`/static/driver/${path}`);
if (!res.ok) throw new Error(`${path}: ${res.status}`);
return res.arrayBuffer();
}
// Resolves once the driver acks the link again after its reset
async function otaWaitBack(id) {
const t0 = Date.now();
await new Promise((r) => setTimeout(r, 2000));
while (Date.now() - t0 < 30000) {
const st = await fetch('/devices/status').then((r) => r.json()).catch(() => ({}));
const age = st[id] ? st[id].last_ack_ms_ago : -1;
if (age >= 0 && age < Date.now() - t0) return true;
await new Promise((r) => setTimeout(r, 1000));
}
return false;
}
async function otaDriver(id, files, label) {
const mac = espnowDevices[id].address;
const sess = 1 + Math.floor(Math.random() * 0xffff);
let written = 0;
try {
for (let i = 0; i < files.length; i++) {
const f = files[i];
otaStatus.textContent = `${label}: ${i + 1}/${files.length} ${f.path}`;
const r = await otaRequest('file', mac, sess, `&path=${f.path}&sha=${f.sha}`, await otaFile(f.path));
if (r.result === 'error') throw new Error(`${f.path}: ${r.code}`);
if (r.result === 'written') written++;
}
} catch (e) {
await otaRequest('abort', mac, sess).catch(() => {});
throw e;
}
const r = await otaRequest('commit', mac, sess);
if (r.result !== 'ok') throw new Error(`commit: ${r.code || r.result}`);
if (!written) return `${label}: already up to date`;
otaStatus.textContent = `${label}: ${written} files written, waiting for the reset`;
const back = await otaWaitBack(id);
return `${label}: ${written} files written, ${back ? 'back online' : 'not back within 30 s'}`;
}
otaStart.addEventListener('click', async () => {
const ids = otaTarget.value === 'all' ? Object.keys(espnowDevices) : [otaTarget.value];
otaStart.disabled = true;
const done = [];
let failed = false;
try {
const res = await fetch('/static/driver/manifest.json');
if (!res.ok) throw new Error(`manifest: ${res.status}`);
const { files } = await res.json();
for (const id of ids) {
const label = espnowDevices[id].name || id;
try {
done.push(await otaDriver(id, files, label));
} catch (e) {
failed = true;
done.push(`${label}: ${errorMessage(e)}`);
}
}
} catch (e) {
failed = true;
done.push(errorMessage(e));
}
otaStatus.textContent = done.join('; ');
flash(failed ? 'Driver update failed.' : 'Driver update finished.', failed);
otaStart.disabled = false;
});
loadEspnowDevices().catch((e) => flash(e.message, true));
})();