From 27a63c492f289b2007731b9e6c922b61ff66ac4c Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Thu, 22 Feb 2018 14:48:53 +0100 Subject: [PATCH] Examples: Demonstrate the usage of esp_err_to_name --- examples/bluetooth/a2dp_sink/main/main.c | 17 +++++----- examples/bluetooth/ble_adv/main/app_bt.c | 10 +++--- .../ble_eddystone/main/esp_eddystone_demo.c | 12 ++++--- .../bluetooth/ble_ibeacon/main/ibeacon_demo.c | 22 ++++++------ .../ble_spp_client/main/spp_client_demo.c | 34 ++++++++++--------- .../ble_spp_server/main/ble_spp_server_demo.c | 15 ++++---- .../bluetooth/blufi/main/blufi_example_main.c | 8 ++--- .../bt_discovery/main/bt_discovery.c | 16 ++++----- .../main/example_spp_acceptor_demo.c | 24 ++++++------- .../main/example_spp_initiator_demo.c | 28 +++++++-------- .../main/controller_hci_uart_demo.c | 4 +-- .../bluetooth/gatt_client/main/gattc_demo.c | 8 ++--- .../main/example_ble_sec_gattc_demo.c | 8 ++--- .../main/example_ble_sec_gatts_demo.c | 8 ++--- .../bluetooth/gatt_server/main/gatts_demo.c | 8 ++--- .../main/gatts_table_creat_demo.c | 8 ++--- .../main/gattc_multi_connect.c | 8 ++--- .../peripherals/adc2/main/adc2_example_main.c | 7 ++-- .../peripherals/i2c/main/i2c_example_main.c | 6 ++-- .../main/subscribe_publish_sample.c | 2 +- .../thing_shadow/main/thing_shadow_sample.c | 2 +- .../protocols/mdns/main/mdns_example_main.c | 6 ++-- .../nvs_rw_blob/main/nvs_blob_example_main.c | 6 ++-- .../main/nvs_value_example_main.c | 4 +-- .../sd_card/main/sd_card_example_main.c | 4 +-- .../storage/spiffs/main/spiffs_example_main.c | 4 +-- .../main/wear_levelling_example_main.c | 2 +- .../main/base_mac_address_example_main.c | 4 +-- .../console/main/console_example_main.c | 6 ++-- examples/system/ota/main/ota_example_main.c | 8 ++--- examples/wifi/iperf/main/main.c | 2 +- 31 files changed, 156 insertions(+), 145 deletions(-) diff --git a/examples/bluetooth/a2dp_sink/main/main.c b/examples/bluetooth/a2dp_sink/main/main.c index a60933862..787dd45f9 100644 --- a/examples/bluetooth/a2dp_sink/main/main.c +++ b/examples/bluetooth/a2dp_sink/main/main.c @@ -85,24 +85,25 @@ void app_main() ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); + esp_err_t err; esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s initialize controller failed\n", __func__); + if ((err = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { + ESP_LOGE(BT_AV_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s enable controller failed\n", __func__); + if ((err = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) { + ESP_LOGE(BT_AV_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_init() != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed\n", __func__); + if ((err = esp_bluedroid_init()) != ESP_OK) { + ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_enable() != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed\n", __func__); + if ((err = esp_bluedroid_enable()) != ESP_OK) { + ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/ble_adv/main/app_bt.c b/examples/bluetooth/ble_adv/main/app_bt.c index c843985a5..246d87b30 100644 --- a/examples/bluetooth/ble_adv/main/app_bt.c +++ b/examples/bluetooth/ble_adv/main/app_bt.c @@ -223,17 +223,17 @@ void app_main() ret = esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); if (ret) { - ESP_LOGI(tag, "Bluetooth controller release classic bt memory failed"); + ESP_LOGI(tag, "Bluetooth controller release classic bt memory failed: %s", esp_err_to_name(ret)); return; } - if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { - ESP_LOGI(tag, "Bluetooth controller initialize failed"); + if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { + ESP_LOGI(tag, "Bluetooth controller initialize failed: %s", esp_err_to_name(ret)); return; } - if (esp_bt_controller_enable(ESP_BT_MODE_BLE) != ESP_OK) { - ESP_LOGI(tag, "Bluetooth controller enable failed"); + if ((ret = esp_bt_controller_enable(ESP_BT_MODE_BLE)) != ESP_OK) { + ESP_LOGI(tag, "Bluetooth controller enable failed: %s", esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/ble_eddystone/main/esp_eddystone_demo.c b/examples/bluetooth/ble_eddystone/main/esp_eddystone_demo.c index 593dda124..d7ff37708 100644 --- a/examples/bluetooth/ble_eddystone/main/esp_eddystone_demo.c +++ b/examples/bluetooth/ble_eddystone/main/esp_eddystone_demo.c @@ -79,6 +79,8 @@ static void esp_eddystone_show_inform(const esp_eddystone_result_t* res) static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param) { + esp_err_t err; + switch(event) { case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: { @@ -87,8 +89,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* par break; } case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT: { - if(param->scan_start_cmpl.status != ESP_BT_STATUS_SUCCESS) { - ESP_LOGE(DEMO_TAG,"Scan start failed"); + if((err = param->scan_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(DEMO_TAG,"Scan start failed: %s", esp_err_to_name(err)); } else { ESP_LOGI(DEMO_TAG,"Start scanning..."); @@ -124,8 +126,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* par break; } case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:{ - if(param->scan_stop_cmpl.status != ESP_BT_STATUS_SUCCESS) { - ESP_LOGE(DEMO_TAG,"Scan stop failed"); + if((err = param->scan_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(DEMO_TAG,"Scan stop failed: %s", esp_err_to_name(err)); } else { ESP_LOGI(DEMO_TAG,"Stop scan successfully"); @@ -145,7 +147,7 @@ void esp_eddystone_appRegister(void) /*scan_start_cmpl.status != ESP_BT_STATUS_SUCCESS) { - ESP_LOGE(DEMO_TAG, "Scan start failed"); + if ((err = param->scan_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(DEMO_TAG, "Scan start failed: %s", esp_err_to_name(err)); } break; case ESP_GAP_BLE_ADV_START_COMPLETE_EVT: //adv start complete event to indicate adv start successfully or failed - if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) { - ESP_LOGE(DEMO_TAG, "Adv start 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)); } break; case ESP_GAP_BLE_SCAN_RESULT_EVT: { @@ -115,8 +117,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par } case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT: - if (param->scan_stop_cmpl.status != ESP_BT_STATUS_SUCCESS){ - ESP_LOGE(DEMO_TAG, "Scan stop failed"); + if ((err = param->scan_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS){ + ESP_LOGE(DEMO_TAG, "Scan stop failed: %s", esp_err_to_name(err)); } else { ESP_LOGI(DEMO_TAG, "Stop scan successfully"); @@ -124,8 +126,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par break; case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: - if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS){ - ESP_LOGE(DEMO_TAG, "Adv stop failed"); + 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, "Stop adv successfully"); @@ -146,7 +148,7 @@ void ble_ibeacon_appRegister(void) //register the scan callback function to the gap module if ((status = esp_ble_gap_register_callback(esp_gap_cb)) != ESP_OK) { - ESP_LOGE(DEMO_TAG, "gap register error, error code = %x", status); + ESP_LOGE(DEMO_TAG, "gap register error: %s", esp_err_to_name(status)); return; } @@ -180,7 +182,7 @@ void app_main() esp_ble_gap_config_adv_data_raw((uint8_t*)&ibeacon_adv_data, sizeof(ibeacon_adv_data)); } else { - ESP_LOGE(DEMO_TAG, "Config iBeacon data failed, status =0x%x\n", status); + ESP_LOGE(DEMO_TAG, "Config iBeacon data failed: %s\n", esp_err_to_name(status)); } #endif } diff --git a/examples/bluetooth/ble_spp_client/main/spp_client_demo.c b/examples/bluetooth/ble_spp_client/main/spp_client_demo.c index 1071512d8..fe8485ef4 100644 --- a/examples/bluetooth/ble_spp_client/main/spp_client_demo.c +++ b/examples/bluetooth/ble_spp_client/main/spp_client_demo.c @@ -205,11 +205,12 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par { uint8_t *adv_name = NULL; uint8_t adv_name_len = 0; + esp_err_t err; switch(event){ case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: { - if(param->scan_param_cmpl.status != ESP_BT_STATUS_SUCCESS){ - ESP_LOGE(GATTC_TAG, "Scan param set failed"); + if((err = param->scan_param_cmpl.status) != ESP_BT_STATUS_SUCCESS){ + ESP_LOGE(GATTC_TAG, "Scan param set failed: %s", esp_err_to_name(err)); break; } //the unit of the duration is second @@ -220,15 +221,15 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par } case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT: //scan start complete event to indicate scan start successfully or failed - if (param->scan_start_cmpl.status != ESP_BT_STATUS_SUCCESS) { - ESP_LOGE(GATTC_TAG, "Scan start failed"); + if ((err = param->scan_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(GATTC_TAG, "Scan start failed: %s", esp_err_to_name(err)); break; } ESP_LOGI(GATTC_TAG, "Scan start successed"); break; case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT: - if (param->scan_stop_cmpl.status != ESP_BT_STATUS_SUCCESS) { - ESP_LOGE(GATTC_TAG, "Scan stop failed"); + if ((err = param->scan_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(GATTC_TAG, "Scan stop failed: %s", esp_err_to_name(err)); break; } ESP_LOGI(GATTC_TAG, "Scan stop successed"); @@ -262,8 +263,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par break; } case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: - if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS){ - ESP_LOGE(GATTC_TAG, "Adv stop failed"); + if ((err = param->adv_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS){ + ESP_LOGE(GATTC_TAG, "Adv stop failed: %s", esp_err_to_name(err)); }else { ESP_LOGI(GATTC_TAG, "Stop adv successfully"); } @@ -510,24 +511,25 @@ void spp_heart_beat_task(void * arg) void ble_client_appRegister(void) { esp_err_t status; + char err_msg[20]; ESP_LOGI(GATTC_TAG, "register callback"); //register the scan callback function to the gap module if ((status = esp_ble_gap_register_callback(esp_gap_cb)) != ESP_OK) { - ESP_LOGE(GATTC_TAG, "gap register error, error code = %x", status); + ESP_LOGE(GATTC_TAG, "gap register error: %s", esp_err_to_name_r(status, err_msg, sizeof(err_msg))); return; } //register the callback function to the gattc module if ((status = esp_ble_gattc_register_callback(esp_gattc_cb)) != ESP_OK) { - ESP_LOGE(GATTC_TAG, "gattc register error, error code = %x", status); + ESP_LOGE(GATTC_TAG, "gattc register error: %s", esp_err_to_name_r(status, err_msg, sizeof(err_msg))); return; } esp_ble_gattc_app_register(PROFILE_APP_ID); esp_err_t local_mtu_ret = esp_ble_gatt_set_local_mtu(200); if (local_mtu_ret){ - ESP_LOGE(GATTC_TAG, "set local MTU failed, error code = %x", local_mtu_ret); + ESP_LOGE(GATTC_TAG, "set local MTU failed: %s", esp_err_to_name_r(local_mtu_ret, err_msg, sizeof(err_msg))); } cmd_reg_queue = xQueueCreate(10, sizeof(uint32_t)); @@ -606,28 +608,28 @@ void app_main() nvs_flash_init(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable controller failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable controller failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ESP_LOGI(GATTC_TAG, "%s init bluetooth\n", __func__); ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s init bluetooth failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } - + ble_client_appRegister(); spp_uart_init(); } diff --git a/examples/bluetooth/ble_spp_server/main/ble_spp_server_demo.c b/examples/bluetooth/ble_spp_server/main/ble_spp_server_demo.c index f81ebadc4..2da39c5fe 100644 --- a/examples/bluetooth/ble_spp_server/main/ble_spp_server_demo.c +++ b/examples/bluetooth/ble_spp_server/main/ble_spp_server_demo.c @@ -461,7 +461,8 @@ static void spp_task_init(void) static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) { - ESP_LOGI(GATTS_TABLE_TAG, "GAP_EVT, event %d\n", event); + esp_err_t err; + ESP_LOGE(GATTS_TABLE_TAG, "GAP_EVT, event %d\n", event); switch (event) { case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT: @@ -469,8 +470,8 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param break; case ESP_GAP_BLE_ADV_START_COMPLETE_EVT: //advertising start complete event to indicate advertising start successfully or failed - if(param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) { - ESP_LOGE(GATTS_TABLE_TAG, "Advertising start failed\n"); + if((err = param->adv_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(GATTS_TABLE_TAG, "Advertising start failed: %s\n", esp_err_to_name(err)); } break; default: @@ -664,25 +665,25 @@ void app_main() ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth\n", __func__); ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed\n", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed\n", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/blufi/main/blufi_example_main.c b/examples/bluetooth/blufi/main/blufi_example_main.c index c16aa38d6..6c1382ba1 100644 --- a/examples/bluetooth/blufi/main/blufi_example_main.c +++ b/examples/bluetooth/blufi/main/blufi_example_main.c @@ -380,24 +380,24 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - BLUFI_ERROR("%s initialize bt controller failed\n", __func__); + BLUFI_ERROR("%s initialize bt controller failed: %s\n", __func__, esp_err_to_name(ret)); } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - BLUFI_ERROR("%s enable bt controller failed\n", __func__); + BLUFI_ERROR("%s enable bt controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_init(); if (ret) { - BLUFI_ERROR("%s init bluedroid failed\n", __func__); + BLUFI_ERROR("%s init bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - BLUFI_ERROR("%s init bluedroid failed\n", __func__); + BLUFI_ERROR("%s init bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/bt_discovery/main/bt_discovery.c b/examples/bluetooth/bt_discovery/main/bt_discovery.c index dd5bb4f44..656711443 100644 --- a/examples/bluetooth/bt_discovery/main/bt_discovery.c +++ b/examples/bluetooth/bt_discovery/main/bt_discovery.c @@ -280,23 +280,23 @@ void app_main() ESP_ERROR_CHECK( ret ); esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { - ESP_LOGE(GAP_TAG, "%s initialize controller failed\n", __func__); + if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { + ESP_LOGE(GAP_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bt_controller_enable(ESP_BT_MODE_BTDM) != ESP_OK) { - ESP_LOGE(GAP_TAG, "%s enable controller failed\n", __func__); + if ((ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM)) != ESP_OK) { + ESP_LOGE(GAP_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_init() != ESP_OK) { - ESP_LOGE(GAP_TAG, "%s initialize bluedroid failed\n", __func__); + if ((ret = esp_bluedroid_init()) != ESP_OK) { + ESP_LOGE(GAP_TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_enable() != ESP_OK) { - ESP_LOGE(GAP_TAG, "%s enable bluedroid failed\n", __func__); + if ((ret = esp_bluedroid_enable()) != ESP_OK) { + ESP_LOGE(GAP_TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c b/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c index b893dd62c..3d9d95a5f 100644 --- a/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c +++ b/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c @@ -116,33 +116,33 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s initialize controller failed\n", __func__); + if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s enable controller failed\n", __func__); + if ((ret = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_init() != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed\n", __func__); + if ((ret = esp_bluedroid_init()) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_enable() != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s enable bluedroid failed\n", __func__); + if ((ret = esp_bluedroid_enable()) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_spp_register_callback(esp_spp_cb) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s spp register failed\n", __func__); + if ((ret = esp_spp_register_callback(esp_spp_cb)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s spp register failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_spp_init(esp_spp_mode) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s spp init failed\n", __func__); + if ((ret = esp_spp_init(esp_spp_mode)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s spp init failed: %s\n", __func__, esp_err_to_name(ret)); return; } } diff --git a/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c b/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c index d7659f5e3..f4d81a14f 100644 --- a/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c +++ b/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c @@ -210,38 +210,38 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s initialize controller failed\n", __func__); + if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s enable controller failed\n", __func__); + if ((ret = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_init() != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed\n", __func__); + if ((ret = esp_bluedroid_init()) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bluedroid_enable() != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s enable bluedroid failed\n", __func__); + if ((ret = esp_bluedroid_enable()) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_bt_gap_register_callback(esp_bt_gap_cb) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s gap register failed\n", __func__); + if ((ret = esp_bt_gap_register_callback(esp_bt_gap_cb)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s gap register failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_spp_register_callback(esp_spp_cb) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s spp register failed\n", __func__); + if ((ret = esp_spp_register_callback(esp_spp_cb)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s spp register failed: %s\n", __func__, esp_err_to_name(ret)); return; } - if (esp_spp_init(esp_spp_mode) != ESP_OK) { - ESP_LOGE(SPP_TAG, "%s spp init failed\n", __func__); + if ((ret = esp_spp_init(esp_spp_mode)) != ESP_OK) { + ESP_LOGE(SPP_TAG, "%s spp init failed: %s\n", __func__, esp_err_to_name(ret)); return; } } diff --git a/examples/bluetooth/controller_hci_uart/main/controller_hci_uart_demo.c b/examples/bluetooth/controller_hci_uart/main/controller_hci_uart_demo.c index 836caafbe..006a951b3 100644 --- a/examples/bluetooth/controller_hci_uart/main/controller_hci_uart_demo.c +++ b/examples/bluetooth/controller_hci_uart/main/controller_hci_uart_demo.c @@ -50,13 +50,13 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret != ESP_OK) { - ESP_LOGE(tag, "Bluetooth Controller initialize failed, ret %d", ret); + ESP_LOGE(tag, "Bluetooth Controller initialize failed: %s", esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM); if (ret != ESP_OK) { - ESP_LOGE(tag, "Bluetooth Controller initialize failed, ret %d", ret); + ESP_LOGE(tag, "Bluetooth Controller initialize failed: %s", esp_err_to_name(ret)); return; } } diff --git a/examples/bluetooth/gatt_client/main/gattc_demo.c b/examples/bluetooth/gatt_client/main/gattc_demo.c index 40ea97ed2..eac3f58ee 100644 --- a/examples/bluetooth/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/gatt_client/main/gattc_demo.c @@ -424,25 +424,25 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTC_TAG, "%s initialize controller failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable controller failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s init bluetooth failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c b/examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c index 65b29c239..32e660bb3 100644 --- a/examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c +++ b/examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c @@ -467,25 +467,25 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTC_TAG, "%s initialize controller failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable controller failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s init bluetooth failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed, error code = %x\n", __func__, ret); + ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/gatt_security_server/main/example_ble_sec_gatts_demo.c b/examples/bluetooth/gatt_security_server/main/example_ble_sec_gatts_demo.c index 39762eccc..11f2563d2 100644 --- a/examples/bluetooth/gatt_security_server/main/example_ble_sec_gatts_demo.c +++ b/examples/bluetooth/gatt_security_server/main/example_ble_sec_gatts_demo.c @@ -475,24 +475,24 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s init controller failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s init controller failed: %s", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret)); return; } ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__); ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed: %s", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/gatt_server/main/gatts_demo.c b/examples/bluetooth/gatt_server/main/gatts_demo.c index a02a3e64e..4f413ea45 100644 --- a/examples/bluetooth/gatt_server/main/gatts_demo.c +++ b/examples/bluetooth/gatt_server/main/gatts_demo.c @@ -690,23 +690,23 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTS_TAG, "%s initialize controller failed\n", __func__); + ESP_LOGE(GATTS_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTS_TAG, "%s enable controller failed\n", __func__); + ESP_LOGE(GATTS_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTS_TAG, "%s init bluetooth failed\n", __func__); + ESP_LOGE(GATTS_TAG, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTS_TAG, "%s enable bluetooth failed\n", __func__); + ESP_LOGE(GATTS_TAG, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c b/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c index 525a73456..ac9bfed96 100644 --- a/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c +++ b/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c @@ -523,25 +523,25 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed", __func__); + ESP_LOGE(GATTS_TABLE_TAG, "%s enable bluetooth failed: %s", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/bluetooth/gattc_multi_connect/main/gattc_multi_connect.c b/examples/bluetooth/gattc_multi_connect/main/gattc_multi_connect.c index 8cd1bef67..d01720754 100644 --- a/examples/bluetooth/gattc_multi_connect/main/gattc_multi_connect.c +++ b/examples/bluetooth/gattc_multi_connect/main/gattc_multi_connect.c @@ -895,25 +895,25 @@ void app_main() esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ret = esp_bt_controller_init(&bt_cfg); if (ret) { - ESP_LOGE(GATTC_TAG, "%s initialize controller failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable controller failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_init(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s init bluetooth failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { - ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed\n", __func__); + ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(ret)); return; } diff --git a/examples/peripherals/adc2/main/adc2_example_main.c b/examples/peripherals/adc2/main/adc2_example_main.c index ed574be2b..309053ad1 100644 --- a/examples/peripherals/adc2/main/adc2_example_main.c +++ b/examples/peripherals/adc2/main/adc2_example_main.c @@ -49,11 +49,14 @@ void app_main(void) if ( r == ESP_OK ) { printf("%d: %d\n", output_data, read_raw ); } else if ( r == ESP_ERR_INVALID_STATE ) { - printf("ADC2 not initialized yet.\n"); + printf("%s: ADC2 not initialized yet.\n", esp_err_to_name(r)); } else if ( r == ESP_ERR_TIMEOUT ) { //This can not happen in this example. But if WiFi is in use, such error code could be returned. - printf("ADC2 is in use by Wi-Fi.\n"); + printf("%s: ADC2 is in use by Wi-Fi.\n", esp_err_to_name(r)); + } else { + printf("%s\n", esp_err_to_name(r)); } + vTaskDelay( 2 * portTICK_PERIOD_MS ); } } diff --git a/examples/peripherals/i2c/main/i2c_example_main.c b/examples/peripherals/i2c/main/i2c_example_main.c index 709758b55..e887355f0 100644 --- a/examples/peripherals/i2c/main/i2c_example_main.c +++ b/examples/peripherals/i2c/main/i2c_example_main.c @@ -238,7 +238,7 @@ static void i2c_test_task(void* arg) printf("data_l: %02x\n", sensor_data_l); printf("sensor val: %f\n", (sensor_data_h << 8 | sensor_data_l) / 1.2); } else { - printf("No ack, sensor not connected...skip...\n"); + printf("%s: No ack, sensor not connected...skip...\n", esp_err_to_name(ret)); } xSemaphoreGive(print_mux); vTaskDelay(( DELAY_TIME_BETWEEN_ITEMS_MS * ( task_idx + 1 ) ) / portTICK_RATE_MS); @@ -267,7 +267,7 @@ static void i2c_test_task(void* arg) printf("====TASK[%d] Master read ====\n", task_idx); disp_buf(data_rd, d_size); } else { - printf("Master read slave error, IO not connected...\n"); + printf("%s: Master read slave error, IO not connected...\n", esp_err_to_name(ret)); } xSemaphoreGive(print_mux); vTaskDelay(( DELAY_TIME_BETWEEN_ITEMS_MS * ( task_idx + 1 ) ) / portTICK_RATE_MS); @@ -293,7 +293,7 @@ static void i2c_test_task(void* arg) printf("----TASK[%d] Slave read: [%d] bytes ----\n", task_idx, size); disp_buf(data, size); } else { - printf("TASK[%d] Master write slave error, IO not connected....\n", task_idx); + printf("TASK[%d] %s: Master write slave error, IO not connected....\n", task_idx, esp_err_to_name(ret)); } xSemaphoreGive(print_mux); vTaskDelay(( DELAY_TIME_BETWEEN_ITEMS_MS * ( task_idx + 1 ) ) / portTICK_RATE_MS); diff --git a/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c b/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c index 398fb3c18..d4e22bd1e 100644 --- a/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c +++ b/examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c @@ -205,7 +205,7 @@ void aws_iot_task(void *param) { sdmmc_card_t* card; esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card); if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem."); + ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret)); abort(); } #endif diff --git a/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c b/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c index 36feb14e1..2b489d57b 100644 --- a/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c +++ b/examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c @@ -239,7 +239,7 @@ void aws_iot_task(void *param) { sdmmc_card_t* card; esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card); if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem."); + ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret)); abort(); } #endif diff --git a/examples/protocols/mdns/main/mdns_example_main.c b/examples/protocols/mdns/main/mdns_example_main.c index e6495b0eb..44984c268 100755 --- a/examples/protocols/mdns/main/mdns_example_main.c +++ b/examples/protocols/mdns/main/mdns_example_main.c @@ -162,7 +162,7 @@ static void query_mdns_service(const char * service_name, const char * proto) mdns_result_t * results = NULL; esp_err_t err = mdns_query_ptr(service_name, proto, 3000, 20, &results); if(err){ - ESP_LOGE(TAG, "Query Failed"); + ESP_LOGE(TAG, "Query Failed: %s", esp_err_to_name(err)); return; } if(!results){ @@ -184,10 +184,10 @@ static void query_mdns_host(const char * host_name) esp_err_t err = mdns_query_a(host_name, 2000, &addr); if(err){ if(err == ESP_ERR_NOT_FOUND){ - ESP_LOGW(TAG, "Host was not found!"); + ESP_LOGW(TAG, "%s: Host was not found!", esp_err_to_name(err)); return; } - ESP_LOGE(TAG, "Query Failed"); + ESP_LOGE(TAG, "Query Failed: %s", esp_err_to_name(err)); return; } diff --git a/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c b/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c index ad55e6b0a..8c11e72fd 100644 --- a/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c +++ b/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c @@ -156,10 +156,10 @@ void app_main() ESP_ERROR_CHECK( err ); err = print_what_saved(); - if (err != ESP_OK) printf("Error (%d) reading data from NVS!\n", err); + if (err != ESP_OK) printf("Error (%s) reading data from NVS!\n", esp_err_to_name(err)); err = save_restart_counter(); - if (err != ESP_OK) printf("Error (%d) saving restart counter to NVS!\n", err); + if (err != ESP_OK) printf("Error (%s) saving restart counter to NVS!\n", esp_err_to_name(err)); gpio_pad_select_gpio(GPIO_NUM_0); gpio_set_direction(GPIO_NUM_0, GPIO_MODE_DEF_INPUT); @@ -172,7 +172,7 @@ void app_main() vTaskDelay(1000 / portTICK_PERIOD_MS); if(gpio_get_level(GPIO_NUM_0) == 0) { err = save_run_time(); - if (err != ESP_OK) printf("Error (%d) saving run time blob to NVS!\n", err); + if (err != ESP_OK) printf("Error (%s) saving run time blob to NVS!\n", esp_err_to_name(err)); printf("Restarting...\n"); fflush(stdout); esp_restart(); diff --git a/examples/storage/nvs_rw_value/main/nvs_value_example_main.c b/examples/storage/nvs_rw_value/main/nvs_value_example_main.c index 0b99d6c98..c4aa598ae 100644 --- a/examples/storage/nvs_rw_value/main/nvs_value_example_main.c +++ b/examples/storage/nvs_rw_value/main/nvs_value_example_main.c @@ -34,7 +34,7 @@ void app_main() nvs_handle my_handle; err = nvs_open("storage", NVS_READWRITE, &my_handle); if (err != ESP_OK) { - printf("Error (%d) opening NVS handle!\n", err); + printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err)); } else { printf("Done\n"); @@ -51,7 +51,7 @@ void app_main() printf("The value is not initialized yet!\n"); break; default : - printf("Error (%d) reading!\n", err); + printf("Error (%s) reading!\n", esp_err_to_name(err)); } // Write diff --git a/examples/storage/sd_card/main/sd_card_example_main.c b/examples/storage/sd_card/main/sd_card_example_main.c index bf9b5deab..ed35b64c6 100644 --- a/examples/storage/sd_card/main/sd_card_example_main.c +++ b/examples/storage/sd_card/main/sd_card_example_main.c @@ -97,8 +97,8 @@ void app_main(void) ESP_LOGE(TAG, "Failed to mount filesystem. " "If you want the card to be formatted, set format_if_mount_failed = true."); } else { - ESP_LOGE(TAG, "Failed to initialize the card (%d). " - "Make sure SD card lines have pull-up resistors in place.", ret); + ESP_LOGE(TAG, "Failed to initialize the card (%s). " + "Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret)); } return; } diff --git a/examples/storage/spiffs/main/spiffs_example_main.c b/examples/storage/spiffs/main/spiffs_example_main.c index d2ead7308..2148139a3 100644 --- a/examples/storage/spiffs/main/spiffs_example_main.c +++ b/examples/storage/spiffs/main/spiffs_example_main.c @@ -37,7 +37,7 @@ void app_main(void) } else if (ret == ESP_ERR_NOT_FOUND) { ESP_LOGE(TAG, "Failed to find SPIFFS partition"); } else { - ESP_LOGE(TAG, "Failed to initialize SPIFFS (%d)", ret); + ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret)); } return; } @@ -45,7 +45,7 @@ void app_main(void) size_t total = 0, used = 0; ret = esp_spiffs_info(NULL, &total, &used); if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to get SPIFFS partition information"); + ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret)); } else { ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used); } diff --git a/examples/storage/wear_levelling/main/wear_levelling_example_main.c b/examples/storage/wear_levelling/main/wear_levelling_example_main.c index 474b608c5..f797abc6e 100644 --- a/examples/storage/wear_levelling/main/wear_levelling_example_main.c +++ b/examples/storage/wear_levelling/main/wear_levelling_example_main.c @@ -37,7 +37,7 @@ void app_main(void) }; esp_err_t err = esp_vfs_fat_spiflash_mount(base_path, "storage", &mount_config, &s_wl_handle); if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to mount FATFS (0x%x)", err); + ESP_LOGE(TAG, "Failed to mount FATFS (%s)", esp_err_to_name(err)); return; } ESP_LOGI(TAG, "Opening file"); diff --git a/examples/system/base_mac_address/main/base_mac_address_example_main.c b/examples/system/base_mac_address/main/base_mac_address_example_main.c index 838ec0e6d..c7a114bfe 100644 --- a/examples/system/base_mac_address/main/base_mac_address_example_main.c +++ b/examples/system/base_mac_address/main/base_mac_address_example_main.c @@ -40,7 +40,7 @@ void app_main() /* Get base MAC address from BLK3 of EFUSE */ ret = esp_efuse_mac_get_custom(mac_addr); if (ret != ESP_OK) { - ESP_LOGE(TAG, "Get base MAC address from BLK3 of EFUSE error"); + ESP_LOGE(TAG, "Get base MAC address from BLK3 of EFUSE error (%s)", esp_err_to_name(ret)); /* If get custom base MAC address error, the application developer can decide what to do: * abort or use the default base MAC address which is stored in BLK0 of EFUSE by doing * nothing. @@ -67,7 +67,7 @@ void app_main() ESP_LOGI(TAG, "Use base MAC address which is stored in other external storage(flash, EEPROM, etc)"); } else { - ESP_LOGI(TAG, "Use base MAC address which is stored in BLK0 of EFUSE"); + ESP_LOGI(TAG, "Use base MAC address which is stored in BLK0 of EFUSE (%s)", esp_err_to_name(ret)); } #endif//CONFIG_BASE_MAC_STORED_OTHER_EXTERNAL_STORAGE #else diff --git a/examples/system/console/main/console_example_main.c b/examples/system/console/main/console_example_main.c index 65df945b7..0c7e566ab 100644 --- a/examples/system/console/main/console_example_main.c +++ b/examples/system/console/main/console_example_main.c @@ -41,7 +41,7 @@ static void initialize_filesystem() }; esp_err_t err = esp_vfs_fat_spiflash_mount(MOUNT_PATH, "storage", &mount_config, &wl_handle); if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to mount FATFS (0x%x)", err); + ESP_LOGE(TAG, "Failed to mount FATFS (%s)", esp_err_to_name(err)); return; } } @@ -170,9 +170,9 @@ void app_main() } else if (err == ESP_ERR_INVALID_ARG) { // command was empty } else if (err == ESP_OK && ret != ESP_OK) { - printf("Command returned non-zero error code: 0x%x\n", ret); + printf("Command returned non-zero error code: 0x%x (%s)\n", ret, esp_err_to_name(err)); } else if (err != ESP_OK) { - printf("Internal error: 0x%x\n", err); + printf("Internal error: %s\n", esp_err_to_name(err)); } /* linenoise allocates line buffer on the heap, so need to free it */ linenoiseFree(line); diff --git a/examples/system/ota/main/ota_example_main.c b/examples/system/ota/main/ota_example_main.c index 44caa4a9b..3d8a3008d 100644 --- a/examples/system/ota/main/ota_example_main.c +++ b/examples/system/ota/main/ota_example_main.c @@ -120,7 +120,7 @@ static bool read_past_http_header(char text[], int total_len, esp_ota_handle_t u esp_err_t err = esp_ota_write( update_handle, (const void *)ota_write_data, i_write_len); if (err != ESP_OK) { - ESP_LOGE(TAG, "Error: esp_ota_write failed! err=0x%x", err); + ESP_LOGE(TAG, "Error: esp_ota_write failed (%s)!", esp_err_to_name(err)); return false; } else { ESP_LOGI(TAG, "esp_ota_write header OK"); @@ -240,7 +240,7 @@ static void ota_example_task(void *pvParameter) err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle); if (err != ESP_OK) { - ESP_LOGE(TAG, "esp_ota_begin failed, error=%d", err); + ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err)); task_fatal_error(); } ESP_LOGI(TAG, "esp_ota_begin succeeded"); @@ -261,7 +261,7 @@ static void ota_example_task(void *pvParameter) memcpy(ota_write_data, text, buff_len); err = esp_ota_write( update_handle, (const void *)ota_write_data, buff_len); if (err != ESP_OK) { - ESP_LOGE(TAG, "Error: esp_ota_write failed! err=0x%x", err); + ESP_LOGE(TAG, "Error: esp_ota_write failed (%s)!", esp_err_to_name(err)); task_fatal_error(); } binary_file_length += buff_len; @@ -283,7 +283,7 @@ static void ota_example_task(void *pvParameter) } err = esp_ota_set_boot_partition(update_partition); if (err != ESP_OK) { - ESP_LOGE(TAG, "esp_ota_set_boot_partition failed! err=0x%x", err); + ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err)); task_fatal_error(); } ESP_LOGI(TAG, "Prepare to restart system!"); diff --git a/examples/wifi/iperf/main/main.c b/examples/wifi/iperf/main/main.c index 9553d6db0..bb4940f79 100644 --- a/examples/wifi/iperf/main/main.c +++ b/examples/wifi/iperf/main/main.c @@ -135,7 +135,7 @@ void app_main(void) } else if (err == ESP_OK && ret != ESP_OK) { printf("Command returned non-zero error code: 0x%x\n", ret); } else if (err != ESP_OK) { - printf("Internal error: 0x%x\n", err); + printf("Internal error: %s\n", esp_err_to_name(err)); } /* linenoise allocates line buffer on the heap, so need to free it */ linenoiseFree(line);