3 Commits

Author SHA1 Message Date
da9da77890 feat: added get/set attemps 2025-05-06 09:31:46 +03:00
17deb9f895 feat: added get initialization status 2025-05-06 09:07:52 +03:00
cedea19f1a feat: added reset statistics 2025-05-06 08:58:28 +03:00
3 changed files with 56 additions and 1 deletions

View File

@ -116,6 +116,34 @@ extern "C"
*/
const zh_espnow_stats_t *zh_espnow_get_stats(void);
/**
* @brief Reset ESP-NOW statistics.
*/
void zh_espnow_reset_stats(void);
/**
* @brief Check ESP-NOW initialization status.
*
* @return true if ESP-NOW is initialized false otherwise.
*/
bool zh_espnow_is_initialized(void);
/**
* @brief Get number of attempts.
*
* @return Attemps number.
*/
uint8_t zh_espnow_get_attempts(void);
/**
* @brief Set number of attempts.
*
* @param[in] attempts Attemps number.
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_espnow_set_attempts(uint8_t attempts);
#ifdef __cplusplus
}
#endif

View File

@ -1 +1 @@
1.1.2
1.4.0

View File

@ -509,3 +509,30 @@ const zh_espnow_stats_t *zh_espnow_get_stats(void)
{
return &_stats;
}
void zh_espnow_reset_stats(void)
{
_stats.sent_success = 0;
_stats.sent_fail = 0;
_stats.received = 0;
ZH_ESPNOW_LOGI("ESP-NOW statistic reset successfully.");
}
bool zh_espnow_is_initialized(void)
{
return _is_initialized;
}
uint8_t zh_espnow_get_attempts(void)
{
return _init_config.attempts;
}
esp_err_t zh_espnow_set_attempts(uint8_t attempts)
{
ZH_ESPNOW_CHECK(_is_initialized == true, ESP_ERR_INVALID_STATE, "ESP-NOW is not initialized.");
ZH_ESPNOW_CHECK(attempts > 0, ESP_ERR_INVALID_ARG, "Invalid number of attempts.");
_init_config.attempts = attempts;
ZH_ESPNOW_LOGI("Number of attempts set successfully.");
return ESP_OK;
}