Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEEE 802.15.4 doesn't receive packets after calling esp_ieee802154_receive() (IDFGH-10286) #11549

Closed
3 tasks done
spark404 opened this issue May 30, 2023 · 16 comments
Closed
3 tasks done
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@spark404
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.2-dev-823-g903af13e84

Operating System used.

macOS

How did you build your project?

Command line with idf.py

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

None

Development Kit.

ESP32-C6-DevKitC-1

Power Supply used.

USB

What is the expected behavior?

I expected the call to esp_ieee802154_receive() to enable the driver to receive all packets on the network on a particular channel. This should trigger the corresponding hooks like esp_ieee802154_receive_done and esp_ieee802154_receive_failed but neither are called.

What is the actual behavior?

The expected behaviour is a continuous stream of packets passed to the esp_ieee802154_receive_done handler.

It's important to note here that this does work if the esp_ieee802154_transmit(..) is called before calling esp_ieee802154_receive().

Steps to reproduce.

Use the following main.c

#include <string.h>
#include <nvs.h>
#include <nvs_flash.h>
#include <esp_ieee802154.h>
#include <esp_log.h>
#include <esp_phy_init.h>

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"

#define TAG "main"
#define RADIO_TAG "ieee802154"

#define PANID 0x4242
#define CHANNEL 15

#define SHORT_NOT_CONFIGURED 0xFFFE

void esp_ieee802154_receive_done(uint8_t* frame, esp_ieee802154_frame_info_t* frame_info) {
    ESP_EARLY_LOGI(RADIO_TAG, "rx OK, received %d bytes", frame[0]);
}

void esp_ieee802154_receive_failed(uint16_t error) {
    ESP_EARLY_LOGI(RADIO_TAG, "rx failed, error %d", error);
}

void esp_ieee802154_receive_sfd_done(void) {
    ESP_EARLY_LOGI(RADIO_TAG, "rx sfd done, Radio state: %d", esp_ieee802154_get_state());
}

void app_main() {
    ESP_LOGI(TAG, "Initializing NVS from flash...");
    esp_err_t err = nvs_flash_init();
    if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        err = nvs_flash_init();
    }
    ESP_ERROR_CHECK(err);

    ESP_ERROR_CHECK(esp_ieee802154_enable());
    ESP_ERROR_CHECK(esp_ieee802154_set_promiscuous(true));
    ESP_ERROR_CHECK(esp_ieee802154_set_rx_when_idle(true));

    ESP_ERROR_CHECK(esp_ieee802154_set_panid(PANID));
    ESP_ERROR_CHECK(esp_ieee802154_set_coordinator(false));

    ESP_ERROR_CHECK(esp_ieee802154_set_channel(CHANNEL));

    esp_phy_calibration_data_t cal_data;
    ESP_ERROR_CHECK(esp_phy_load_cal_data_from_nvs(&cal_data));

    // Set long address to the mac address (with 0xff padding at the end)
    // Set short address to unconfigured
    uint8_t long_address[8];
    memcpy(&long_address, cal_data.mac, 6);
    long_address[6] = 0xff;
    long_address[7] = 0xfe;
    esp_ieee802154_set_extended_address(long_address);
    esp_ieee802154_set_short_address(SHORT_NOT_CONFIGURED);

//#define MAKE_IT_WORK
#ifdef MAKE_IT_WORK
    // basically bogus data
    long_address[0] = 8;
    esp_ieee802154_transmit(long_address, false);
#endif

    uint8_t radio_long_address[8];
    esp_ieee802154_get_extended_address(radio_long_address);
    ESP_LOGI(TAG, "Receiver ready, panId=0x%04x, channel=%d, long=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, short=%04x",
             esp_ieee802154_get_panid(), esp_ieee802154_get_channel(),
             radio_long_address[0], radio_long_address[1], radio_long_address[2], radio_long_address[3],
             radio_long_address[4], radio_long_address[5], radio_long_address[6], radio_long_address[7],
             esp_ieee802154_get_short_address());


    ESP_ERROR_CHECK(esp_ieee802154_receive());

    // All done, the rest is up to handlers
    while (true) {
        vTaskDelay(10 / portTICK_PERIOD_MS);
    }
}

On an active Zigbee network the output with the MAKE_IT_WORK define enabled is:

