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:
1 parent
3f8f67823b
commit
50ca46fee6
657 files changed
+15818
-1107
No files matched your search
@@ -301,9 +301,18 @@ function applyTransportVisibility(transport) {
|
||||
if (drvWrap) drvWrap.hidden = !isWifi;
|
||||
}
|
||||
|
||||
function readMaxBrightness(id) {
|
||||
const el = document.getElementById(id);
|
||||
if (!el || el.value === '') return null;
|
||||
const n = parseInt(el.value, 10);
|
||||
return Number.isNaN(n) ? null : Math.max(0, Math.min(255, n));
|
||||
}
|
||||
|
||||
function getDriverConfigPushFields(transport, registryName) {
|
||||
const push = {};
|
||||
if (registryName) push.name = registryName;
|
||||
const mb = readMaxBrightness('edit-device-max-brightness');
|
||||
if (mb != null) push.max_brightness = mb;
|
||||
if (transport === 'wifi') {
|
||||
const nl = document.getElementById('edit-device-wifi-num-leds');
|
||||
const co = document.getElementById('edit-device-wifi-color-order');
|
||||
@@ -358,6 +367,8 @@ function collectDeviceEditPayload() {
|
||||
address,
|
||||
output_brightness,
|
||||
};
|
||||
const maxB = readMaxBrightness('edit-device-max-brightness');
|
||||
if (maxB != null) payload.max_brightness = maxB;
|
||||
if (transport === 'wifi') {
|
||||
const dn = document.getElementById('edit-device-wifi-driver-name');
|
||||
const nl = document.getElementById('edit-device-wifi-num-leds');
|
||||
@@ -652,6 +663,17 @@ function openEditDeviceModal(devId, dev) {
|
||||
obr.value = String(bv);
|
||||
if (obv) obv.textContent = String(bv);
|
||||
}
|
||||
const mbr = document.getElementById('edit-device-max-brightness');
|
||||
const mbv = document.getElementById('edit-device-max-brightness-value');
|
||||
if (mbr) {
|
||||
let mv = 255;
|
||||
if (dev && dev.max_brightness != null && dev.max_brightness !== '') {
|
||||
const n = parseInt(String(dev.max_brightness), 10);
|
||||
if (!Number.isNaN(n)) mv = Math.max(0, Math.min(255, n));
|
||||
}
|
||||
mbr.value = String(mv);
|
||||
if (mbv) mbv.textContent = String(mv);
|
||||
}
|
||||
void renderEditDeviceGroups(devId);
|
||||
modal.classList.add('active');
|
||||
}
|
||||
@@ -812,6 +834,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
|
||||
const devMaxBr = document.getElementById('edit-device-max-brightness');
|
||||
const devMaxBrVal = document.getElementById('edit-device-max-brightness-value');
|
||||
if (devMaxBr && devMaxBrVal) {
|
||||
devMaxBr.addEventListener('input', () => {
|
||||
devMaxBrVal.textContent = devMaxBr.value;
|
||||
});
|
||||
}
|
||||
|
||||
const transportEdit = document.getElementById('edit-device-transport');
|
||||
if (transportEdit) {
|
||||
transportEdit.addEventListener('change', () => {
|
||||
|
||||
@@ -146,6 +146,11 @@ function collectGroupEditPayload() {
|
||||
const nb = parseInt(gob.value, 10);
|
||||
if (!Number.isNaN(nb)) payload.output_brightness = Math.max(0, Math.min(255, nb));
|
||||
}
|
||||
const gmb = document.getElementById('edit-group-max-brightness');
|
||||
if (gmb && gmb.value !== '') {
|
||||
const nm = parseInt(gmb.value, 10);
|
||||
if (!Number.isNaN(nm)) payload.max_brightness = Math.max(0, Math.min(255, nm));
|
||||
}
|
||||
return { gid, payload };
|
||||
}
|
||||
|
||||
@@ -198,6 +203,17 @@ function loadWifiFieldsFromGroup(g) {
|
||||
gob.value = String(bv);
|
||||
if (gobv) gobv.textContent = String(bv);
|
||||
}
|
||||
const gmb = document.getElementById('edit-group-max-brightness');
|
||||
const gmbv = document.getElementById('edit-group-max-brightness-value');
|
||||
if (gmb) {
|
||||
let mv = 255;
|
||||
if (g && g.max_brightness != null && g.max_brightness !== '') {
|
||||
const n = parseInt(String(g.max_brightness), 10);
|
||||
if (!Number.isNaN(n)) mv = Math.max(0, Math.min(255, n));
|
||||
}
|
||||
gmb.value = String(mv);
|
||||
if (gmbv) gmbv.textContent = String(mv);
|
||||
}
|
||||
}
|
||||
|
||||
async function openEditGroupModal(groupId, groupDoc) {
|
||||
@@ -435,6 +451,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
|
||||
const grpMaxBr = document.getElementById('edit-group-max-brightness');
|
||||
const grpMaxBrVal = document.getElementById('edit-group-max-brightness-value');
|
||||
if (grpMaxBr && grpMaxBrVal) {
|
||||
grpMaxBr.addEventListener('input', () => {
|
||||
grpMaxBrVal.textContent = grpMaxBr.value;
|
||||
});
|
||||
}
|
||||
|
||||
const editIdentifyBtn = document.getElementById('edit-group-identify-btn');
|
||||
if (editIdentifyBtn) {
|
||||
editIdentifyBtn.addEventListener('click', async () => {
|
||||
|
||||
@@ -287,24 +287,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
return FIRMWARE_BUILTIN_PATTERNS.has(id);
|
||||
};
|
||||
|
||||
const sendPatternToDevices = async (patternName) => {
|
||||
const response = await fetch(`/patterns/${encodeURIComponent(patternName)}/send`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error((data && data.error) || 'Failed to send pattern');
|
||||
}
|
||||
const sentCount = data && typeof data.sent_count === 'number' ? data.sent_count : null;
|
||||
if (sentCount === null) {
|
||||
alert(`Sent "${patternName}" to devices.`);
|
||||
} else {
|
||||
alert(`Sent "${patternName}" to ${sentCount} device(s).`);
|
||||
}
|
||||
};
|
||||
|
||||
const loadPatternMetadata = async (patternName, fallbackData) => {
|
||||
const raw = String(patternName || '').trim();
|
||||
const norm = raw.endsWith('.py') ? raw.slice(0, -3).trim() : raw;
|
||||
@@ -405,18 +387,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
row.appendChild(label);
|
||||
|
||||
if (!isFirmwareBuiltinPattern(patternName)) {
|
||||
const sendBtn = document.createElement('button');
|
||||
sendBtn.className = 'btn btn-primary btn-small';
|
||||
sendBtn.textContent = 'Send';
|
||||
sendBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
await sendPatternToDevices(patternName);
|
||||
} catch (error) {
|
||||
console.error('Send pattern failed:', error);
|
||||
alert(error.message || 'Failed to send pattern.');
|
||||
}
|
||||
});
|
||||
|
||||
const editBtn = document.createElement('button');
|
||||
editBtn.className = 'btn btn-secondary btn-small';
|
||||
editBtn.textContent = 'Edit';
|
||||
@@ -428,7 +398,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
row.appendChild(editBtn);
|
||||
row.appendChild(sendBtn);
|
||||
}
|
||||
|
||||
patternsList.appendChild(row);
|
||||
|
||||
@@ -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));
|
||||
})();
|
||||
Reference in new issue
Block a user