From c142ffd468ece097e0f9e7ef2d33d74e468589b7 Mon Sep 17 00:00:00 2001 From: Li Zhineng Date: Tue, 10 Jun 2025 22:43:23 +0800 Subject: send request device identity command --- index.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.html b/index.html index 7090f31..13e4557 100644 --- a/index.html +++ b/index.html @@ -48,6 +48,9 @@ const password = '' await sendWifiCredentialsCommand(writeChar, ssid, password) await delay(500) + + // 4. Retrieve device ID + await sendRequestDeviceIdentityCommand(writeChar) } function handleDeviceResponse(event) { @@ -127,6 +130,18 @@ await sendRawData(writeChar, packet2) } + async function sendRequestDeviceIdentityCommand(writeChar) { + const packet = new Uint8Array([ + // Header (4 bytes) + 0x04, // Sequence Number: 4 + 0x11, // Packet Info: (Packet 1 of 1) + 0x00, // Command ID: 22, Enc-Flag: 0 (Big Endian) + 0x16 + ]) + + await sendRawData(writeChar, packet) + } + async function sendRawData(characteristic, data) { const chunkSize = 20 for (let i = 0; i < data.length; i += chunkSize) { -- cgit v1.2.3