barry007
barry007

Reputation: 539

Bluetooth LE maximum transmission size

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?

Upvotes: 3

Views: 3786

Answers (1)

Bogdan Alexandru
Bogdan Alexandru

Reputation: 5542

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.

Upvotes: 4

Related Questions