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)
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.
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.
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.