Hey all,
I have a custom board running nRF52832 with Softdevice S132 v6.1.0 and SDK15.2. My application requires me to start advertising without any manufacturer data, then add manufacturer data in reaction to an event. To do this, when the event occurs, I stop the advertising, create a ble_advdata_manuf_data_t variable (in a function) and add my data, then pass it to the original advdata variable.
ble_advdata_manuf_data_t adv_manuf_data;
err_code = sd_ble_gap_adv_stop(m_adv_handle); //Stop advertising
APP_ERROR_CHECK(err_code);
memset(&adv_manuf_data, 0, sizeof(adv_manuf_data));
adv_manuf_data.data.p_data = adv_manuf_data_data;
adv_manuf_data.data.size = length;
adv_manuf_data.company_identifier = 0x0059; //Nordic's company ID
advdata.p_manuf_specific_data = &adv_manuf_data;
err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG); //Restart advertising
APP_ERROR_CHECK(err_code);