I (293) main_task: Calling app_main()
I (293) main: Initializing NVS from flash...
I (303) phy_init: phy_version 202,b4b3263,May 17 2023,20:14:14
I (353) main: Receiver ready, panId=0x4242, channel=15, long=40:4c:ca:40:28:dc:ff:fe, short=fffe
I (1143) ieee802154: rx sfd done, Radio state: 2
I (1143) ieee802154: rx OK, received 50 bytes
I (1203) ieee802154: rx sfd done, Radio state: 2
I (1203) ieee802154: rx OK, received 53 bytes
I (1203) ieee802154: rx sfd done, Radio state: 2
I (1233) ieee802154: rx sfd done, Radio state: 2
I (1233) ieee802154: rx OK, received 50 bytes
I (1243) ieee802154: rx sfd done, Radio state: 2
I (1243) ieee802154: rx OK, received 53 bytes

On the same Zigbee network without the MAKE_IT_WORK define

I (293) main_task: Calling app_main()
I (293) main: Initializing NVS from flash...
I (303) phy_init: phy_version 202,b4b3263,May 17 2023,20:14:14
I (353) main: Receiver ready, panId=0x4242, channel=15, long=40:4c:ca:40:28:dc:ff:fe, short=fffe
I (9943) ieee802154: rx sfd done, Radio state: 2

Debug Logs.

No response

More Information.

No response

@spark404 spark404 added the Type: Bug bugs in IDF label May 30, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label May 30, 2023
@github-actions github-actions bot changed the title IEEE 802.15.4 doesn't receive packets after calling esp_ieee802154_receive() IEEE 802.15.4 doesn't receive packets after calling esp_ieee802154_receive() (IDFGH-10286) May 30, 2023
@zwx1995esp
Copy link
Collaborator

Hi @spark404 I have already tried your main.c code, but I did not reproduce this issue.

I use your main.c, without macro MAKE_IT_WORK defined, as a receiver. And using another board to transmit some packets, the receiver can receive all of the packet.

So, could you please try using another board to send some packets to see if the receiver can receive those packets?(using another board to send packets, using esp_ieee802154_transmit function to send some specific packets).

@spark404
Copy link
Author

Hi @zwx1995esp, thank you for assisting with this issue. I followed your recommendation, however I still encounter the issue I mentioned. For reference I've uploaded the two project that I use for verification:

https://github.com/spark404/ieee802154-receiver
https://github.com/spark404/ieee802154-sender

The output from the sender is as follows:

