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

Writing a custom version of ble_advertising_init?

I'd like to be able to quickly update the advertising data using

sd_ble_gap_adv_data_set()

and at the moment I'm doing this via a bit of a hack, as I captured the advertising packet, and worked out the offset to the manufacturer data, so I can just change values in that data and then call sd_ble_gap_adv_data_set() passing an array of bytes

But I know this is a bit of a hack, so I thought I'd copy the code from ble_advertising_init(), and get my own copy to save the advertising data, and also store the location of the manufacturer data, so that I could cleanly update just the manufacturer data using sd_ble_gap_adv_data_set()

However, this does not seem to be possible, because ble_advertising.c contains static variables including

static bool m_initialized;

which need to be configured, or the advertising doesn't seem to work.

(My current hack is to call ble_advertising_init() to get it to setup its internal variables, but then call sd_ble_gap_adv_data_set() with my previously captured data.)

As far as I can see, the only way I can do this, is to have a duplicate function for ble_advertising_init() where I save the advertising data array (actually I'd need to duplicate some other functions like ble_advdata_set() as I need the data just prior to it being sent to the SD.)

But I'd still need to call ble_advertising_init(), otherwise I can't get the advertising to start, by calling ble_advertising_start as m_initislized is not set.

Can you advise the best way to just update the manufacturer data, that doesn't take a lot of unnecessary processing cycles

Thanks

Related