diff options
| author | Li Zhineng <[email protected]> | 2025-06-10 21:22:36 +0800 |
|---|---|---|
| committer | Li Zhineng <[email protected]> | 2025-06-10 21:22:36 +0800 |
| commit | b7810a12703645a41d1861a5dc89ab9699cee189 (patch) | |
| tree | a692b9b8873fa24f5769a1149badf07ae15c3448 | |
| parent | 5ab8cb6d19ddca16246576e80863e2847c17c88c (diff) | |
| download | setup-b7810a12703645a41d1861a5dc89ab9699cee189.tar.gz setup-b7810a12703645a41d1861a5dc89ab9699cee189.zip | |
update bind command
| -rw-r--r-- | index.html | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -53,18 +53,21 @@ } async function sendBindCommand(writeChar) { - const commandId = 17 - const subCommandId = 1 - const dummyToken = '0000000000000000' - const encoder = new TextEncoder() - const tokenBytes = encoder.encode(dummyToken) + const handshakePacket = new Uint8Array([ + // --- 4-byte Header --- + 0x01, // Sequence Number: 1 + 0x11, // Packet Info: (Packet 1 of 1) + 0x00, // Command ID: 11 (Big Endian Short, MSB) + 0x0B, // Command ID: 11 (Big Endian Short, LSB) - const buffer = new Uint8Array(18) - buffer[0] = commandId - buffer[1] = subCommandId - buffer.set(tokenBytes, 2) + // --- 15-byte Payload --- + 0x08, // Hardcoded first byte of payload + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Token (as 0L) + 0x05, // Length of version string "1.0.0" + 0x31, 0x2e, 0x30, 0x2e, 0x30 // ASCII for "1.0.0" + ]) - await sendRawData(writeChar, buffer) + await sendRawData(writeChar, handshakePacket) } async function sendRawData(characteristic, data) { |