--- WARNING: Serial ports accessed as /dev/tty.* will hang gdb if launched.
--- Using /dev/cu.usbmodem11201 instead...
--- idf_monitor on /dev/cu.usbmodem11201 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
cpu_start: Compile time:     May 31 2023 19:41:26ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x15 (USB_UART_HPSYS),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x400294a6
SPIWP:0xee
mode:DIO, clock div:2
load:0x4086c410,len:0xd44
load:0x4086e610,len:0x2db8
load:0x40875720,len:0x181c
entry 0x4086c41a
I (23) boot: ESP-IDF v5.2-dev-823-g903af13e84 2nd stage bootloader
I (23) boot: compile time May 31 2023 19:41:31
I (24) boot: chip revision: v0.0
I (27) boot.esp32c6: SPI Speed      : 40MHz
I (32) boot.esp32c6: SPI Mode       : DIO
I (37) boot.esp32c6: SPI Flash Size : 8MB
I (41) boot: Enabling RNG early entropy source...
I (47) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (58) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (65) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (73) boot:  2 factory          factory app      00 00 00010000 00096000
I (80) boot:  3 zb_storage       Unknown data     01 81 000a6000 00004000
I (88) boot:  4 zb_fct           Unknown data     01 81 000aa000 00000400
I (95) boot: End of partition table
I (99) esp_image: segment 0: paddr=00010020 vaddr=42020020 size=09590h ( 38288) map
I (115) esp_image: segment 1: paddr=000195b8 vaddr=40800000 size=06a60h ( 27232) load
I (122) esp_image: segment 2: paddr=00020020 vaddr=42000020 size=191a8h (102824) map
I (145) esp_image: segment 3: paddr=000391d0 vaddr=40806a60 size=06984h ( 27012) load
I (155) boot: Loaded app from partition at offset 0x10000
I (155) boot: Disabling RNG early entropy source...
I (166) cpu_start: Unicore app
I (167) cpu_start: Pro cpu up.
W (175) clk: esp_perip_clk_init() has not been implemented yet
I (182) cpu_start: Pro cpu start user code
I (182) cpu_start: cpu freq: 160000000 Hz
I (182) cpu_start: Application information:
I (185) cpu_start: Project name:     ieee802154-sender
I (191) cpu_start: App version:      0.1.0
I (196) cpu_start: Compile time:     May 31 2023 19:41:26
I (202) cpu_start: ELF file SHA256:  c89fda4a0...
I (207) cpu_start: ESP-IDF:          v5.2-dev-823-g903af13e84
I (213) cpu_start: Min chip rev:     v0.0
I (218) cpu_start: Max chip rev:     v0.99
I (223) cpu_start: Chip rev:         v0.0
I (228) heap_init: Initializing. RAM available for dynamic allocation:
I (235) heap_init: At 4080EFD0 len 0006D640 (437 KiB): D/IRAM
I (241) heap_init: At 4087C610 len 00002F54 (11 KiB): STACK/DIRAM
I (248) heap_init: At 50000010 len 00003FF0 (15 KiB): RTCRAM
I (255) spi_flash: detected chip: generic
I (259) spi_flash: flash io: dio
I (263) sleep: Configure to isolate all GPIO pins in sleep state
I (270) sleep: Enable automatic switching of GPIO sleep configuration
I (277) coexist: coex firmware version: ebddf30
I (282) coexist: coexist rom version 5b8dcfa
I (287) app_start: Starting scheduler on CPU0
I (292) main_task: Started on CPU0
I (292) main_task: Calling app_main()
I (292) main: Initializing NVS from flash...
I (312) phy_init: phy_version 202,b4b3263,May 17 2023,20:14:14
I (352) main: Sender ready, panId=0x4242, channel=11, long=40:4c:ca:40:28:dc:ff:fe, short=1111
I (1352) ieee802154: tx failed, error 2
I (1352) ieee802154: tx sfd done
I (1352) ieee802154: tx OK, sent 103 bytes, ack 0
I (2352) ieee802154: tx sfd done
I (2352) ieee802154: tx OK, sent 103 bytes, ack 0
I (3352) ieee802154: tx sfd done
I (3352) ieee802154: tx OK, sent 103 bytes, ack 0
I (4352) ieee802154: tx sfd done
I (4352) ieee802154: tx OK, sent 103 bytes, ack 0
I (5352) ieee802154: tx sfd done
I (5352) ieee802154: tx OK, sent 103 bytes, ack 0
I (6352) ieee802154: tx sfd done
I (6352) ieee802154: tx OK, sent 103 bytes, ack 0
I (7352) ieee802154: tx sfd done
I (7352) ieee802154: tx OK, sent 103 bytes, ack 0
I (8352) ieee802154: tx sfd done
I (8352) ieee802154: tx OK, sent 103 bytes, ack 0
I (9352) ieee802154: tx sfd done
I (9352) ieee802154: tx OK, sent 103 bytes, ack 0
I (10352) ieee802154: tx sfd done
I (10352) ieee802154: tx OK, sent 103 bytes, ack 0
I (11352) ieee802154: tx sfd done
I (11352) ieee802154: tx OK, sent 103 bytes, ack 0
I (12352) ieee802154: tx sfd done
I (12352) ieee802154: tx OK, sent 103 bytes, ack 0
I (13352) ieee802154: tx sfd done
I (13352) ieee802154: tx OK, sent 103 bytes, ack 0
I (14352) ieee802154: tx sfd done
I (14352) ieee802154: tx OK, sent 103 bytes, ack 0
I (15352) ieee802154: tx sfd done
I (15352) ieee802154: tx OK, sent 103 bytes, ack 0
I (16352) ieee802154: tx sfd done
I (16352) ieee802154: tx OK, sent 103 bytes, ack 0
I (17352) ieee802154: tx sfd done
I (17352) ieee802154: tx OK, sent 103 bytes, ack 0
I (18352) ieee802154: tx sfd done
I (18352) ieee802154: tx OK, sent 103 bytes, ack 0
I (19352) ieee802154: tx sfd done
I (19352) ieee802154: tx OK, sent 103 bytes, ack 0
I (20352) ieee802154: tx sfd done
I (20352) ieee802154: tx OK, sent 103 bytes, ack 0
I (21352) ieee802154: tx sfd done
I (21352) ieee802154: tx OK, sent 103 bytes, ack 0
I (22352) ieee802154: tx sfd done
I (22352) ieee802154: tx OK, sent 103 bytes, ack 0
I (23352) ieee802154: tx sfd done
I (23352) ieee802154: tx OK, sent 103 bytes, ack 0
I (24352) ieee802154: tx sfd done
I (24352) ieee802154: tx OK, sent 103 bytes, ack 0
I (25352) ieee802154: tx sfd done
I (25352) ieee802154: tx OK, sent 103 bytes, ack 0
I (26352) ieee802154: tx sfd done
I (26352) ieee802154: tx OK, sent 103 bytes, ack 0
I (27352) ieee802154: tx sfd done
I (27352) ieee802154: tx OK, sent 103 bytes, ack 0
I (28352) ieee802154: tx sfd done
I (28352) ieee802154: tx OK, sent 103 bytes, ack 0
I (29352) ieee802154: tx sfd done
I (29352) ieee802154: tx OK, sent 103 bytes, ack 0

