Code: Select all
case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
//adv start complete event to indicate adv start successfully or failed
if ((err = param->adv_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
ESP_LOGE(DEMO_TAG, "Adv start failed: %s", esp_err_to_name(err));
}
else {
ESP_LOGI(DEMO_TAG, "woke up and now starting adv successfully");
}
int64_t t_before_us = esp_timer_get_time();
vTaskDelay((1000*1) / portTICK_PERIOD_MS);
int64_t t_after_us = esp_timer_get_time();
printf("Returned from vTaskDelay, t=%lld ms, delayed for %lld ms\n",
t_after_us / 1000, (t_after_us - t_before_us) / 1000);
esp_ble_gap_stop_advertising();
break;
case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT:
if ((err = param->adv_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS){
ESP_LOGE(DEMO_TAG, "Adv stop failed: %s", esp_err_to_name(err));
}
else {
ESP_LOGI(DEMO_TAG, "Stopped adv successfully and now going to sleep");
}
//below using light sleep
esp_sleep_enable_timer_wakeup(4000000);
/* Enter sleep mode */
uart_tx_wait_idle(CONFIG_ESP_CONSOLE_UART_NUM);
ESP_ERROR_CHECK(esp_light_sleep_start());
esp_ble_gap_start_advertising(&ble_adv_params);
break;
Code: Select all
ESP_ERROR_CHECK(esp_bluedroid_disable());
ESP_ERROR_CHECK(esp_bluedroid_deinit());
ESP_ERROR_CHECK(esp_bt_controller_disable());
ESP_ERROR_CHECK(esp_bt_controller_deinit());
Code: Select all
ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));
ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));
ESP_ERROR_CHECK(esp_bluedroid_init());
ESP_ERROR_CHECK(esp_bluedroid_enable());
ble_ibeacon_appRegister();