Hi, In my project I need to measure current values for every sec and update those values to advertising data. So, I take manufacture field in advertising data to update the current values my advertising update function is shown below
static void updateAdData ( void )
{
uint32_t err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;
ble_advdata_manuf_data_t manuf_specific_data;
int8_t tx_power_level = TX_POWER_LEVEL;
// YOUR_JOB: Use UUIDs for service(s) used in your application.
static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_CURR_SERVICE, BLE_UUID_TYPE_BLE}}; /**< Universally unique service identifiers. */
// Build advertising data struct to pass into @ref ble_advertising_init.
manuf_specific_data.company_identifier = 0x02F4;
manuf_specific_data.data.p_data = mf_Data;
manuf_specific_data.data.size = sizeof(mf_Data);
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
advdata.p_manuf_specific_data = &manuf_specific_data;
memset(&scanrsp, 0, sizeof(scanrsp));
scanrsp.p_tx_power_level = &tx_power_level;
scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
scanrsp.uuids_complete.p_uuids = m_adv_uuids;
ble_advdata_conn_int_t connintvls;
connintvls.min_conn_interval = MIN_CONN_INTERVAL;
connintvls.max_conn_interval = MAX_CONN_INTERVAL;
scanrsp.p_slave_conn_int = &connintvls;
ble_adv_modes_config_t options = {0};
options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED;
options.ble_adv_fast_interval = APP_ADV_INTERVAL;
options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_DEFAULT;
err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
APP_ERROR_CHECK(err_code);
}
The above function is working well but my concern is I am always changing manufacture field only so, is their any way to set only manufacture field rather than complete advertising data to avoid the unnecessary initialization's every time. And I known it is easy by taking advdata and scasnrsp variables as global but I want is their any possible way with sd functions.