Hello, Espressif support.
We would like to know if it is possible to change advertising packet dynamically.
We tried with gatt_server_demo sample putting following code in the event handling of disconnection to see if the manufacturer data could be changed or not.
After the disconnection I can see the manufacture data has been changed but there is an error message,
E (295980) BT_APPL: bta_dm_ble_set_adv_params_all(), fail to start ble adv.
E (295980) GATTS_DEMO: Advertising start failed
Would you tell us the reason of this error message and an appropriate method to make it?
regards,
---modified code below---
static uint8_t test_manufacturer_data = 0;
#define CONFIG_SET_RAW_ADV_DATA
static uint8_t raw_adv_data[] = {
0x02, 0x01, 0x05,
0x02, 0x0a, 0x00, //Tx power
0x13, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //manufacturer specific data
};
case ESP_GATTS_DISCONNECT_EVT:
++test_manufacturer_data;
adv_config_done = 0;
ESP_LOGI(GATTS_TAG, "ESP_GATTS_DISCONNECT_EVT test_manufacturer_data:%d adv_config_done:%d", test_manufacturer_data, adv_config_done);
raw_adv_data[10] = test_manufacturer_data;
#ifdef CONFIG_SET_RAW_ADV_DATA
esp_err_t raw_adv_ret = esp_ble_gap_config_adv_data_raw(raw_adv_data, sizeof(raw_adv_data));
if (raw_adv_ret){
ESP_LOGE(GATTS_TAG, "config raw adv data failed, error code = %x ", raw_adv_ret);
}
adv_config_done |= adv_config_flag;
esp_err_t raw_scan_ret = esp_ble_gap_config_scan_rsp_data_raw(raw_scan_rsp_data, sizeof(raw_scan_rsp_data));
if (raw_scan_ret){
ESP_LOGE(GATTS_TAG, "config raw scan rsp data failed, error code = %x", raw_scan_ret);
}
adv_config_done |= scan_rsp_config_flag;
#endif
break;
Changing advertising packet dynamically
-
- Posts: 1
- Joined: Tue Apr 09, 2019 11:41 am
Re: Changing advertising packet dynamically
Maybe last comma?0x13, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Who is online
Users browsing this forum: ESP_ondrej, MicroController and 124 guests