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:
@@ -321,7 +321,14 @@ void app_main()
|
||||
{
|
||||
esp_err_t ret;
|
||||
|
||||
ESP_ERROR_CHECK( nvs_flash_init() );
|
||||
// Initialize NVS
|
||||
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 );
|
||||
|
||||
initialise_wifi();
|
||||
|
||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||
|
||||
Reference in New Issue
Block a user