The receiver output (without the define) as follows:

--- WARNING: Serial ports accessed as /dev/tty.* will hang gdb if launched.
--- Using /dev/cu.usbmodem11101 instead...
--- idf_monitor on /dev/cu.usbmodem11101 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
I (199) cpu_start: ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x15 (USB_UART_HPSYS),boot:0x7c (SPI_FAST_FLASH_BOOT)
Saved PC:0x400294ae
SPIWP:0xee
mode:DIO, clock div:2
load:0x4086c410,len:0xd44
load:0x4086e610,len:0x2db8
load:0x40875720,len:0x181c
entry 0x4086c41a
I (23) boot: ESP-IDF v5.2-dev-823-g903af13e84 2nd stage bootloader
I (23) boot: compile time May 31 2023 19:44:57
I (24) boot: chip revision: v0.0
I (27) boot.esp32c6: SPI Speed      : 40MHz
I (32) boot.esp32c6: SPI Mode       : DIO
I (37) boot.esp32c6: SPI Flash Size : 8MB
I (42) boot: Enabling RNG early entropy source...
I (47) boot: Partition Table:
I (51) boot: ## Label            Usage          Type ST Offset   Length
I (58) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (65) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (73) boot:  2 factory          factory app      00 00 00010000 00096000
I (80) boot:  3 zb_storage       Unknown data     01 81 000a6000 00004000
I (88) boot:  4 zb_fct           Unknown data     01 81 000aa000 00000400
I (95) boot: End of partition table
I (99) esp_image: segment 0: paddr=00010020 vaddr=42020020 size=09608h ( 38408) map
I (115) esp_image: segment 1: paddr=00019630 vaddr=40800000 size=069e8h ( 27112) load
I (122) esp_image: segment 2: paddr=00020020 vaddr=42000020 size=19194h (102804) map
I (145) esp_image: segment 3: paddr=000391bc vaddr=408069e8 size=069b8h ( 27064) load
I (155) boot: Loaded app from partition at offset 0x10000
I (155) boot: Disabling RNG early entropy source...
I (166) cpu_start: Unicore app
I (167) cpu_start: Pro cpu up.
W (175) clk: esp_perip_clk_init() has not been implemented yet
I (182) cpu_start: Pro cpu start user code
I (182) cpu_start: cpu freq: 160000000 Hz
I (183) cpu_start: Application information:
I (185) cpu_start: Project name:     ieee802154-receiver
I (191) cpu_start: App version:      0.1.0
I (196) cpu_start: Compile time:     May 31 2023 19:44:53
I (202) cpu_start: ELF file SHA256:  785251ddf21c5fdb...
I (208) cpu_start: ESP-IDF:          v5.2-dev-823-g903af13e84
I (214) cpu_start: Min chip rev:     v0.0
I (219) cpu_start: Max chip rev:     v0.99
I (224) cpu_start: Chip rev:         v0.0
I (229) heap_init: Initializing. RAM available for dynamic allocation:
I (236) heap_init: At 4080EF80 len 0006D690 (437 KiB): D/IRAM
I (242) heap_init: At 4087C610 len 00002F54 (11 KiB): STACK/DIRAM
I (249) heap_init: At 50000010 len 00003FF0 (15 KiB): RTCRAM
I (256) spi_flash: detected chip: generic
I (260) spi_flash: flash io: dio
I (264) sleep: Configure to isolate all GPIO pins in sleep state
I (271) sleep: Enable automatic switching of GPIO sleep configuration
I (278) coexist: coex firmware version: ebddf30
I (283) coexist: coexist rom version 5b8dcfa
I (288) app_start: Starting scheduler on CPU0
I (293) main_task: Started on CPU0
I (293) main_task: Calling app_main()
I (293) main: Initializing NVS from flash...
I (313) phy_init: phy_version 202,b4b3263,May 17 2023,20:14:14
I (343) main: Receiver ready, panId=0x4242, channel=11, long=40:4c:ca:40:2a:24:ff:fe, short=fffe

