diff --git a/include/zh_espnow.h b/include/zh_espnow.h index 5213dc5..34ef316 100644 --- a/include/zh_espnow.h +++ b/include/zh_espnow.h @@ -128,6 +128,22 @@ extern "C" */ 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 \ No newline at end of file diff --git a/version.txt b/version.txt index 589268e..e21e727 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.3.0 \ No newline at end of file +1.4.0 \ No newline at end of file diff --git a/zh_espnow.c b/zh_espnow.c index 5b45469..4d7fb1c 100755 --- a/zh_espnow.c +++ b/zh_espnow.c @@ -521,4 +521,18 @@ void zh_espnow_reset_stats(void) 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; } \ No newline at end of file