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

Confusion about new style of manufacturer specific data updating

Hi,

I have a project which was originally written using SDK12, and have updated it to SDK16, I am sorry I know this question seems to have been asked in many different ways already.

I have one problem left.

I need to dynamically update manufacture specific data for the advertisement, and the code below used to work fine.

I know things have changed now and I have to use the ble_advdata_encode function, but it is not clear how exactly and I cannot find any direct examples.

The searched turn up hundreds of results from the forum which are all slightly different, some use ble_advertising_init, others sd_ble_gap_adv_start and a ton inbetweeners.

The migration guide is also not clear on the matter.

I am using short names and fast advertising, I previously had the following init function and an update function - could someone indicate to me, or point me to a proper example of how I can change this code from SDK12 style to SDK16 and achieve exactly the same result with as little change as possible?

I think I have to continue to use the ble_advertising_init due to the fast advertising options, I would also prefer not to have to stop and start the advertisement every time I want to update it (i believe I will also have to update the interval times as per the change of units mentioned in the migration guide)

Many thanks

  • It is SO much easier to update now!  Here's how I do it.  Change the options in new_data to match your init function.

  • Spot on, that's worked a treat, thanks

  • Hello, thanks for the solution for the newbie here. However, could you elaborate how I can use this function? Where should I locate this function?

  • Sure! 

    - Where to locate ... I'd put it right below your advertising_init() function.  Edit your advertising_init() function with the same manufacturer data as advertising_update_mfg_data().

    - How to use... depends on what manufacturer data you are advertising.  Lets say you're measuring temperature and going to send it in two bytes (say in a signed int16).  You have a timer which reads the temperature and saves it to a static location (m_temperature) every minute.  Right after you read temperature, call advertising_update_mfg_data() to copy the new reading into the advertising data.  Watch the bytes being sent in the advertisement change with temperature.

    Replacing <<<<<your first byte here>>>>>> .... would be something like:

    - Rob

  • Hello Rob,

    I added advertising_update_mfg_data(void) function right below the advertising_init(). But it doesn't seem to update the new data by time.

    I have a beacon that advertises the current time every 187.5ms(no reason) loaded on manufacturer specific data field. I scanned this beacon through an app, but the data seemed to fixed to 590000 (0x0059 is Nordic manufacturer) and did not showed the updated second data.

    Could you look at my code? Below is advertising_init() and advertising_update_mfg_data()

    And my main function just looks like this below.

    Also thanks for the prompt reply yesterday !

1 2