Examples: Demonstrate the usage of esp_err_to_name

This commit is contained in:
Roland Dobai
2018-02-22 14:48:53 +01:00
parent f891eac827
commit 27a63c492f
31 changed files with 156 additions and 145 deletions

View 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

View 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);

View 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!");