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

Updating advertising data (manuf. spec. data) in SDK15

Hello guys! And girls Slight smile

My project is working as expected in SDK14.2.
I'm updating adv data (manuf. spec. data) without any problem with this function

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void advertising_data_update(uint8_t adv_manuf_byte)
{
ret_code_t err_code;
ble_advertising_init_t init;
ble_advdata_manuf_data_t adv_manuf_data;
uint8_array_t adv_manuf_data_array;
uint8_t adv_manuf_data_data[1];
adv_manuf_data_data[0] = adv_manuf_byte;
memset(&init, 0, sizeof(init));
init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
init.advdata.include_appearance = false;
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
init.advdata.uuids_complete.p_uuids = m_adv_uuids;
adv_manuf_data_array.p_data = adv_manuf_data_data;
adv_manuf_data_array.size = sizeof(adv_manuf_data_data);
adv_manuf_data.company_identifier = APP_COMPANY_IDENTIFIER;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


But in SDK15 the function ble_advdata_set() has been deprecated.
The migration guide is says to use ble_advdata_encode() and sd_ble_gap_adv_set_configure() instead.

So I changed it to something like this

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void advertising_data_update(uint8_t adv_manuf_byte)
{
ret_code_t err_code;
ble_advertising_init_t init;
ble_advdata_manuf_data_t adv_manuf_data;
uint8_array_t adv_manuf_data_array;
adv_manuf_data_data[0] = adv_manuf_byte;
memset(&init, 0, sizeof(init));
init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
init.advdata.include_appearance = false;
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
init.advdata.uuids_complete.p_uuids = m_adv_uuids;
adv_manuf_data_array.p_data = adv_manuf_data_data;
adv_manuf_data_array.size = sizeof(adv_manuf_data_data);
adv_manuf_data.company_identifier = APP_COMPANY_IDENTIFIER;
adv_manuf_data.data = adv_manuf_data_array;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


And of course... it's not working. :)
I'm getting a very strange error at sd_ble_gap_adv_set_configure() --> app: ERROR 12801 [Unknown error code]

Any idea why?
What I'm doing wrong?
What I have to change to get this working like in the SDK14.2?

Parents
  • Try this code:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    static void advertising_init(void)
    {
    ret_code_t err_code;
    ble_advertising_init_t init;
    ble_advdata_manuf_data_t adv_manuf_data;
    uint8_array_t adv_manuf_data_array;
    adv_manuf_data_data[0] = 0x00;
    memset(&init, 0, sizeof(init));
    init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance = false;
    init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids = m_adv_uuids;
    adv_manuf_data_array.p_data = adv_manuf_data_data;
    adv_manuf_data_array.size = sizeof(adv_manuf_data_data);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I also tried this, and recieve error 12, with a ble_advdata_encode(). May be we should encode data directly to m_advertising.enc_advdata? like when we initialize advertising?

  • You just have to assign the one after the other. The SoftDevice requires only that you send it a pointer to an address that is different from the previous buffer, the content can remain the same. 

  • But my content changes every time(battery voltage value. I tried to refer eddystone and hrs example but couldn't go so far).

    manuf_specific_data.company_identifier = battVolt_1;

    this line is called every time when there is time out of timer. So, data is updated.

    Now is it good approach to use if else to assign new data(new buffer) at every cycle? Or am I at wrong approach?

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    static void advertising_init(void)
    {
    ret_code_t err_code;
    ble_advdata_t advdata;
    uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    get_battery_volt();
    ble_advdata_manuf_data_t manuf_specific_data;
    manuf_specific_data.company_identifier = battVolt_1; //changes when time out
    manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
    manuf_specific_data.data.size = APP_BEACON_INFO_LENGTH;
    // Build and set advertising data.
    memset(&advdata, 0, sizeof(advdata));
    advdata.name_type = BLE_ADVDATA_NO_NAME;
    advdata.flags = flags;
    advdata.p_manuf_specific_data = &manuf_specific_data;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I set NULL too in _configure but didnt work.

    I will try to read this whole thread but it is quite long so if you can help in this!

  • "Now is it good approach to use if else to assign new data(new buffer) at every cycle? Or am I at wrong approach?"

    That sounds like what I would have done.


  • But sir code still stopped working at _configure().

    I tried to do debugging on keil.

    I did searched infocenter and different threads but could not get the idea about id,pc,info(i know definitions but how to use them to get to the error).

  • Thank you Haakonsh for your help.

    I made mistake by misunderstanding the pointer and buffer, Sorry!

    This thread helped me.

Reply Children
No Data