]> granicus.if.org Git - esp-idf/commitdiff
Examples: Demonstrate the usage of esp_err_to_name
authorRoland Dobai <dobai.roland@gmail.com>
Thu, 22 Feb 2018 13:48:53 +0000 (14:48 +0100)
committerRoland Dobai <dobai.roland@gmail.com>
Tue, 13 Mar 2018 13:27:00 +0000 (14:27 +0100)
31 files changed:
examples/bluetooth/a2dp_sink/main/main.c
examples/bluetooth/ble_adv/main/app_bt.c
examples/bluetooth/ble_eddystone/main/esp_eddystone_demo.c
examples/bluetooth/ble_ibeacon/main/ibeacon_demo.c
examples/bluetooth/ble_spp_client/main/spp_client_demo.c
examples/bluetooth/ble_spp_server/main/ble_spp_server_demo.c
examples/bluetooth/blufi/main/blufi_example_main.c
examples/bluetooth/bt_discovery/main/bt_discovery.c
examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c
examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c
examples/bluetooth/controller_hci_uart/main/controller_hci_uart_demo.c
examples/bluetooth/gatt_client/main/gattc_demo.c
examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c
examples/bluetooth/gatt_security_server/main/example_ble_sec_gatts_demo.c
examples/bluetooth/gatt_server/main/gatts_demo.c
examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c
examples/bluetooth/gattc_multi_connect/main/gattc_multi_connect.c
examples/peripherals/adc2/main/adc2_example_main.c
examples/peripherals/i2c/main/i2c_example_main.c
examples/protocols/aws_iot/subscribe_publish/main/subscribe_publish_sample.c
examples/protocols/aws_iot/thing_shadow/main/thing_shadow_sample.c
examples/protocols/mdns/main/mdns_example_main.c
examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c
examples/storage/nvs_rw_value/main/nvs_value_example_main.c
examples/storage/sd_card/main/sd_card_example_main.c
examples/storage/spiffs/main/spiffs_example_main.c
examples/storage/wear_levelling/main/wear_levelling_example_main.c
examples/system/base_mac_address/main/base_mac_address_example_main.c
examples/system/console/main/console_example_main.c
examples/system/ota/main/ota_example_main.c
examples/wifi/iperf/main/main.c

index a609338621b642be2a2ce6cdf197e29630710100..787dd45f9770698c26c68d781e6022a5ef9591b6 100644 (file)
@@ -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;
     }
 
index c843985a5089f82b08234b0cb811afeb51a6e0cb..246d87b3047f5dae268cafc8fc850a87c3d05219 100644 (file)
@@ -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;
     }
 
