From 3053a931a31b0f72a7b149edf8ed2a244f8273a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ku=C5=BAnia?= Date: Mon, 30 Aug 2021 16:36:26 +0200 Subject: [PATCH] drivers: ieee802154: reverse ack data ext addr string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ack data for extended address is set with the nrf_802154_ack_data_set function, the extended address must be reversed to the IEEE 802.15.4 address transmit order in order to be properly matched. Signed-off-by: Rafał Kuźnia --- drivers/ieee802154/ieee802154_nrf5.c | 13 +++++++++---- include/net/ieee802154_radio.h | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index a3893eb57e2..0ce293fb401 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -842,11 +842,16 @@ static int nrf5_configure(const struct device *dev, uint8_t ext_addr_le[EXTENDED_ADDRESS_SIZE]; sys_put_le16(config->ack_ie.short_addr, short_addr_le); -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - memcpy(ext_addr_le, config->ack_ie.ext_addr, EXTENDED_ADDRESS_SIZE); -#else + /** + * The extended address field passed to this function starts + * with the leftmost octet and ends with the rightmost octet. + * The IEEE 802.15.4 transmission order mandates this order to be + * reversed in a transmitted frame. + * + * The nrf_802154_ack_data_set expects extended address in transmission + * order. + */ sys_memcpy_swap(ext_addr_le, config->ack_ie.ext_addr, EXTENDED_ADDRESS_SIZE); -#endif if (config->ack_ie.data_len > 0) { nrf_802154_ack_data_set(short_addr_le, false, config->ack_ie.data, diff --git a/include/net/ieee802154_radio.h b/include/net/ieee802154_radio.h index d34e719c9f1..9fe5804366a 100644 --- a/include/net/ieee802154_radio.h +++ b/include/net/ieee802154_radio.h @@ -281,6 +281,13 @@ struct ieee802154_config { const uint8_t *data; uint16_t data_len; uint16_t short_addr; + /** + * The extended address is expected to be passed starting + * with the leftmost octet and ending with the rightmost octet. + * A device with an extended address 01:23:45:67:89:ab:cd:ef + * should provide a pointer to array containing values in the + * same exact order. + */ const uint8_t *ext_addr; } ack_ie; };