Skip to main content
Lwang1
Associate
Jul 12, 2022 3:02 AM UTC
Question

How to sent variable len BLE message?

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.

3 replies

Remy ISSALYS
ST Technical Moderator
Jul 13, 2022 9:31 AM UTC

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
Aug 19, 2022 12:50 PM UTC

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
ST Technical Moderator
Aug 19, 2022 1:09 PM UTC

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