esp-rs/esp-hal

Ieee802154 does not work with ext_addr

Opened this issue · 0 comments

Bug description

When trying to send a frame that contains only an ext_addr and no short_addr it will not be picked up by the receiver, unless its in promiscuous mode

To Reproduce

Receiver

//% CHIPS: esp32c6 esp32h2

#![no_std]
#![no_main]

use esp_backtrace as _;
use esp_hal::prelude::*;
use esp_ieee802154::{Config, Ieee802154};
use esp_println::println;

#[entry]
fn main() -> ! {
    let mut peripherals = esp_hal::init(esp_hal::Config::default());
    let mut ieee802154 = Ieee802154::new(peripherals.IEEE802154, peripherals.RADIO_CLK);

    ieee802154.set_config(Config {
        channel: 15,
        promiscuous: false,
        rx_when_idle: true,
        auto_ack_rx: true,
        auto_ack_tx: true,
        pan_id: Some(0x4242),
        ext_addr: Some(0x2323),
        ..Default::default()
    });

    println!("Start receiving:");
    ieee802154.start_receive();

    loop {
        if let Some(frame) = ieee802154.get_received() {
            println!("Received {:?}\n", &frame);
        }
    }
}

Transmitter

//% CHIPS: esp32c6 esp32h2

#![no_std]
#![no_main]

use esp_backtrace as _;
use esp_hal::{delay::Delay, prelude::*};
use esp_ieee802154::{Config, Frame, Ieee802154};
use esp_println::println;
use ieee802154::mac::{Address, ExtendedAddress, FrameContent, FrameType, FrameVersion, Header, PanId, ShortAddress};

#[entry]
fn main() -> ! {
    let mut peripherals = esp_hal::init(esp_hal::Config::default());

    let delay = Delay::new();

    let mut ieee802154 = Ieee802154::new(peripherals.IEEE802154, peripherals.RADIO_CLK);

    ieee802154.set_config(Config {
        channel: 15,
        promiscuous: false,
        pan_id: Some(0x4242),
        ext_addr: Some(0x2222),
        ..Default::default()
    });

    let mut seq_number = 0u8;
    loop {
        ieee802154
            .transmit(&Frame {
                header: Header {
                    frame_type: FrameType::Data,
                    frame_pending: false,
                    ack_request: true,
                    pan_id_compress: false,
                    seq_no_suppress: false,
                    ie_present: false,
                    version: FrameVersion::Ieee802154_2006,
                    seq: seq_number,
                    destination: Some(Address::Extended(PanId(0x4242), ExtendedAddress(0x2323))),
                    source: None,
                    auxiliary_security_header: None,
                },
                content: FrameContent::Data,
                payload: heapless::Vec::from_slice(b"Hello World").unwrap(),
                footer: [0u8; 2],
            })
            .ok();

        println!("Send frame with sequence number {seq_number}");
        delay.delay_millis(1000u32);
        seq_number = seq_number.wrapping_add(1);
    }
}

Expected behavior

It should receive the message.

Environment

  • Target device:
    Chip type: esp32c6 (revision v0.1)
    Crystal frequency: 40 MHz
    Flash size: 4MB
    Features: WiFi 6, BT 5

  • Crate name and version:
    esp-hal: ca5e856
    esp-ieee802154: ca5e856