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

ble_app_template based app with adv frame update during runntime?


(SES + SDK15)

Hi!

I am trying to create an new firmware prototype based  on ble_app_template_sample

Until now I have a connectable firmware, with one service and several characteristics. Everything is working well.

But now I have the need to change the advertisement manuf data on the fly while advertising.
It seems that in SDK 15 the way the manuf data is changed is different.
Until now I haven't succeeded on this.

Is there any  ble peripheral connectable sample that also updates manuf data using SDK15 new approach?


I have this prototype code:


//Some globals
BLE_ADVERTISING_DEF(m_advertising);                                             /**< Advertising module instance. */
ble_advertising_init_t
ble_advdata_manuf_data_t manuf_data; //Variable to hold manufacturer specific data


void advertising_init(void)
{
    ret_code_t             err_code;
    memset(&init, 0, sizeof(init));

    //just to...
    data[0] = 0xCA;    
    data[1] = 0xCA;    
    data[2] = 0xCA;    
    data[3] = 0xCA;
    data[4] = 0xCA;
    data[5] = 0xCA;
    data[6] = 0xCA;
    data[7] = 0xCA;

    manuf_data.company_identifier             =  0xFFFF;
    manuf_data.data.p_data                    = data;
    manuf_data.data.size                      = sizeof(data);
    init.advdata.p_manuf_specific_data = &manuf_data;


    init.advdata.name_type               = BLE_ADVDATA_SHORT_NAME; // Use a shortened name
    init.advdata.short_name_len = 6;    
    init.advdata.include_appearance      = true;
    init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    int8_t tx_power                       = -4;
    init.advdata.p_tx_power_level = &tx_power;
 
    init.config.ble_adv_fast_enabled  = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}


Then, in an app timer I have this starting code:


static void timer_timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);

   //Reset to avoid double buffering
   ret_code_t ret = sd_ble_gap_adv_set_configure(m_advertising.adv_handle,NULL,NULL);

   //???

   ret = sd_ble_gap_adv_set_configure(m_advertising.adv_handle,m_advertising.p_adv_data,NULL);
   VERIFY_SUCCESS(ret);

}

Please, how to change one or two sample bytes of advertising frame in the //??? place?

Thanks al lot

Alex

Parents Reply
  • Sorry but I just can see (re)start advertising and not changing advertising without restarting :-(

    I can change advertising by stopping it and start it again but as the prototype is connectable,if i stop and start  central devices will see problems connecting to peripheral because it will be restarting from second to second in order to update adv data.

    Any source code to change just one byte would be very appreaciated

Children
Related