espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
12.56k stars 7.01k forks source link

ESP-Now priv from esp_now_peer_info_t is not set (IDFGH-12706) #13693

Open Schuemi opened 2 weeks ago

Schuemi commented 2 weeks ago

Answers checklist.

IDF version.

v5.2.1 and v5.1.2

Espressif SoC revision.

tried with ESP32C3

Operating System used.

Linux

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

Seeed Human Detector Sensor Kit

Power Supply used.

USB

What is the expected behavior?

If I call esp_now_add_peer with an esp_now_peer_info_t in which the priv pointer is set, esp_now_get_peer and esp_now_fetch_peer should display this pointer in the result of esp_now_peer_info_t. However, the pointer is not set.

What is the actual behavior?

Set the priv pointer to the value it was set with esp_now_add_peer.

Steps to reproduce.

` static uint8_t s_example_mac[ESP_NOW_ETH_ALEN] = { 0x01, 0x02, 0x04, 0x05, 0x06, 0x07 }; esp_now_peer_info_t peer; esp_now_peer_info_t peerTest; uint32_t someUserData = (uint32_t)malloc(sizeof(uint32_t)); memset(&peer, 0, sizeof(esp_now_peer_info_t)); memset(&peerTest, 0, sizeof(esp_now_peer_info_t));

peer.channel = 5; peer.ifidx = WIFI_IF_STA; peer.encrypt = false; peer.priv = someUserData; memcpy(&peer.peer_addr, s_example_mac, ESP_NOW_ETH_ALEN);

printf("some user data Pointer: %p\n", peer.priv); if (esp_now_add_peer(&peer) != ESP_OK) printf("Failed adding peer"); if (esp_now_get_peer(s_example_mac, &peerTest)!= ESP_OK) printf("Failed getting peer");

printf("got user data Pointer: %p\n", peerTest.priv); `

Output: some user data Pointer: 0x3fcae554 got user data Pointer: 0x0

Debug Logs.

No response

More Information.

tried with 5.1.2 and 5.2.1

zhangyanjiaoesp commented 2 weeks ago

@Schuemi thanks for your report, will fix it