bleprofile_WriteHandle() function doubt

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
wewu_1392881
Level 3
Level 3
First like received First like given Welcome!

During i call bleprofile_WriteHandle(UINT16 hdl, BLEPROFILE_DB_PDU *p_pdu), i find that the BLEPROFILE_DB_PDU structure as following:

// GATT_PDU

typedef PACKED struct

{

  UINT8 len;

  UINT8 header;

  UINT8 pdu[LEATT_ATT_MTU-1];

} BLEPROFILE_DB_PDU;

The LEATT_ATT_MTU value is 23, so the max length of data i can update the characteristic is 22 bytes, if i define a characteristic whose value length is more than 22 bytes, how can i update using bleprofile_WriteHandle()?  Although BLE spec requires the MTU of characteristic is 22, but i find if i define one characteristic value length more than 22, it will split into 2 packets and send to host.

0 Likes
1 Solution
Anonymous
Not applicable

Hello.

Yes LEATT_ATT_MTU is a 23. That's because MTU (maximum transmission unit) for BLE is 23 bytes.

However you can have a something called "long characteristic". Pretty much it's a characteristic that has length greater 23 bytes.

Reading and writing to characteristics from client are done by the BLE stack. So you don't have to worry about that.

There is an example of long characteristic in the SDK apps under "long_characteristic".

You can take a look at this app and test it with LightBlue or some other app equivalent to it.

Using LightBlue, I was able to easily read and write to the BLE device with long characteristic.

The app also shows how you can use bleprofile_ReadHandleData and bleprofile_WriteHandleData to read and write to long characteristic.

You can find this part in the interrupt handler function. Basically you allocate memory space big enough for the characteristic and use its pointer after casting it to BLEPROFILE_DB_PDU pointer. You don't actually use the struct. You just use its pointer type.

Let us know if this helps. Thank you.

James

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Hello.

Yes LEATT_ATT_MTU is a 23. That's because MTU (maximum transmission unit) for BLE is 23 bytes.

However you can have a something called "long characteristic". Pretty much it's a characteristic that has length greater 23 bytes.

Reading and writing to characteristics from client are done by the BLE stack. So you don't have to worry about that.

There is an example of long characteristic in the SDK apps under "long_characteristic".

You can take a look at this app and test it with LightBlue or some other app equivalent to it.

Using LightBlue, I was able to easily read and write to the BLE device with long characteristic.

The app also shows how you can use bleprofile_ReadHandleData and bleprofile_WriteHandleData to read and write to long characteristic.

You can find this part in the interrupt handler function. Basically you allocate memory space big enough for the characteristic and use its pointer after casting it to BLEPROFILE_DB_PDU pointer. You don't actually use the struct. You just use its pointer type.

Let us know if this helps. Thank you.

James

0 Likes
Anonymous
Not applicable

You may also find this post helpful.

Support for very large characteristics

0 Likes