问题
We are currently working with Bluetooth LE and want to send a 128 character string to a gatt service.
Now the Bluetooth Specs say that the maximum packet size of BLE is 22 bytes, my string will never fit in the packet.
We are thinking about chunking it up and send it in iterations.
Is this the usual way of doing things?
回答1:
Yes, you need to chunk the data into 18 bytes pieces, then send a series of Prepare Write Request
s to the Server. Each of this request has 3 parameters:
- Attribute handle (2 bytes)
- Attribute offset (2 bytes)
- Data part (max 18 bytes)
So you would first send a packet with offset 0, then a packet with offset 18, then 36 etc. When you do that, the Server queues all your requests.
In the end, you send an Execute Write Request
and the Server writes all the bytes in one shot.
来源:https://stackoverflow.com/questions/26214362/bluetooth-le-maximum-transmission-size