Unable to dynamically change advertising packets on PSoC 4 BLE

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

cross mob
User84021
Level 1
Level 1
Welcome! First question asked First reply posted

Hello,

I am trying to dynamically update the advertising packets sent by my PSoC 4 device in the "Central and Peripheral" project. I have seen the following thread:

Recommended method to update manufacturer data when NOT advertising

and have attempted to do this by changing the cyBle_discoveryModeInfo.advData->advData[] array before starting advertising. I have done this in the StackEventHandler's CYBLE_EVT_STACK_ON function:

/* Set adv data packet */

char deviceName[] = "12345678";

(cyBle_discoveryModeInfo.advData->advData)[3] = 0x09;   //Set length

for(i=5; i<13; i++)

    (cyBle_discoveryModeInfo.advData->advData) = deviceName[i-5];

cyBle_discoveryModeInfo.advData->advDataLen = 13;

CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

/* ------------------------- */

The issue I am having is that the advertising packet does not change, which I see by using the LightBlue app and looking at the device name. Interestingly, if I change the cyBle_discoveryModeInfo.r->respData array this way, it does change the response packet. However, I need to change the initial advertising packet as well. What am I doing wrong in this case?

Thank you very much.

0 Likes
1 Solution

From your attached code, you have just changed the device name and advdata length, the other data remains untouched, right?

One possible reason is regarding to mobile app you are using, which remains the old name even though it's changed. You can try to switch to another app, e.g. CySmart, to check whether this issue is still there.

If it is not effective, you can try to put the the code snippet from under swtich case to main loop with judging some boundary conditions, like -

- Whether BLE stack is on;

- Whether current state of advertisement is stopped;

- Whether the current BLE connection number is 0.

Of course, the most intuitive way is to enter debug mode and observe whether the adv data is changed or not before advertising start.

View solution in original post

5 Replies