Implement BLE OTA
This commit is contained in:
+32
@@ -1015,3 +1015,35 @@ if (!navigator.bluetooth) {
|
||||
} else {
|
||||
log('Web Bluetooth ready. Click CONNECT to pair your IMU Mouse.','info');
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// OTA firmware update
|
||||
//
|
||||
// The OTAFIX bootloader uses Nordic Legacy DFU (service 00001530-...) which is
|
||||
// blocklisted in Chrome's Web Bluetooth implementation. Browser-side upload is
|
||||
// therefore not possible without special flags or a native app wrapper.
|
||||
//
|
||||
// What the UI does instead:
|
||||
// • "Enter DFU Mode" sends command 0x02 via BLE → device reboots as XIAO_DFU
|
||||
// • User then uploads firmware_dfu.zip via nRF Connect (mobile or desktop)
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
function otaLog(msg, type = 'info') {
|
||||
log('[OTA] ' + msg, type);
|
||||
const el = document.getElementById('otaStatus');
|
||||
if (el) { el.textContent = msg; el.className = 'ota-status' + (type !== 'info' ? ' ota-' + type : ''); }
|
||||
}
|
||||
|
||||
// Send command 0x02 → firmware reboots into XIAO_DFU bootloader mode.
|
||||
// User then uploads firmware_dfu.zip via nRF Connect.
|
||||
async function sendOTATrigger() {
|
||||
if (!chars.command) { otaLog('Not connected', 'err'); return; }
|
||||
document.getElementById('btnOTA').disabled = true;
|
||||
try {
|
||||
await chars.command.writeValueWithResponse(new Uint8Array([0x02]));
|
||||
otaLog('Device rebooting into DFU mode — connect to XIAO_DFU in nRF Connect', 'ok');
|
||||
} catch (e) {
|
||||
otaLog('Failed: ' + e.message, 'err');
|
||||
document.getElementById('btnOTA').disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user