Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
cedea19f1a | |||
7d1653b076 | |||
87d4713b40 | |||
7c4650d87a |
@ -100,7 +100,7 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return ESP_OK if success or an error code otherwise.
|
* @return ESP_OK if success or an error code otherwise.
|
||||||
*/
|
*/
|
||||||
esp_err_t zh_espnow_send(const uint8_t *target, const uint8_t *data, const uint8_t data_len);
|
esp_err_t zh_espnow_send(const uint8_t *target, const uint8_t *data, const uint16_t data_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get ESP-NOW version.
|
* @brief Get ESP-NOW version.
|
||||||
@ -116,6 +116,11 @@ extern "C"
|
|||||||
*/
|
*/
|
||||||
const zh_espnow_stats_t *zh_espnow_get_stats(void);
|
const zh_espnow_stats_t *zh_espnow_get_stats(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset ESP-NOW statistics.
|
||||||
|
*/
|
||||||
|
void zh_espnow_reset_stats(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -1 +1 @@
|
|||||||
1.1.0
|
1.2.0
|
12
zh_espnow.c
12
zh_espnow.c
@ -215,7 +215,7 @@ esp_err_t zh_espnow_deinit(void)
|
|||||||
return final_status;
|
return final_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t zh_espnow_send(const uint8_t *target, const uint8_t *data, const uint8_t data_len)
|
esp_err_t zh_espnow_send(const uint8_t *target, const uint8_t *data, const uint16_t data_len)
|
||||||
{
|
{
|
||||||
ZH_ESPNOW_LOGI("Adding to queue outgoing ESP-NOW data to MAC %02X:%02X:%02X:%02X:%02X:%02X started.", MAC2STR((target == NULL) ? _broadcast_mac : target));
|
ZH_ESPNOW_LOGI("Adding to queue outgoing ESP-NOW data to MAC %02X:%02X:%02X:%02X:%02X:%02X started.", MAC2STR((target == NULL) ? _broadcast_mac : target));
|
||||||
if (_is_initialized == false)
|
if (_is_initialized == false)
|
||||||
@ -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_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;
|
zh_espnow_event_on_recv_t *recv_data = (zh_espnow_event_on_recv_t *)&queue->data;
|
||||||
++_stats.received;
|
++_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)
|
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));
|
ZH_ESPNOW_LOGI("Incoming ESP-NOW data from MAC %02X:%02X:%02X:%02X:%02X:%02X processed successfully.", MAC2STR(queue->data.mac_addr));
|
||||||
@ -509,3 +509,11 @@ const zh_espnow_stats_t *zh_espnow_get_stats(void)
|
|||||||
{
|
{
|
||||||
return &_stats;
|
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.");
|
||||||
|
}
|
Reference in New Issue
Block a user