diff --git a/main/app_networking.cpp b/main/app_networking.cpp index c13a51a..14ad246 100644 --- a/main/app_networking.cpp +++ b/main/app_networking.cpp @@ -9,12 +9,15 @@ #include "esp_netif.h" #include "esp_now.h" #include "esp_wifi.h" +#include "esp_log.h" namespace { using namespace Networking; +static const char* TAG = "Networking"; + static_assert(std::is_standard_layout_v && std::is_trivial_v, "EspNowEvent is not compatible with a FreeRTOS queue."); @@ -40,6 +43,7 @@ void s_cbEspNowSendComplete(const std::uint8_t* peer_mac, esp_now_send_status_t EspNowEvent event = { EspNowEvent::MSG_SEND_COMPLETE, 0 }; xQueueSend(s_esp_now_queue, &event, 0); + ESP_LOGD(TAG, "Send complete. s_tx_inflight = false."); } void s_cbEspNowReceiveComplete(const esp_now_recv_info_t* recv_info, const std::uint8_t* data, int len) @@ -49,6 +53,7 @@ void s_cbEspNowReceiveComplete(const esp_now_recv_info_t* recv_info, const std:: EspNowEvent event = { EspNowEvent::MSG_RECEIVED, rx_len }; xQueueSend(s_esp_now_queue, &event, 0); + ESP_LOGD(TAG, "Received message. Length: %d.", len); } } @@ -97,7 +102,14 @@ void sendData(const std::array& buffer, const std::size_t len !s_tx_inflight && peer_mac != nullptr) { esp_now_send(peer_mac->data(), buffer.data(), length); - s_tx_inflight = true; + if (!s_isBroadcastAddress(peer_mac->data())) + s_tx_inflight = true; + + ESP_LOGD(TAG, "Message send started. s_tx_inflight = %d.", s_tx_inflight); + } + else + { + ESP_LOGW(TAG, "Dropped message."); } } diff --git a/main/esp_tunnel.cpp b/main/esp_tunnel.cpp index 7325ff5..422e415 100644 --- a/main/esp_tunnel.cpp +++ b/main/esp_tunnel.cpp @@ -94,6 +94,10 @@ extern "C" void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); + esp_log_level_set("*", ESP_LOG_INFO); + esp_log_level_set(TAG, ESP_LOG_DEBUG); + esp_log_level_set("Networking", ESP_LOG_DEBUG); + ESP_LOGD(TAG, "Starting main."); Networking::setupWifi();