Dynamically changing the BLE advertising message content

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

cross mob
StNu_1610991
Level 4
Level 4
First comment on KBA 50 sign-ins 25 replies posted

The content of the advertising message is set up statically in the BLE component configuration. in PSoC Creator 4.3  We need to change two bytes dynamically in one field.  The start and stop of the advertising is  controlled in the CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP event but I do not see a pointer to the message content to be able to change it.

Could someone tell me where the message data is located or how this could be done?

0 Likes
1 Solution

I found a solution not even needing Cy_BLE_GAPP_UpdateAdvScanData().

The advertising packet bytes are at  cy_ble_config.discoveryModeInfo[cy_ble_advIndex].advData as a byte array.  For my application only 2 bytes need to be dynamically variable.  So, just setting the bytes in this array seems to be working fine.  The structure of the advertising message does not have to be changed.

View solution in original post

3 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Please refer to the Cy_BLE_GAPP_UpdateAdvScanData() API in the BLE component datasheet. This function is used by GAP Peripheral application to set Advertisement and/or Scan Response data. This function can be used during active advertisement as well. Application should ensure the validity of the data content. On completion of this operation, GAP Peripheral application receives CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE event.

Thanks,
P Yugandhar.

0 Likes

OK. Thanks.

From my perspective I never would have guessed by the name of the function that it could also modify the advertising data.  The documentation could be a lot more clear.

Now, the next problem is getting access to the advertising packet byte array that was assembled statically.  First how can it be accessed and second, how is it put into the cy_stc_ble_gapp_disc_mode_info_t structure needed by the UpdateAdvScanData function?

0 Likes

I found a solution not even needing Cy_BLE_GAPP_UpdateAdvScanData().

The advertising packet bytes are at  cy_ble_config.discoveryModeInfo[cy_ble_advIndex].advData as a byte array.  For my application only 2 bytes need to be dynamically variable.  So, just setting the bytes in this array seems to be working fine.  The structure of the advertising message does not have to be changed.