Utils API
Utils layer related APIs for ESP-NOW.
API Reference
Header File
Functions
-
esp_err_t espnow_reboot(TickType_t wait_ticks)
Reboot the chip after a delay.
This API just starts an esp_timer and executes a reboot from that. Useful if you want to reboot after a delay, to allow other tasks to finish their operations (Eg. MQTT publish to indicate OTA success)
- Parameters:
wait_ticks – [in] time in ticks after which the chip should reboot
- Returns:
ESP_OK
ESP_FAIL
-
int espnow_reboot_unbroken_count(void)
Get the number of consecutive restarts.
- Returns:
count
-
int espnow_reboot_total_count(void)
Get the number of restarts.
- Returns:
count
-
bool espnow_reboot_is_exception(bool erase_coredump)
Determine if the restart is caused by an exception.
- Parameters:
erase_coredump – [in] erase all coredump partition
- Returns:
true
false
-
esp_err_t espnow_timesync_start(void)
Initialize time synchronization.
This API initializes SNTP for time synchronization.
- Returns:
ESP_OK
ESP_FAIL
-
bool espnow_timesync_check(void)
Check if current time is updated.
This API checks if the current system time is updated against the reference time of 1-Jan-2020.
- Returns:
true if time is updated
false if time is not updated
-
esp_err_t espnow_timesync_wait(uint32_t wait_ms)
Wait for time synchronization.
This API waits for the system time to be updated against the reference time of 1-Jan-2020. This is a blocking call.
- Parameters:
wait_ms – [in] number of ticks to wait for time synchronization.
- Returns:
ESP_OK
-
void espnow_print_system_info(uint32_t interval_ms)
Interval printing system information.
- Parameters:
interval_ms – [in] interval of printing system log information
-
uint8_t *espnow_mac_str2hex(const char *mac_str, uint8_t *mac_hex)
Convert MAC from string to hex.
- Parameters:
mac_str – [in] mac address string in format MACSTR
mac_hex – [out] mac address array in hex
- Returns:
NULL: fail
mac_hex: success
Structures
Macros
-
ESP_ERROR_RETURN(con, err, format, ...)
Macro which can be used to check the error code, and terminate the program in case the code is not ESP_OK. Prints the error code, error location, and the failed statement to serial output.
Disabled if assertions are disabled.
-
ESP_ERROR_ASSERT(err)
Macro serves similar purpose as
assert
, except that it checksesp_err_t
value rather than abool
condition. If the argument ofESP_ERROR_ASSERT
is not equalESP_OK
, then an error message is printed on the console, andabort()
is called.Note
If
IDF monitor
is used, addresses in the backtrace will be converted to file names and line numbers.- Parameters:
err – [in] [description]
- Returns:
[description]
-
ESP_ERROR_GOTO(con, lable, format, ...)
-
ESP_ERROR_CONTINUE(con, format, ...)
-
ESP_ERROR_BREAK(con, format, ...)
-
ESP_PARAM_CHECK(con)
Type Definitions
-
typedef struct espnow_time_config_s espnow_time_config_t
The SNTP server configuration.