How to write a hex array to the device

Viewed 46

Because the device's document just let me know how to send byte-by-byte to communicate with the BLE Device. Example: When turn on the light, the command will be

Byte 0: 0x01, Byte 1: 0x32, Byte 2: 0x5A, Byte 3-4: 0x042A, Byte 5-18: 0x0024....2A, Byte 19-20: 0xB21F. I saw a lot of Bluetooth API document and example. When sending a value to device, we need to use

await characteristic.writeValue(Uint8Array.from(data))

But when I try to put a long hex buffer array like this [0x32,0x5A,0x04,0x2A,0x00,0x24,...,0x2A,0xB2,0x1F] into "data" I got an error like this:

NotSupportedError: GATT Error Unknown

But when I try a shorter command for changing some setting ([0x01,0x2a,0x58,0xab,0x00,0x1b,0xbf]) this error disappear.

So can I send a long Hex array to BLE device by Javascript code?

Sorry my English is not good and this is my first time asking in StackOverflow

0 Answers
Related