with the define enabled I see the following

I (313) phy_init: phy_version 202,b4b3263,May 17 2023,20:14:14
I (353) main: Receiver ready, panId=0x4242, channel=11, long=40:4c:ca:40:2a:24:ff:fe, short=fffe
I (633) ieee802154: rx sfd done, Radio state: 2
I (633) ieee802154: rx OK, received 103 bytes
I (1633) ieee802154: rx sfd done, Radio state: 2
I (1633) ieee802154: rx OK, received 103 bytes
I (2633) ieee802154: rx sfd done, Radio state: 2
I (2633) ieee802154: rx OK, received 103 bytes
I (3633) ieee802154: rx sfd done, Radio state: 2
I (3633) ieee802154: rx OK, received 103 bytes

I tried switching the roles from between the two boards, but that didn't help. The board I'm using is the ESP32-C6-DevKitC-1. Unfortunately I have no other boards to test this with.

@zwx1995esp
Copy link
Collaborator

Hi I add some debug info function for getting more infomations for the reason why your board can not receive any messages.
https://github.com/zwx1995esp/ieee802154-sender/tree/add_debug_info

Could you please try the code with these two steps and send the two logs to me?

(Tips, the log may be too long, so you may need to choose a clear channel, which may not have any IEEE802154 packets(or just very little packets) transmitting on.)

Step 1, enable PHY_DEBUG and MAKE_IT_WORK, build and flash the firmware, waiting for the whole log printed done, save the whole logs, name it with normal.

Step 2, only enable PHY_DEBUG, disable MAKE_IT_WORK, also build, flash, save logs, name it with abnormal.

@spark404
Copy link
Author

spark404 commented Jun 2, 2023

Thanks for putting in this effort! I've attached the output files.

PHY_DEBUG + MAKE_IT_WORK
esp32c6-phydebug-abnormal.txt

PHY_DEBUG
esp32c6-phydebug-normal.txt

@zwx1995esp
Copy link
Collaborator

Ok, I will ask for the PHY group for some help on your logs, maybe need some times.

@zwx1995esp
Copy link
Collaborator

zwx1995esp commented Jun 5, 2023

@spark404 Hi, I have already synced with PHY group, and they said, IEEE802154 has already entered rx mode after the first log print, so could you please confirm that if there are some codes modified in your esp-idf?

you can also add some logs for this API ieee802154_receive to see if this function is called twice in your code.

@spark404
Copy link
Author

spark404 commented Jun 7, 2023

Hello @zwx1995esp thank you for keeping track of this. I've ran a test with a log statement on the receive function. Attached are the logs.

output_not_working_with_receivecheck.txt

I noticed something that might be related. On the receiver application I'm setting the address with:

    // Set long address to the mac address (with 0xff padding at the end)
    uint8_t long_address[8];
    memcpy(&long_address, cal_data.mac, 6);
    long_address[6] = 0xff;
    long_address[7] = 0xff;
    esp_ieee802154_set_extended_address(long_address);
    esp_ieee802154_set_short_address(SHORT_MY_ADDRESS);

I can retrieve the correct settings as shown in the logs:
Ready, panId=0x4447, channel=11, long=40:4c:ca:40:2a:24:ff:ff, short=1111

When I send a message from a sender application to that particular combination of pan and long address it isn't received unless I activate promiscuous mode with esp_ieee802154_set_promiscuous(true). I've tried with regular device connected to the same pan and there the packet is received.

I've attached a cap file showing that the broadcast is correctly received but the targeted message isn't.

associate_fail.txt

associate_sequence_2.pcapng.zip

