Skip to main content
Lwang1
Associate
July 12, 2022
Question

How to sent variable len BLE message?

  • July 12, 2022
  • 2 replies
  • 1273 views

I have set the data length as variable. The code generate in custom_stm.c also aci_gatt_add_char as CHAR_VALUE_LEN_VARIABLE. But in the Custom_STM_App_Update_char function, it always sent and static const charValueLen.

I fix it by cloning Custom_STM_App_Update_char and add length parameter. It works, The data I sent is not alway const length. But I don't know how to sent a variable data normally.

This topic has been closed for replies.

2 replies

Remy ISSALYS
Technical Moderator
July 13, 2022

Hello,

Indeed, in the code generate, in the Custom_STM_App_Update_char function, it always sent and static const charValueLen. I think, in aci_gatt_update_char_value function you can use a sizeof(pPayload) for charValueLen in your variable length characteristic, depending how your payload is defined.

I will checked this point with the development team, to improve the feature for the next release.

Best Regards

Ugilten
Associate III
August 19, 2022

Hi @Remy ISSALYS​ ,

Unfortunately, this won't work, since you just get the size of the pointer.

the payload variable is defined as uint_8 *pPayload.

Regards

Remy ISSALYS
Technical Moderator
August 19, 2022

Hello,

Yes, you have right, in this case the best way is to add length parameter in Custom_STM_App_Update_char function.

Best Regards