From b7810a12703645a41d1861a5dc89ab9699cee189 Mon Sep 17 00:00:00 2001 From: Li Zhineng Date: Tue, 10 Jun 2025 21:22:36 +0800 Subject: update bind command --- index.html | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 88dc225..b04539b 100644 --- a/index.html +++ b/index.html @@ -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) { -- cgit v1.2.3