@zwx1995esp
Copy link
Collaborator

zwx1995esp commented Jun 8, 2023

But, I see your code, ESP_ERROR_CHECK(esp_ieee802154_set_promiscuous(true)); you have already set the promiscuous mode true, so why you need to set it again?

If you do not enable the promiscuous mode, the hardware will filter the packets using the rules defined in IEEE802.15.4 spec(only packets match the panid and address can be received or the packets contain the broadcast address or panid can be received).

@zwx1995esp
Copy link
Collaborator

zwx1995esp commented Jun 8, 2023

And could you please push your idf branch to your remote repository and give me a link? I want to try to reproduce with your code base. Also I can leave some commits for debugging on your repository directly.

@spark404
Copy link
Author

spark404 commented Jun 9, 2023

@zwx1995esp I've updated the receiver and sender code I used to demonstrate the case more clearly I hope this helps. This a small summary of where I am with the debugging. I'll update make the esp-idf branch and update the ticket.

The sender app sends a series of packets for testing
https://github.com/spark404/ieee802154-sender

The receiver app prints debug output for every packet it receives
https://github.com/spark404/ieee802154-receiver

The log output and packet capture for the sequence is attached.
logs_and_capture.zip

What seems to be the current case:
If the MAKE_IT_WORK define is not enabled the receiver receives nothing.
If MAKE_IT_WORK is defined the receiver received the broadcast message, the message sent to the short address. It doesn't receive the message sent to the long address.

@spark404
Copy link
Author

spark404 commented Jun 9, 2023

I created the debug repository here: https://github.com/spark404/esp-idf/tree/ieee802154-debug

Attached the output from the receiver app with the debug statements (MAKE_IT_WORK enabled):
receiver_with_debug.txt

And the same with MAKE_IT_WORK disabled
receiver_with_debug_MAKE_IT_WORK_disabled.txt

@spark404
Copy link
Author

spark404 commented Jun 9, 2023

I think I solved at least part of my problem. The call to set the extended address needs to be in reversed order:

    uint8_t eui64[8] = {0};
    esp_read_mac(eui64, ESP_MAC_IEEE802154);
    uint8_t eui64_rev[8] = {0};
    for (int i=0; i<8; i++) {
        eui64_rev[7-i] = eui64[i];
    }
    esp_ieee802154_set_extended_address(eui64_rev);

If I do that the directed frames arrive as expected.

@zwx1995esp
Copy link
Collaborator

Sorry for the delay, due to some urgent breaks me.

Your issue seems due to the bit order, the extended address is not set rightly as expected. So some frames may be filtered by the hardware.

But you enable the promiscuous mode.... If you enable the promiscuous mode, I don't think some frame will be filtered by our hardware.

Our in your apps, maybe some other logic before the examples you shared to me....
It doesn't make sense if you enable the promiscuous mode but some frames are filtered....

@chshu
Copy link
Collaborator

chshu commented Nov 10, 2023

@spark404 Do you have any update of the issue?

Generally speaking, no frame will be dropped if promiscuous mode is enabled. If promiscuous mode is disabled, hardware will perform the frame filter as defined in the 802.15.4 spec, frames including unexpected destination panid / addresses will be dropped.

@nopnop2002
Copy link

nopnop2002 commented Dec 16, 2023

@spark404

Your code was able to communicate with the Digi Xbee S2C 802.15.4 firmware.

wonderful!

digi-xbee-s2c

digi-xbee-s2c-20

@spark404
Copy link
Author

spark404 commented Jan 6, 2024

I've tried the demo projects I've created with the latest version of esp-idf and everything seems to be working. I verified by removing the workarounds in some other code an no issues anymore.

I (192) cpu_start: Application information:
I (195) cpu_start: Project name:     ieee802154-receiver
I (201) cpu_start: App version:      0.1.0
I (205) cpu_start: Compile time:     Jan  6 2024 21:38:50
I (211) cpu_start: ELF file SHA256:  0ab02c395...
I (217) cpu_start: ESP-IDF:          v5.3-dev-1288-g5524b692ee
I (223) cpu_start: Min chip rev:     v0.0
I (228) cpu_start: Max chip rev:     v0.99
I (233) cpu_start: Chip rev:         v0.0

Many thanks for all the support on this!

@spark404 spark404 closed this as completed Jan 6, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

5 participants