main.c 983 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "esp_log.h"
  7. #include "nvs_flash.h"
  8. #include "esp_bt.h"
  9. #ifndef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
  10. #error "Please Enable Uart for HCI"
  11. #endif
  12. #define TAG "BLE_HCI"
  13. void
  14. app_main(void)
  15. {
  16. esp_err_t ret;
  17. /* Initialize NVS — it is used to store PHY calibration data */
  18. ret = nvs_flash_init();
  19. if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  20. ESP_ERROR_CHECK(nvs_flash_erase());
  21. ret = nvs_flash_init();
  22. }
  23. ESP_ERROR_CHECK(ret);
  24. esp_bt_controller_config_t config_opts = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
  25. /*
  26. * Initialize Bluetooth Controller parameters.
  27. */
  28. ESP_ERROR_CHECK(esp_bt_controller_init(&config_opts));
  29. /*
  30. * Enable the task stack of the Bluetooth Controller.
  31. */
  32. ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));
  33. }