espressif / esp-csi

Applications based on Wi-Fi CSI (Channel state information), such as indoor positioning, human detection
Apache License 2.0
706 stars 111 forks source link

Send packets failed while integrating the send function in the receiver side (AEGHB-830) #208

Open Yaqi3707 opened 1 month ago

Yaqi3707 commented 1 month ago

Checklist

Issue or Suggestion Description

Greetings ESP32 developers,

As I browsed the issues about whether it was possible to integrate both the send and receive functions in either the sender or receiver side, the answer is yes #142. So I would like to implement these two functions on my sender and receiver side.

I am using Rpi4 with OS: Linux raspberrypi 6.6.31+rpt-rpi-v8 https://github.com/espressif/esp-csi/issues/1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux

My ESP-idf is: ESP-IDF v5.4-dev-1873-g41dd1a351b

I modified the sender and receiver here(receiver.txt, sender.txt). In my code, I added the send function right after the CSI capture and print function since I wanted a quick response (I temporarily disabled the CSI data print function). The issue came from the receiver side so far, which showed me that the send function failed after each CSI packet was received. I made sure no error came from the code, but I could not figure out why the send function always failed. Screenshot 2024-09-30 203624

I truly and sincerely appreciate any suggestions and guidance that help me on this implementation.

NingYuxiang commented 4 days ago

In the receiver.txt file, the peer structure in the main function:

    esp_now_peer_info_t peer = {
        .channel = CONFIG_LESS_INTERFERENCE_CHANNEL,
        .ifidx = WIFI_IF_STA,
        .encrypt = false,
        .peer_addr = {0x1a, 0x00, 0x00, 0x00, 0x00, 0x00},
    };

should be modified to a static variable:

    static esp_now_peer_info_t peer = {
        .channel = CONFIG_LESS_INTERFERENCE_CHANNEL,
        .ifidx = WIFI_IF_STA,
        .encrypt = false,
        .peer_addr = {0x1a, 0x00, 0x00, 0x00, 0x00, 0x00},
    };

This is necessary because, once the main function finishes execution, the variable will be released, making it inaccessible for subsequent operations.