index 593dda1240b822aee579670fcb39768805aeb6fd..d7ff37708698f0603048da45e2c2075cba58e94a 100644 (file)
@@ -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)
 
     /*<! 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;
     }
 }
index 17c71f7b9fc6c47900c8982a08c109670ae78038..899d96fe8d08a3c38f015a845841535178c2b933 100644 (file)
@@ -62,6 +62,8 @@ static esp_ble_adv_params_t ble_adv_params = {
 
 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_ADV_DATA_RAW_SET_COMPLETE_EVT:{
 #if (IBEACON_MODE == IBEACON_SENDER)
@@ -79,14 +81,14 @@ 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(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
 }
index 1071512d824ecfd22aaff94f2a00034a9fc48c0a..fe8485ef4816441391677c1a6658f761776fcf3c 100644 (file)
@@ -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();
 }
index f81ebadc4097a940b18e525ea171300850de7714..2da39c5fe8f13d56e0e26ee725fe84073781b0ab 100644 (file)
@@ -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;
     }
 
index c16aa38d6ec619409c7597042bcf43a363d49328..6c1382ba172c7ea43e48831fac4f748fe47a14ca 100644 (file)
@@ -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;
     }
 
index dd5bb4f4445e1e2419d08f49603e35872be9a280..65671144392e1e01db3c293527b51dc2aa4c2c5c 100644 (file)
@@ -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;
     }
 
index b893dd62c151e6d1d3920c9b95cb27a6314678f9..3d9d95a5f6fb2f48ff11388a1cc4ca8275294934 100644 (file)
@@ -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;
     }
 }
index d7659f5e33e34192cee30ec85450a408a65c74fa..f4d81a14f21922b320f8c4127d25f73539003051 100644 (file)
@@ -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;
     }
 }
index 836caafbef4a4313ca10c42d778be729ac66c632..006a951b3918700d654cab6e7322997999ca07fe 100644 (file)
@@ -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;
     }
 }
index 40ea97ed236b0e360139b8d69785efbf4dfdfcd6..eac3f58ee08953dd01c302d881d5f82ee0325136 100644 (file)
@@ -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;
     }
 
index 65b29c239f0780d0817a11a479cd552ad28b1bf1..32e660bb3e5e1401f1ced9718580eb0f8ccf1074 100644 (file)
@@ -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;
     }
 
index 39762eccc34dd7719c70d192e5c3de70f48230ee..11f2563d22adbeaa04c935394574d8fe4c0ba125 100644 (file)
@@ -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;
     }
 
index a02a3e64e9b2f83be7e2b12997dad00763766412..4f413ea4539a3597b3eb5f3847412ad83731af4d 100644 (file)
@@ -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;
     }
 
index 525a734562fa9ddf95a54f6199fd94cd39e5e18e..ac9bfed96ebc6ec107df8f176c221e437a081785 100644 (file)
@@ -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;
     }
 
index 8cd1bef67b975c8b6521e5817efacdf37ba875f8..d01720754bfc9a1a486c9847b96101bd648b91f7 100644 (file)
@@ -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;
     }
 
index ed574be2bad0b2c00eeb54106ea323c0c6409c27..309053ad1a64104b395636e56307933e07bf70b7 100644 (file)
@@ -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 );
     }
 }
index 709758b55c74c834bb98ff023be14d5f1cba1544..e887355f0bf32a5442bf10fd14854eac633d09d8 100644 (file)
@@ -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);
index 398fb3c188c902ff444a0f3b8bbf441af634007a..d4e22bd1ecd28319c2370d60a85f0e722b11a03b 100644 (file)
@@ -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
index 36feb14e14369c00530a907bc18c621accd9d71e..2b489d57be7c031cc01a1f3e88a9600d4c9eb792 100644 (file)
@@ -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
index e6495b0eb87c1b94d034244e9f5baad20b1cde1d..44984c26820a9b991c06026bfa85c4e3f2a1cecf 100755 (executable)
@@ -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;
     }
 
index ad55e6b0a6845427e3d2f83658da233ac3dd10eb..8c11e72fd085d20ada664e87fdf7155efb1c8a58 100644 (file)
@@ -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();
index 0b99d6c98ff555af651840963617fb3ce42c9673..c4aa598ae1e7b5b013c609186d25658897f213f4 100644 (file)
@@ -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
index bf9b5deab9548825e95fdbeeabdc8560d9a596b8..ed35b64c694758da7e4282ae3dd428a97e60519e 100644 (file)
@@ -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;
     }
index d2ead7308b3c6105a1ba2c5a9b442264d2b7de3e..2148139a3f37c2cd0ef1ba4c22a22964bd7878e5 100644 (file)
@@ -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);
     }
index 474b608c542932f0852a66c31d5377df63041341..f797abc6e388a7064fab415a1058e8a33f675e3c 100644 (file)
@@ -37,7 +37,7 @@ void app_main(void)
     };\r
     esp_err_t err = esp_vfs_fat_spiflash_mount(base_path, "storage", &mount_config, &s_wl_handle);\r
     if (err != ESP_OK) {\r
-        ESP_LOGE(TAG, "Failed to mount FATFS (0x%x)", err);\r
+        ESP_LOGE(TAG, "Failed to mount FATFS (%s)", esp_err_to_name(err));\r
         return;\r
     }\r
     ESP_LOGI(TAG, "Opening file");\r
index 838ec0e6d0cbfc05680eba623161bf5b661da60d..c7a114bfef916dd1671d6652f9fd1fa11119c9f1 100644 (file)
@@ -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
index 65df945b7393e9399fe4e0c0f4da96dfcea47f8f..0c7e566abe0b9ed86ca39abc7e8b905106c2e9bc 100644 (file)
@@ -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);
index 44caa4a9b6e4d0b1b8c461de939c1a049b9768ba..3d8a3008d1d6e40ead4aae75f878ccbbed1bcf4f 100644 (file)
@@ -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!");
index 9553d6db0bb3d55bf1d1f8edf45c4dfe8694b638..bb4940f79b57ae61867b66ac9edc3a8fa4a0ee4f 100644 (file)
@@ -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);