This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2652R: Problem when advertising dynamic data

Part Number: CC2652R
Other Parts Discussed in Thread: SYSCONFIG

Hi!

I'm trying to create a simple peripheral device that can change the advertising data automatically. Long term, I would like to advertise some sensor data.

I tried to follow to steps mentioned on that link (Bluetooth Low Energy 5 Scanning and Advertising Basics)  but looks like I can modify the data only 1 time. I would like to know I you can help me. As mentioned in the link, I added my code in "case GAP_EVT_ADV_START_AFTER_ENABLE:" of "SimplePeripheral_processAdvEvent()" I'm using the simple peripheral code of SimpleLink CC13xx CC26xx SDK 7.10.02.23. 

Here is a picture of my code: /resized-image/__size/698x758/__key/communityserver-discussions-components-files/538/Screenshot-2024_2D00_01_2D00_22-161924.png

As you can see, each time I'm coming to this case i'm incrementing a variable that should be advertise (advertData2[11] = test_loop2;). I can see the variable beeing incremented but when preparing to load the buffer again, I'm getting a status bleGAPNotFound. 

So sum up, I'd like to understand how to advertise some dynamic data. 

Thanks,

Jonathan

  • Hi Jonathan,

    Whenever a change is made to the advertising date, the advertisements should be disabled first and then the change should be made. You should be able to modify multiple elements in the array at the same time using a function like memcpy or by simply iterating over the array. Please ensure data is modified only when advertisements are disabled.

    Best Regards,

    Jan

  • The following command is used before modifing the data. This command disables the advertising set as mentioned in the user guide.
    status = GapAdv_prepareLoadByBuffer(advData1, FALSE);

  • Hi,

    Can you verify that the corresponding event for disabling advertisements is being received?

    Best Regards,

    Jan

  • Hi,

    After creating the advertising handle in SimplePeripheral_processGapMessage(), I'm loading the advData1 generated by sysconfig (loadbyHandle), I'm setting the mask with

    GapAdv_setEventMask(advHandleLegacy, GAP_ADV_EVT_MASK_START_AFTER_ENABLE | GAP_ADV_EVT_MASK_END_AFTER_DISABLE | GAP_ADV_EVT_MASK_SET_TERMINATED);

    And I'm enabling the set with GapAdv_enable(). This part is working fine but then the program is going in SimplePeripheral_processAdvEvent() (case GAP_EVT_ADV_START_AFTER_ENABLE) to update the data. The first time the program entering this case it's working (prepareloadbybuffer return success) because I'm trying to modify the advData1 but then the second time this same function return bleGAPNotFound (no advertising sets are using this buffer). I don't know which buffer should I use then.

  • Hi,

    Can you try disabling the advertisements, waiting for the GAP_EVT_ADV_END_AFTER_DISABLE event to be received, and inside the event update the adv_data? I think this method will be the safest way to update the advertising data and will help us see if we may be missing something in the setup.

    Best Regards,

    Jan

  • " waiting for the GAP_EVT_ADV_END_AFTER_DISABLE event to be received" How do you do that ?

  • Hi,

    By default, the GAP_EVT_ADV_END_AFTER_DISABLE event is subscribed to already. Whenever advertising has been fully disabled by the BLE5-Stack, the stack will post an event to the application and this event will be the GAP_EVT_ADV_END_AFTER_DISABLE. The event will be caught and make its way to the SimplePeripheral_processAdvEvent() function. Within that function, there is a case for the SimplePeripheral_processAdvEvent GAP_EVT_ADV_END_AFTER_DISABLE, so any processing or code that takes place inside this case statement can be made with assurance that advertisements are fully disabled.

    Best Regards,

    Jan

  • Hi,

    That's what I was doing! My problem is that I'm trying to update some data in that case statement but to do so, I want the program to go in this case multiple time while keeping the advertisement interval fixed. Right now, I can either go to this case statement again by setting the mask to GAP_EVT_ADV_END_AFTER_DISABLE while being in GAP_EVT_ADV_END_AFTER_DISABLE but this overpass the advertisement interval and the data is sent too quickly. Or I can set the mask to something else but the program won't reach this case anymore so the data won't be update.

    I don't know if SimplePeripheral_processAdvEvent is the right way to do it.

  • Hi,

    My apologies, I did not realize you were already doing your processing inside that event. It seems you want to make sure the advertisements are sent at a consistent interval while changing the data. In which case, maybe adding the GAP_ADV_EVT_MASK_END to the advertising event mask may be helpful. Adding that event mask will generate a GAP_EVT_ADV_START event immediately after an advertisement is sent. Maybe we can try loading the updated advertising data in that case instead.

    Best Regards,

    Jan

  • I found a way to resolve my problem by doing the same thing as SP_PERIODIC_EVT is doing. I just changed the function SimplePeripheral_performPeriodicTask to update the data.