fix log messages

This commit is contained in:
NP v/d Spek 2024-09-19 18:18:30 +02:00
parent fed4858ee4
commit ab31977886

View file

@ -275,18 +275,20 @@ void ESPNowComponent::on_data_received(const esp_now_recv_info_t *recv_info, con
void ESPNowComponent::on_data_received(const uint8_t *addr, const uint8_t *data, int size) void ESPNowComponent::on_data_received(const uint8_t *addr, const uint8_t *data, int size)
#endif #endif
{ {
ESPNowPacket packet((uint64_t) *addr, data, size); bool broadcast = false;
wifi_pkt_rx_ctrl_t *rx_ctrl = nullptr; wifi_pkt_rx_ctrl_t *rx_ctrl = nullptr;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 1) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 1)
uint8_t *addr = recv_info->src_addr; uint8_t *addr = recv_info->src_addr;
packet.broadcast(*recv_info->des_addr == ESPNOW_BROADCAST_ADDR); broadcast = ((uint64_t) *recv_info->des_addr & ESPNOW_BROADCAST_ADDR) == ESPNOW_BROADCAST_ADDR;
rx_ctrl = recv_info->rx_ctrl; rx_ctrl = recv_info->rx_ctrl;
#else #else
wifi_promiscuous_pkt_t *promiscuous_pkt = wifi_promiscuous_pkt_t *promiscuous_pkt =
(wifi_promiscuous_pkt_t *) (data - sizeof(wifi_pkt_rx_ctrl_t) - sizeof(espnow_frame_format_t)); (wifi_promiscuous_pkt_t *) (data - sizeof(wifi_pkt_rx_ctrl_t) - sizeof(espnow_frame_format_t));
rx_ctrl = &promiscuous_pkt->rx_ctrl; rx_ctrl = &promiscuous_pkt->rx_ctrl;
#endif #endif
ESPNowPacket packet((uint64_t) *addr, data, size);
packet.broadcast(broadcast);
packet.rssi(rx_ctrl->rssi); packet.rssi(rx_ctrl->rssi);
packet.timestamp(rx_ctrl->timestamp); packet.timestamp(rx_ctrl->timestamp);
ESP_LOGVV(TAG, "Read: %s |H:%02x%02x%02x A:%02x%02x%02x %02x T:%02x C:%02x%02x S:%02d", packet.content_bytes(), ESP_LOGVV(TAG, "Read: %s |H:%02x%02x%02x A:%02x%02x%02x %02x T:%02x C:%02x%02x S:%02d", packet.content_bytes(),