This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Update advertisement manufacturer data once per second

Hi,

In my project I am using SDK 14.2 with S332.

I need to change the data in the manufacturer part of the advertisement packet once per second (nearly, timing is not strictly important). I saw the suggested method is to wait for a radio notification event, but the answer aimed at changing data once per adv packet, which I am not really interested. In my case, data changes on an application timer and I just want to send the lastest data collected, indepdendently from the frequency of advertisement.

Do I still need to sync with radio notifications or not? It is not clear if it is required just for the original case of one change per packet or if it is required by the ble_advdata_set method (i.e. avoid crash).

Avoiding to subscribe to radio notifications would be really useful.

Thanks a lot!

Parents

  • The problem will be that your calls to set the manufacturer specific ID will likely be asynchronous with the BLE timer which performs calls to send out the advertising packets.

    As simple solution would be to wrap your setting of the manufacturer ID with the app_util_critical_region_enter() and app_util_critical_region_exit() functions. Their function definitions are in the SDK 15.2 directory nRF5_SDK_15.2.0_9412b96/components/libraries/util/app_util_platform.c and associated .h file.

    This will prevent the BLE timer interrupt from reading the manufacturing data from the advertising structure before you are done writing to it.

  • Thanks, I am expecting the 2 events (update  <-> send) to be completely async, it's not a problem for my app. The real question is if it may cause crashes or other criticals. If the only problem is that a write is missed, it's not really that important. Data will either be sent on the next advertisement packet or be superseded by new data.

    I'm not sure I've explained my use case. Data is produced continuously at a more or less fixed rate (ex: about once per second), while advertisement will either be fast or slow (and have their timings completely unrelated to data). I just want the advertisement to pick up the new data I write with ble_advdata_set. I think I will be using static structures and all data has meaning at byte level. So event if I am writing while advertisement is in progress, it's not  problem if data is only partially updated.

    The question is if this may cause any crash, because at data level I have not worries.

    Thanks!

  • You don't need to synchronize with the radio to update the manufacturer data. Just change the data in the packet structure and re-init advertisements.  The softdevice won't crash, it will just use the new data on the next advertisement.

    We do precisely this for one of our products.  It works perfectly.

Reply Children
Related