From f4f367042be5190a8fada191d29e7be43f40a729 Mon Sep 17 00:00:00 2001 From: Tyler Potyondy Date: Wed, 26 Jun 2024 10:34:53 -0700 Subject: [PATCH 1/2] Fix ACK buf Size The current ACK buf size for the nrf52840 15.4 radio is 6 bytes. The 15.4 spec requires ACK frames to be 5 bytes (from perspective of MAC layer). The PHY layer adds a 1 byte frame length field (encapsulated in PSDU offset) -- total is 7 bytes. --- chips/nrf52840/src/ieee802154_radio.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chips/nrf52840/src/ieee802154_radio.rs b/chips/nrf52840/src/ieee802154_radio.rs index 3e88465b31..f33fabfcc0 100644 --- a/chips/nrf52840/src/ieee802154_radio.rs +++ b/chips/nrf52840/src/ieee802154_radio.rs @@ -87,7 +87,13 @@ pub const IEEE802154_ACK_TIME: usize = 512; //microseconds = 32 symbols pub const IEEE802154_MAX_POLLING_ATTEMPTS: u8 = 4; pub const IEEE802154_MIN_BE: u8 = 3; pub const IEEE802154_MAX_BE: u8 = 5; -pub const ACK_BUF_SIZE: usize = 6; + +// ACK Requires MHR and MFR fields. More explicitly this is composed of: +// | Frame Control (2 bytes) | Sequence Number (1 byte) | FCS (2 bytes) |. +// In total the ACK frame is 5 bytes long + 2 PSDU bytes (7 bytes total). +const SEQ_NUM_LEN: usize = 1; +pub const ACK_BUF_SIZE: usize = + radio::PSDU_OFFSET + radio::MHR_FC_SIZE + SEQ_NUM_LEN + radio::MFR_SIZE; /// Where the 15.4 packet from the radio is stored in the buffer. The HIL /// reserves one byte at the beginning of the buffer for use by the From 352e43b9fb7b45998f320e09808895d506aff1f7 Mon Sep 17 00:00:00 2001 From: Tyler Potyondy <77175673+tyler-potyondy@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:41:29 -0700 Subject: [PATCH 2/2] 15.4 ACK Buffer Length: Comment updates Co-authored-by: Brad Campbell --- chips/nrf52840/src/ieee802154_radio.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chips/nrf52840/src/ieee802154_radio.rs b/chips/nrf52840/src/ieee802154_radio.rs index f33fabfcc0..2b2c6d4e04 100644 --- a/chips/nrf52840/src/ieee802154_radio.rs +++ b/chips/nrf52840/src/ieee802154_radio.rs @@ -89,11 +89,11 @@ pub const IEEE802154_MIN_BE: u8 = 3; pub const IEEE802154_MAX_BE: u8 = 5; // ACK Requires MHR and MFR fields. More explicitly this is composed of: -// | Frame Control (2 bytes) | Sequence Number (1 byte) | FCS (2 bytes) |. +// | Frame Control (2 bytes) | Sequence Number (1 byte) | MFR (2 bytes) |. // In total the ACK frame is 5 bytes long + 2 PSDU bytes (7 bytes total). const SEQ_NUM_LEN: usize = 1; pub const ACK_BUF_SIZE: usize = - radio::PSDU_OFFSET + radio::MHR_FC_SIZE + SEQ_NUM_LEN + radio::MFR_SIZE; + radio::SPI_HEADER_SIZE + radio::PHR_SIZE + radio::MHR_FC_SIZE + SEQ_NUM_LEN + radio::MFR_SIZE; /// Where the 15.4 packet from the radio is stored in the buffer. The HIL /// reserves one byte at the beginning of the buffer for use by the