Bluetooth LE maximum transmission size

守給你的承諾、 提交于 2019-12-24 02:42:45

问题


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 Requests 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!