Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
da9da77890 | |||
17deb9f895 | |||
cedea19f1a | |||
7d1653b076 |
@ -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
|
@ -1 +1 @@
|
||||
1.1.1
|
||||
1.4.0
|
29
zh_espnow.c
29
zh_espnow.c
@ -459,7 +459,7 @@ static void _zh_espnow_process_recv(_queue_t *queue)
|
||||
ZH_ESPNOW_LOGI("Processing incoming ESP-NOW data from MAC %02X:%02X:%02X:%02X:%02X:%02X started.", MAC2STR(queue->data.mac_addr));
|
||||
zh_espnow_event_on_recv_t *recv_data = (zh_espnow_event_on_recv_t *)&queue->data;
|
||||
++_stats.received;
|
||||
esp_err_t err = esp_event_post(ZH_ESPNOW, ZH_ESPNOW_ON_RECV_EVENT, recv_data, recv_data->data_len + sizeof(recv_data->mac_addr) + sizeof(uint8_t), portTICK_PERIOD_MS);
|
||||
esp_err_t err = esp_event_post(ZH_ESPNOW, ZH_ESPNOW_ON_RECV_EVENT, recv_data, sizeof(zh_espnow_event_on_recv_t), portTICK_PERIOD_MS);
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
ZH_ESPNOW_LOGI("Incoming ESP-NOW data from MAC %02X:%02X:%02X:%02X:%02X:%02X processed successfully.", MAC2STR(queue->data.mac_addr));
|
||||
@ -508,4 +508,31 @@ uint8_t zh_espnow_get_version(void)
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user