bt: call nvs_flash_init in examples, show error if NVS is not initialized

NVS is used to store PHY calibration data, WiFi configuration, and BT
configuration. Previously BT examples did not call nvs_flash_init,
relying on the fact that it is called during PHY init. However PHY init
did not handle possible NVS initialization errors.

This change moves PHY init procedure into the application, and adds
diagnostic messages to BT config management routines if NVS is not
initialized.
This commit is contained in:
Ivan Grokhotkov
2017-07-13 23:46:19 +08:00
parent 1ed4eadfab
commit 979fce0df5
17 changed files with 132 additions and 31 deletions

View File

@@ -14,7 +14,7 @@
#include <stdio.h>
#include <string.h>
#include "nvs.h"
#include "bt.h"
#include "driver/uart.h"
#include "esp_log.h"
@@ -34,6 +34,15 @@ void app_main()
{
esp_err_t ret;
/* Initialize NVS — it is used to store PHY calibration data */
ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
/* As the UART1/2 pin conflict with flash pin, so do matrix of the signal and pin */
uart_gpio_reset();