I am using ESP32 WROOM module with gatt_server and I am trying to change the data being advertised on the go in the main function using the following code segment.
Code: Select all
static esp_ble_adv_params_t adv_params1 = {
.adv_int_min = 0x0A0, //160 * 0.625 ms = 100ms,
.adv_int_max = 0x140, //320 * 0.625 ms = 200ms,
.adv_type = ADV_TYPE_IND,
.own_addr_type = BLE_ADDR_TYPE_PUBLIC,
//.peer_addr =
//.peer_addr_type =
.channel_map = ADV_CHNL_ALL,
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};
{
static uint8_t test_manufacturer[4] = { 0x23, 0x07, 0x41, 0x56};
static uint8_t adv_service_uuid128[32] = {
/* LSB <--------------------------------------------------------------------------------> MSB */
//first uuid, 16bit, [12],[13] is the value
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xEE, 0x00, 0x00, 0x00,
//second uuid, 32bit, [12], [13], [14], [15] is the value
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
};
static uint8_t service[5] = {0, 1, 2, 3, 4};
esp_ble_gap_stop_advertising();
static esp_ble_adv_data_t ADVinfo;
ADVinfo.set_scan_rsp = false;
ADVinfo.include_name = true;
ADVinfo.include_txpower = true;
ADVinfo.appearance = 0x2A79;
ADVinfo.min_interval = 0x0036; //slave connection min interval, Time = min_interval * 1.25 msec
ADVinfo.max_interval = 0x0040; //slave connection max interval, Time = max_interval * 1.25 msec
ADVinfo.appearance = 0x00;
ADVinfo.manufacturer_len = sizeof(test_manufacturer); //TEST_MANUFACTURER_DATA_LEN,
ADVinfo.p_manufacturer_data = test_manufacturer; //&test_manufacturer[0],
ADVinfo.service_data_len = 0;
ADVinfo.p_service_data = NULL;
ADVinfo.service_uuid_len = sizeof(adv_service_uuid128);
ADVinfo.p_service_uuid = adv_service_uuid128;
ADVinfo.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT);
test_manufacturer[2] = test_manufacturer[2] + 1;
esp_ble_gap_config_adv_data(&ADVinfo);
esp_ble_gap_start_advertising(&adv_params1);
}
is it possible to modify the data being advertised on the go ?if yes what is the proper way of doing that?
Thank you