Iam using esp gatt server demo code
:
https://github.com/espressif/esp-idf/bl ... tts_demo.c
uint8_t manufacture_specific_data[8] = { 0x0b, 0xFF, 0x02, 0x00};
uint8_t checkNum = 0;
/* The length of adv data must be less than 31 bytes */
static esp_ble_adv_data_t adv_data = {
.set_scan_rsp = false,
.include_name = false,
.include_txpower = false,
.min_interval = 0x20,
.max_interval = 0x40, //slave connection max interval, Time = max_interval * 1.25 msec
.appearance = 0x00,
// .manufacturer_len = sizeof(manufacture_specific_data),
// .p_manufacturer_data = &manufacture_specific_data,
.service_data_len = 0,
.p_service_data = NULL,
.service_uuid_len = ESP_UUID_LEN_128,
.p_service_uuid = Huilan_service_uuid,
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};
// scan response data
static esp_ble_adv_data_t scan_rsp_data = {
.set_scan_rsp = true,
.include_name = true,
.include_txpower = false,
.min_interval = 0x0006,
.max_interval = 0x0010,
.appearance = 0x00,
.manufacturer_len = sizeof(manufacture_specific_data),
.p_manufacturer_data = manufacture_specific_data,
.service_data_len = 0,
.p_service_data = NULL,
.service_uuid_len = ESP_UUID_LEN_128,
.p_service_uuid = Huilan_service_uuid,
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};
static esp_ble_adv_params_t adv_params = {
.adv_int_min = 0x20,
.adv_int_max = 0x40,
.adv_type = ADV_TYPE_IND,
.own_addr_type = BLE_ADDR_TYPE_PUBLIC,
.channel_map = ADV_CHNL_ALL,
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};
///////////////////////////////////////////////////////////////////////////////////////////////////////
This is the timer call back where I updated the manufacture data
void periodic_timer_callback(void *arg)
{
checkNum++;
int64_t time_since_boot = esp_timer_get_time();
ESP_LOGI(timer_tag, "Periodic timer called, time since boot: %lld us", time_since_boot);
if (checkNum != 250)
{
dyn_adv_update(false);
manufacture_specific_data[2] = checkNum;
dyn_adv_update(true);
}
else
{
ESP_ERROR_CHECK(esp_timer_stop(periodic_timer));
ESP_ERROR_CHECK(esp_timer_delete(periodic_timer));
ESP_LOGI(timer_tag, "Stopped and deleted timers");
}
}
void dyn_adv_update(bool param)
{
if (param == false)
esp_ble_gap_stop_advertising();
if (param == true)
esp_ble_gap_start_advertising(&adv_params);
}
so that each time the periodic timer is called the manufacture data needs to be updated. The timer works fine. But the data is not getting updated when advertising.