2 Commits

Author SHA1 Message Date
cedea19f1a feat: added reset statistics 2025-05-06 08:58:28 +03:00
7d1653b076 fix: error receiveng 1 to 6 bytes data 2025-05-06 08:10:39 +03:00
3 changed files with 15 additions and 2 deletions

View File

@ -116,6 +116,11 @@ extern "C"
*/
const zh_espnow_stats_t *zh_espnow_get_stats(void);
/**
* @brief Reset ESP-NOW statistics.
*/
void zh_espnow_reset_stats(void);
#ifdef __cplusplus
}
#endif

View File

@ -1 +1 @@
1.1.1
1.2.0

View File

@ -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,12 @@ 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.");
}