Fixed one bug

This commit is contained in:
2024-06-12 22:35:11 +03:00
parent 1fa7ab2822
commit 4af4b77318

View File

@ -39,7 +39,7 @@ typedef struct
{
uint8_t original_target_mac[6];
uint8_t intermediate_target_mac[6];
} __attribute__((packed)) _routing_table_t;
} _routing_table_t;
typedef struct
{
@ -60,7 +60,7 @@ typedef struct
DELIVERY_CONFIRM,
SEARCH_REQUEST,
SEARCH_RESPONSE
} message_type;
} __attribute__((packed)) message_type;
uint32_t network_id;
uint32_t message_id;
uint32_t confirm_id;
@ -69,8 +69,8 @@ typedef struct
uint8_t sender_mac[6];
uint8_t payload[ZH_NETWORK_MAX_MESSAGE_SIZE];
uint8_t payload_len;
} data;
} __attribute__((packed)) _queue_t;
} __attribute__((packed)) data;
} _queue_t;
ESP_EVENT_DEFINE_BASE(ZH_NETWORK);
/// \endcond
@ -105,7 +105,7 @@ esp_err_t zh_network_init(const zh_network_init_config_t *config)
ESP_LOGW(TAG, "ESP-NOW initialization warning. The device is connected to the router. Channel %d will be used for ESP-NOW.", prim);
}
}
if ((sizeof(_queue_t) - 12) > ESP_NOW_MAX_DATA_LEN)
if ((sizeof(_queue_t) - 14) > ESP_NOW_MAX_DATA_LEN)
{
ESP_LOGE(TAG, "ESP-NOW initialization fail. The maximum value of the transmitted data size is incorrect.");
return ESP_ERR_INVALID_ARG;
@ -255,7 +255,7 @@ static void _recv_cb(const esp_now_recv_info_t *esp_now_info, const uint8_t *dat
ESP_LOGW(TAG, "Adding incoming ESP-NOW data to queue fail. Queue is almost full.");
return;
}
if (data_len == sizeof(_queue_t) - 12)
if (data_len == sizeof(_queue_t) - 14)
{
_queue_t queue = {0};
queue.id = ON_RECV;
@ -404,7 +404,7 @@ static void _processing(void *pvParameter)
memcpy(on_send->mac_addr, queue.data.original_target_mac, 6);
SEND:
++_attempts;
if (esp_now_send((uint8_t *)peer->peer_addr, (uint8_t *)&queue.data, sizeof(_queue_t) - 12) != ESP_OK)
if (esp_now_send((uint8_t *)peer->peer_addr, (uint8_t *)&queue.data, sizeof(_queue_t) - 14) != ESP_OK)
{
ESP_LOGE(TAG, "ESP-NOW message processing task internal error at line %d.", __LINE__);
heap_caps_free(peer);