Hello everyone i need to update the Advertising Data of the device but i am not sure the correct way to do it.
First i have the next struct of the Adv Data that i want to use:
typedef struct {
uint8_t model;
uint16_t device_id;
uint8_t led_r;
uint8_t led_g;
uint8_t led_b;
} device_adv_data_t;The model and device_id are const values, but led params could change on execution time and i want to update the Advertising data with the new values. Right now i initialize the params using the example approach:
device_adv_data_t test_adv_data = {
.device_id = DEVICE_ID_NUMBER,
.model = DEVICE_MODEL_NUMBER,
led_r = DEFAULT_R_COLOR,
led_g = DEFAULT_G_COLOR,
led_b = DEFAULT_B_COLOR
};
static void advertising_init(void)
{
ret_code_t err_code;
ble_advertising_init_t init;
memset(&init, 0, sizeof(init));
static ble_uuid_t m_adv_uuids[] =
{
{SENSOR_UUID, BLE_UUID_TYPE_BLE}
};
init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
init.advdata.include_appearance = true;
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;
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;
/* Here we add more advertising data for devices, (manufacturer data) with the
struct ble_advdata_manuf_data_t s.*/
ble_advdata_manuf_data_t manuf_data;
manuf_data.company_identifier = BT_SIG_COMPANY_ID;
manuf_data.data.size = sizeof(test_adv_data);
manuf_data.data.p_data = (uint8_t*) &test_adv_data;
init.advdata.p_manuf_specific_data = &manuf_data;
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);
}My doubt is, if I update my test_adv_data struct, the adv data will automatically update when restart it since i pass the pointer to that struct? Or i have to do extra steps?
Thanks to everyone.