Question about error codes

Hi to all,
I don't figure out how to manage error codes.
My situation is this:

I'm working with Arduino IDE using ESP32.
When I send out data using ESP-NOW system,
I check the return from send function, to check if the message is sent or not.

esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &OutMessage, sizeof(OutMessage));
   
if (result == ESP_OK) {
  Serial.println("Sent with success");
}
else {
  Serial.println(result);
}

But if I try to get the error code like this:

Serial.println(result);

I have only numeric error codes.
Is there a way to have the text? (e.g. ESP_OK)

Thanks in advance to everyone
Yomega96

if you only get zero and one, maybe it's a bool. I don't know what esp_err_t is

Hi sevenoutpinball,
the error code list of esp_err_t is the following:

ESP_OK : succeed

ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized

ESP_ERR_ESPNOW_ARG : invalid argument

ESP_ERR_ESPNOW_INTERNAL : internal error

ESP_ERR_ESPNOW_NO_MEM : out of memory

ESP_ERR_ESPNOW_NOT_FOUND : peer is not found

ESP_ERR_ESPNOW_IF : current WiFi interface doesn’t match that of peer

I don't know if this can be helpful.
BTW, the behavior is the same for every error code check.

Thanks.

Try this

Serial.println(ESP_OK);

and you will discover the number that is associated with that constant.

In all likelihood it is just true or false or 1 or 0

You could do the same for the other error codes

...R

ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized

ESP_ERR_ESPNOW_ARG : invalid argument

ESP_ERR_ESPNOW_INTERNAL : internal error

I'm guessing each of this is a bool you can check for 1 or 0. so if ESP_ERR_ESPNOW_NOT_INIT ==1 then that happened. Just keep thinking and looking things trying to trace them back to where they came from. It's always cryptic and requires effort.

sevenoutpinball:
ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized

ESP_ERR_ESPNOW_ARG : invalid argument

ESP_ERR_ESPNOW_INTERNAL : internal error

I'm guessing each of this is a bool you can check for 1 or 0. so if ESP_ERR_ESPNOW_NOT_INIT ==1 then that happened. Just keep thinking and looking things trying to trace them back to where they came from. It's always cryptic and requires effort.

Definitely not. They are surely constants against which status values returned by various functions are checked. Most likely #define(s) or enums.

That's where your experience bests mine. I am self taught in all of this stuff. But I run into this same thing myself, I can never find where these variables are defined or set. I had one today in fact, I tried doing a find on the variable and found nothing in the .h or the .cpp. So I don't know where this stuff is coming from.

grep should be your best friend.

if it only works on the command line I don't want to.

sevenoutpinball:
if it only works on the command line I don't want to.

Try Agent Ransack – Mythicsoft

With that, I found:

In esp_err.h:

#define ESP_OK          0       /*!< esp_err_t value indicating success (no error) */
#define ESP_FAIL        -1      /*!< Generic esp_err_t code indicating failure */

Later in the same file:

#define ESP_ERR_WIFI_BASE           0x3000  /*!< Starting number of WiFi error codes */

In esp_now.h:

#define ESP_ERR_ESPNOW_BASE         (ESP_ERR_WIFI_BASE + 100) /*!< ESPNOW error number base. */
#define ESP_ERR_ESPNOW_NOT_INIT     (ESP_ERR_ESPNOW_BASE + 1) /*!< ESPNOW is not initialized. */
#define ESP_ERR_ESPNOW_ARG          (ESP_ERR_ESPNOW_BASE + 2) /*!< Invalid argument */
#define ESP_ERR_ESPNOW_NO_MEM       (ESP_ERR_ESPNOW_BASE + 3) /*!< Out of memory */
#define ESP_ERR_ESPNOW_FULL         (ESP_ERR_ESPNOW_BASE + 4) /*!< ESPNOW peer list is full */
#define ESP_ERR_ESPNOW_NOT_FOUND    (ESP_ERR_ESPNOW_BASE + 5) /*!< ESPNOW peer is not found */
#define ESP_ERR_ESPNOW_INTERNAL     (ESP_ERR_ESPNOW_BASE + 6) /*!< Internal error */
#define ESP_ERR_ESPNOW_EXIST        (ESP_ERR_ESPNOW_BASE + 7) /*!< ESPNOW peer has existed */
#define ESP_ERR_ESPNOW_IF           (ESP_ERR_ESPNOW_BASE + 8) /*!< Interface error */

But, even better than a good search tool is using a Real IDE for code development --- one that will let you trace variables, functions, classes, macros, etc back to their definition. I use Eclipse / Sloeber.