Changing advertising packet dynamically

manabu.onishi
Posts: 1
Joined: Tue Apr 09, 2019 11:41 am

Changing advertising packet dynamically

Postby manabu.onishi » Mon Jul 08, 2019 11:26 am

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;

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Changing advertising packet dynamically

Postby chegewara » Sun Aug 11, 2019 1:17 am

0x13, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Maybe last comma?

Who is online

Users browsing this forum: ESP_Roland and 114 guests