From e13aac3909d15a161e4c356ee4755a28cf38e813 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Mon, 16 Nov 2020 16:05:04 +0100 Subject: [PATCH 1/8] ieee802154/hal: add config src address match --- sys/include/net/ieee802154/radio.h | 90 ++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/sys/include/net/ieee802154/radio.h b/sys/include/net/ieee802154/radio.h index aa2ef4b6a6..7db130c7ab 100644 --- a/sys/include/net/ieee802154/radio.h +++ b/sys/include/net/ieee802154/radio.h @@ -148,6 +148,15 @@ typedef enum { * @brief Multi-Rate Frequency Shift Keying PHY mode */ IEEE802154_CAP_PHY_MR_FSK = BIT17, + /** + * @brief the device supports source address match table. + * + * A Source Address Match table contains source addresses with pending + * data. When a coordinator device receives an IEEE 802.15.4 Data + * Request command from a child node, the Frame Pending bit of the ACK is + * set if the source address matches one from the table. + */ + IEEE802154_CAP_SRC_ADDR_MATCH = BIT18, } ieee802154_rf_caps_t; /** @@ -288,6 +297,47 @@ typedef enum { IEEE802154_RADIO_CONFIRM_CCA, } ieee802154_trx_ev_t; +/** + * @brief Source Address Match commands. + */ +typedef enum { + /** + * @brief Enable or disable source address match. + * + * Enabling it sets the frame pending to all ACK frames in + * response to a Data Request command (if the radio doesn't + * support Source Address Matching) or to a specific address + * in the Source Address Matching table + */ + IEEE802154_SRC_MATCH_EN, + /** + * @brief Add a short address to entry. + * + * This command should only be implemented if @ref IEEE802154_CAP_SRC_ADDR_MATCH + * is available. + */ + IEEE802154_SRC_MATCH_SHORT_ADD, + /** + * @brief Clear short address from entry. + * This command should only be implemented if @ref IEEE802154_CAP_SRC_ADDR_MATCH + * is available. + */ + IEEE802154_SRC_MATCH_SHORT_CLEAR, + /** + * @brief Add a extended address to entry. + * This command should only be implemented if @ref IEEE802154_CAP_SRC_ADDR_MATCH + * is available. + */ + IEEE802154_SRC_MATCH_EXT_ADD, + /** + * @brief Clear extended address from entry. + * + * This command should only be implemented if @ref IEEE802154_CAP_SRC_ADDR_MATCH + * is available. + */ + IEEE802154_SRC_MATCH_EXT_CLEAR, +} ieee802154_src_match_t; + /** * @brief CSMA-CA exponential backoff parameters. */ @@ -568,6 +618,7 @@ struct ieee802154_radio_ops { * - @ref set_csma_params * - @ref set_rx_mode * - @ref set_hw_addr_filter + * - @ref config_src_addr_match * - @ref set_frame_retrans (if available) * * @param[in] dev IEEE802.15.4 device descriptor @@ -765,6 +816,27 @@ struct ieee802154_radio_ops { * @return negative errno on error */ int (*set_rx_mode)(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode); + + /** + * @brief Set the source address match configuration. + * + * This function configures the source address match filter in order to set + * the Frame Pending bit in ACK frames accordingly. + * In case the radio doesn't support @ref IEEE802154_CAP_SRC_ADDR_MATCH, + * this functions is used to activate the Frame Pending bit for all ACK + * frames (in order to be compliant with the IEEE 802.15.4 standard). + * + * @pre the device is on + * + * @param[in] dev IEEE802.15.4 device descriptor + * @param[in] cmd command for the source address match configuration + * @param[in] value value associated to @p cmd. + * + * @return 0 on success + * @return negative errno on error + */ + int (*config_src_addr_match)(ieee802154_dev_t *dev, ieee802154_src_match_t cmd, + const void *value); }; /** @@ -881,6 +953,24 @@ static inline int ieee802154_radio_config_phy(ieee802154_dev_t *dev, return dev->driver->config_phy(dev, conf); } +/** + * @brief Shortcut to @ref ieee802154_radio_ops::config_src_addr_match + * + * @pre the device is on + * + * @param[in] dev IEEE802.15.4 device descriptor + * @param[in] cmd command for the source address match configuration + * @param[in] value value associated to @p cmd. + * + * @return result of @ref ieee802154_radio_ops::config_src_addr_match + */ +static inline int ieee802154_radio_config_src_address_match(ieee802154_dev_t *dev, + ieee802154_src_match_t cmd, + const void *value) +{ + return dev->driver->config_src_addr_match(dev, cmd, value); +} + /** * @brief Shortcut to @ref ieee802154_radio_ops::off * From eb7282db0a12d95ece2bd61d32830ec26154f43d Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 18 Nov 2020 11:39:22 +0100 Subject: [PATCH 2/8] ieee802154/hal: add set frame filter --- sys/include/net/ieee802154/radio.h | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sys/include/net/ieee802154/radio.h b/sys/include/net/ieee802154/radio.h index 7db130c7ab..741f7e9e5c 100644 --- a/sys/include/net/ieee802154/radio.h +++ b/sys/include/net/ieee802154/radio.h @@ -338,6 +338,36 @@ typedef enum { IEEE802154_SRC_MATCH_EXT_CLEAR, } ieee802154_src_match_t; +/** + * @brief Frame Filter mode + */ +typedef enum { + /** + * @brief accept all valid frames that match address filter configuration + */ + IEEE802154_FILTER_ACCEPT, + /** + * @brief accept only ACK frames + * + * @note This mode should only be implemented if the transceiver doesn't + * handle ACK frame reception (when @ref IEEE802154_CAP_FRAME_RETRANS and + * @ref IEEE802154_CAP_IRQ_ACK_TIMEOUT are not present). + */ + IEEE802154_FILTER_ACK_ONLY, + /** + * @brief accept all valid frames + * + * @note This mode is optional + */ + IEEE802154_FILTER_PROMISC, + /** + * @brief accept all frames, regardless of FCS + * + * @note This mode is optional + */ + IEEE802154_FILTER_SNIFFER, +} ieee802154_filter_mode_t; + /** * @brief CSMA-CA exponential backoff parameters. */ @@ -618,6 +648,7 @@ struct ieee802154_radio_ops { * - @ref set_csma_params * - @ref set_rx_mode * - @ref set_hw_addr_filter + * - @ref set_frame_filter_mode * - @ref config_src_addr_match * - @ref set_frame_retrans (if available) * @@ -817,6 +848,19 @@ struct ieee802154_radio_ops { */ int (*set_rx_mode)(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode); + /** + * @brief Set the frame filter moder. + * + * @pre the device is on + * + * @param[in] dev IEEE802.15.4 device descriptor + * @param[in] mode address filter mode + * + * @return 0 on success + * @return negative errno on error + */ + int (*set_frame_filter_mode)(ieee802154_dev_t *dev, ieee802154_filter_mode_t mode); + /** * @brief Set the source address match configuration. * @@ -1007,6 +1051,22 @@ static inline int ieee802154_radio_set_hw_addr_filter(ieee802154_dev_t *dev, return dev->driver->set_hw_addr_filter(dev, short_addr, ext_addr, pan_id); } +/** + * @brief Shortcut to @ref ieee802154_radio_ops::set_frame_filter_mode + * + * @pre the device is on + * + * @param[in] dev IEEE802.15.4 device descriptor + * @param[in] mode frame filter mode + * + * @return result of @ref ieee802154_radio_ops::set_frame_filter_mode + */ +static inline int ieee802154_radio_set_frame_filter_mode(ieee802154_dev_t *dev, + ieee802154_filter_mode_t mode) +{ + return dev->driver->set_frame_filter_mode(dev, mode); +} + /** * @brief Shortcut to @ref ieee802154_radio_ops::set_frame_retrans * From 70815e012ba38477be4a3c738ee6c82e286407a5 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 18 Nov 2020 11:48:57 +0100 Subject: [PATCH 3/8] ieee802154/hal: add set config addr filter --- sys/include/net/ieee802154/radio.h | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/sys/include/net/ieee802154/radio.h b/sys/include/net/ieee802154/radio.h index 741f7e9e5c..409d1052fd 100644 --- a/sys/include/net/ieee802154/radio.h +++ b/sys/include/net/ieee802154/radio.h @@ -338,6 +338,16 @@ typedef enum { IEEE802154_SRC_MATCH_EXT_CLEAR, } ieee802154_src_match_t; +/** + * @brief Address filter command + */ +typedef enum { + IEEE802154_AF_SHORT_ADDR, /**< Set short IEEE 802.15.4 address (network_uint16_t) */ + IEEE802154_AF_EXT_ADDR, /**< Set extended IEEE 802.15.4 address (eui64_t) */ + IEEE802154_AF_PANID, /**< Set PAN ID (uint16_t) */ + IEEE802154_AF_PAN_COORD, /**< Set device as PAN coordinator (bool) */ +} ieee802154_af_cmd_t; + /** * @brief Frame Filter mode */ @@ -645,6 +655,7 @@ struct ieee802154_radio_ops { * - @ref set_cca_threshold * - @ref set_cca_mode * - @ref config_phy + * - @ref config_addr_filter * - @ref set_csma_params * - @ref set_rx_mode * - @ref set_hw_addr_filter @@ -861,6 +872,23 @@ struct ieee802154_radio_ops { */ int (*set_frame_filter_mode)(ieee802154_dev_t *dev, ieee802154_filter_mode_t mode); + /** + * @brief Configure the address filter. + * + * This functions is used for configuring the address filter parameters + * required by the IEEE 802.15.4 standard. + * + * @pre the device is on + * + * @param[in] dev IEEE802.15.4 device descriptor + * @param[in] cmd command for the address filter + * @param[in] value value for @p cmd. + * + * @return 0 on success + * @return negative errno on error + */ + int (*config_addr_filter)(ieee802154_dev_t *dev, ieee802154_af_cmd_t cmd, const void *value); + /** * @brief Set the source address match configuration. * @@ -1051,6 +1079,24 @@ static inline int ieee802154_radio_set_hw_addr_filter(ieee802154_dev_t *dev, return dev->driver->set_hw_addr_filter(dev, short_addr, ext_addr, pan_id); } +/** + * @brief Shortcut to @ref ieee802154_radio_ops::config_addr_filter + * + * @pre the device is on + * + * @param[in] dev IEEE802.15.4 device descriptor + * @param[in] cmd command for the address filter + * @param[in] value value for @p cmd. + * + * @return result of @ref ieee802154_radio_ops::config_addr_filter + */ +static inline int ieee802154_radio_config_addr_filter(ieee802154_dev_t *dev, + ieee802154_af_cmd_t cmd, + const void* value) +{ + return dev->driver->config_addr_filter(dev, cmd, value); +} + /** * @brief Shortcut to @ref ieee802154_radio_ops::set_frame_filter_mode * From 9dce6eba149008bd49e3076be8d7c4f256ecc25e Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 18 Nov 2020 13:52:53 +0100 Subject: [PATCH 4/8] ieee802154: add Auto ACK compile time config --- sys/include/net/ieee802154.h | 7 +++++++ sys/net/link_layer/ieee802154/Kconfig | 3 +++ 2 files changed, 10 insertions(+) diff --git a/sys/include/net/ieee802154.h b/sys/include/net/ieee802154.h index 17769ea4c7..86ba001199 100644 --- a/sys/include/net/ieee802154.h +++ b/sys/include/net/ieee802154.h @@ -301,6 +301,13 @@ extern const uint8_t ieee802154_addr_bcast[IEEE802154_ADDR_BCAST_LEN]; #define CONFIG_IEEE802154_CCA_THRESH_DEFAULT (-70) #endif +/** + * @brief Disable Auto ACK support + */ +#ifdef DOXYGEN +#define CONFIG_IEEE802154_AUTO_ACK_DISABLE 0 +#endif + /** * @brief Initializes an IEEE 802.15.4 MAC frame header in @p buf. * diff --git a/sys/net/link_layer/ieee802154/Kconfig b/sys/net/link_layer/ieee802154/Kconfig index 6186ed6898..b50e1d9337 100644 --- a/sys/net/link_layer/ieee802154/Kconfig +++ b/sys/net/link_layer/ieee802154/Kconfig @@ -82,6 +82,9 @@ if KCONFIG_USEMODULE_IEEE802154 config IEEE802154_DEFAULT_CSMA_CA_MAX int "IEEE802.15.4 default CSMA-CA maximum backoff exponent" default 5 + config IEEE802154_AUTO_ACK_DISABLE + bool "Disable Auto ACK support" if !USEPKG_OPENWSN + default y if USEPKG_OPENWSN menuconfig KCONFIG_USEMODULE_IEEE802154_SECURITY bool "Configure IEEE802.15.4 Security" From 4cfe62fc992577debdf9f52e4d4eb3599b0ea727 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 18 Nov 2020 13:57:21 +0100 Subject: [PATCH 5/8] nrf52840: adapt to Radio HAL changes --- cpu/nrf52/radio/nrf802154/nrf802154_radio.c | 79 +++++++++++++-------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/cpu/nrf52/radio/nrf802154/nrf802154_radio.c b/cpu/nrf52/radio/nrf802154/nrf802154_radio.c index 58fe27b39f..43023eb529 100644 --- a/cpu/nrf52/radio/nrf802154/nrf802154_radio.c +++ b/cpu/nrf52/radio/nrf802154/nrf802154_radio.c @@ -91,6 +91,7 @@ static struct { bool cca_send : 1; /**< whether the next transmission uses CCA or not */ bool ack_filter : 1; /**< whether the ACK filter is activated or not */ bool promisc : 1; /**< whether the device is in promiscuous mode or not */ + bool pending : 1; /**< whether there pending bit should be set in the ACK frame or not */ } cfg = { .cca_send = true, .ack_filter = true, @@ -431,6 +432,11 @@ static void _timer_cb(void *arg, int chan) if (chan == MAC_TIMER_CHAN_ACK) { /* Copy sqn */ + ack[1] = IEEE802154_FCF_TYPE_ACK; + if (cfg.pending) { + ack[1] |= IEEE802154_FCF_FRAME_PEND; + } + ack[3] = rxbuf[3]; NRF_RADIO->PACKETPTR = (uint32_t) &ack; @@ -517,7 +523,7 @@ void isr_radio(void) case STATE_RX: if (NRF_RADIO->CRCSTATUS) { bool l2filter_passed = _l2filter(rxbuf+1); - bool is_auto_ack_en = ack[1]; + bool is_auto_ack_en = !IS_ACTIVE(CONFIG_IEEE802154_AUTO_ACK_DISABLE); bool is_ack = rxbuf[1] & IEEE802154_FCF_TYPE_ACK; bool ack_req = rxbuf[1] & IEEE802154_FCF_ACK_REQ; @@ -699,26 +705,41 @@ int _set_cca_mode(ieee802154_dev_t *dev, ieee802154_cca_mode_t mode) return 0; } -static int _set_hw_addr_filter(ieee802154_dev_t *dev, const network_uint16_t *short_addr, - const eui64_t *ext_addr, const uint16_t *pan_id) +static int _config_addr_filter(ieee802154_dev_t *dev, ieee802154_af_cmd_t cmd, const void *value) { (void) dev; - if (short_addr) { - memcpy(nrf802154_short_addr, short_addr, IEEE802154_SHORT_ADDRESS_LEN); - } - - if (ext_addr) { - memcpy(nrf802154_long_addr, ext_addr, IEEE802154_LONG_ADDRESS_LEN); - } - - if (pan_id) { - nrf802154_pan_id = *pan_id; + const uint16_t *pan_id = value; + switch(cmd) { + case IEEE802154_AF_SHORT_ADDR: + memcpy(nrf802154_short_addr, value, IEEE802154_SHORT_ADDRESS_LEN); + break; + case IEEE802154_AF_EXT_ADDR: + memcpy(nrf802154_long_addr, value, IEEE802154_LONG_ADDRESS_LEN); + break; + case IEEE802154_AF_PANID: + nrf802154_pan_id = *pan_id; + break; + case IEEE802154_AF_PAN_COORD: + return -ENOTSUP; } return 0; } -static int _set_rx_mode(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode) +static int _config_src_addr_match(ieee802154_dev_t *dev, ieee802154_src_match_t cmd, const void *value) +{ + (void) dev; + switch(cmd) { + case IEEE802154_SRC_MATCH_EN: + cfg.pending = *((const bool*) value); + break; + default: + return -ENOTSUP; + } + return 0; +} + +static int _set_frame_filter_mode(ieee802154_dev_t *dev, ieee802154_filter_mode_t mode) { (void) dev; @@ -726,21 +747,16 @@ static int _set_rx_mode(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode) bool _promisc = false; switch (mode) { - case IEEE802154_RX_AACK_DISABLED: - ack[1] = 0; - break; - case IEEE802154_RX_AACK_ENABLED: - ack[1] = IEEE802154_FCF_TYPE_ACK; - break; - case IEEE802154_RX_AACK_FRAME_PENDING: - ack[1] = IEEE802154_FCF_TYPE_ACK | IEEE802154_FCF_FRAME_PEND; - break; - case IEEE802154_RX_PROMISC: - _promisc = true; - break; - case IEEE802154_RX_WAIT_FOR_ACK: - ackf = false; - break; + case IEEE802154_FILTER_ACCEPT: + break; + case IEEE802154_FILTER_PROMISC: + _promisc = true; + break; + case IEEE802154_FILTER_ACK_ONLY: + ackf = false; + break; + default: + return -ENOTSUP; } cfg.ack_filter = ackf; @@ -800,7 +816,8 @@ static const ieee802154_radio_ops_t nrf802154_ops = { .set_cca_threshold = set_cca_threshold, .set_cca_mode = _set_cca_mode, .config_phy = _config_phy, - .set_hw_addr_filter = _set_hw_addr_filter, .set_csma_params = _set_csma_params, - .set_rx_mode = _set_rx_mode, + .config_addr_filter = _config_addr_filter, + .config_src_addr_match = _config_src_addr_match, + .set_frame_filter_mode = _set_frame_filter_mode, }; From 44934d300c990fc19b5d9093e0a4c395acea2697 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 18 Nov 2020 13:57:46 +0100 Subject: [PATCH 6/8] cc2538_rf: adapt to Radio HAL changes --- cpu/cc2538/include/cc2538_rf.h | 3 + cpu/cc2538/radio/cc2538_rf.c | 3 + cpu/cc2538/radio/cc2538_rf_radio_ops.c | 130 ++++++++++++++----------- 3 files changed, 77 insertions(+), 59 deletions(-) diff --git a/cpu/cc2538/include/cc2538_rf.h b/cpu/cc2538/include/cc2538_rf.h index a30c44f1c4..ebaca7f9a4 100644 --- a/cpu/cc2538/include/cc2538_rf.h +++ b/cpu/cc2538/include/cc2538_rf.h @@ -107,7 +107,10 @@ extern "C" { #define CC2538_RSSI_OFFSET (-73) /**< Signal strength offset value */ #define CC2538_RF_SENSITIVITY (-97) /**< dBm typical, normal conditions */ +#define CC2538_ACCEPT_FT_0_BEACON (1 << 3) /**< enable or disable the BEACON filter */ +#define CC2538_ACCEPT_FT_1_DATA (1 << 4) /**< enable or disable the DATA filter */ #define CC2538_ACCEPT_FT_2_ACK (1 << 5) /**< enable or disable the ACK filter */ +#define CC2538_ACCEPT_FT_3_CMD (1 << 6) /**< enable or disable the CMD filter */ #define CC2538_STATE_SFD_WAIT_RANGE_MIN (0x03U) /**< min range value of SFD wait state */ #define CC2538_STATE_SFD_WAIT_RANGE_MAX (0x06U) /**< max range value of SFD wait state */ #define CC2538_FRMCTRL1_PENDING_OR_MASK (0x04) /**< mask for enabling or disabling the diff --git a/cpu/cc2538/radio/cc2538_rf.c b/cpu/cc2538/radio/cc2538_rf.c index 076d238dcd..570378538e 100644 --- a/cpu/cc2538/radio/cc2538_rf.c +++ b/cpu/cc2538/radio/cc2538_rf.c @@ -174,6 +174,9 @@ void cc2538_init(void) /* setup mac timer */ _cc2538_setup_mac_timer(); + /* Enable Auto ACK */ + RFCORE->XREG_FRMCTRL0bits.AUTOACK = !IS_ACTIVE(CONFIG_IEEE802154_AUTO_ACK_DISABLE); + /* Flush the receive and transmit FIFOs */ RFCORE_SFR_RFST = ISFLUSHTX; RFCORE_SFR_RFST = ISFLUSHRX; diff --git a/cpu/cc2538/radio/cc2538_rf_radio_ops.c b/cpu/cc2538/radio/cc2538_rf_radio_ops.c index 529f0192b7..69bcad1a5d 100644 --- a/cpu/cc2538/radio/cc2538_rf_radio_ops.c +++ b/cpu/cc2538/radio/cc2538_rf_radio_ops.c @@ -352,7 +352,7 @@ void cc2538_irq_handler(void) /* Disable RX while the frame has not been processed */ RFCORE_XREG_RXMASKCLR = 0xFF; /* If AUTOACK is enabled and the ACK request bit is set */ - if (RFCORE->XREG_FRMCTRL0bits.AUTOACK && + if (!IS_ACTIVE(CONFIG_IEEE802154_AUTO_ACK_DISABLE) && (rfcore_peek_rx_fifo(1) & IEEE802154_FCF_ACK_REQ)) { /* The next SFD will be the ACK's, ignore it */ cc2538_sfd_listen = false; @@ -400,31 +400,51 @@ static int _off(ieee802154_dev_t *dev) return -ENOTSUP; } -static int _set_hw_addr_filter(ieee802154_dev_t *dev, const network_uint16_t *short_addr, - const eui64_t *ext_addr, const uint16_t *pan_id) +static int _config_addr_filter(ieee802154_dev_t *dev, ieee802154_af_cmd_t cmd, const void *value) { (void) dev; - if (short_addr) { - RFCORE_FFSM_SHORT_ADDR0 = short_addr->u8[1]; - RFCORE_FFSM_SHORT_ADDR1 = short_addr->u8[0]; + const network_uint16_t *short_addr = value; + const eui64_t *ext_addr = value; + const uint16_t *pan_id = value; + switch(cmd) { + case IEEE802154_AF_SHORT_ADDR: + RFCORE_FFSM_SHORT_ADDR0 = short_addr->u8[1]; + RFCORE_FFSM_SHORT_ADDR1 = short_addr->u8[0]; + break; + case IEEE802154_AF_EXT_ADDR: + RFCORE_FFSM_EXT_ADDR0 = ext_addr->uint8[7]; + RFCORE_FFSM_EXT_ADDR1 = ext_addr->uint8[6]; + RFCORE_FFSM_EXT_ADDR2 = ext_addr->uint8[5]; + RFCORE_FFSM_EXT_ADDR3 = ext_addr->uint8[4]; + RFCORE_FFSM_EXT_ADDR4 = ext_addr->uint8[3]; + RFCORE_FFSM_EXT_ADDR5 = ext_addr->uint8[2]; + RFCORE_FFSM_EXT_ADDR6 = ext_addr->uint8[1]; + RFCORE_FFSM_EXT_ADDR7 = ext_addr->uint8[0]; + break; + case IEEE802154_AF_PANID: + RFCORE_FFSM_PAN_ID0 = *pan_id; + RFCORE_FFSM_PAN_ID1 = (*pan_id) >> 8; + break; + case IEEE802154_AF_PAN_COORD: + return -ENOTSUP; } - if (ext_addr) { - RFCORE_FFSM_EXT_ADDR0 = ext_addr->uint8[7]; - RFCORE_FFSM_EXT_ADDR1 = ext_addr->uint8[6]; - RFCORE_FFSM_EXT_ADDR2 = ext_addr->uint8[5]; - RFCORE_FFSM_EXT_ADDR3 = ext_addr->uint8[4]; - RFCORE_FFSM_EXT_ADDR4 = ext_addr->uint8[3]; - RFCORE_FFSM_EXT_ADDR5 = ext_addr->uint8[2]; - RFCORE_FFSM_EXT_ADDR6 = ext_addr->uint8[1]; - RFCORE_FFSM_EXT_ADDR7 = ext_addr->uint8[0]; - } + return 0; +} - if (pan_id) { - RFCORE_FFSM_PAN_ID0 = *pan_id; - RFCORE_FFSM_PAN_ID1 = (*pan_id) >> 8; +static int _config_src_addr_match(ieee802154_dev_t *dev, ieee802154_src_match_t cmd, const void *value) +{ + (void) dev; + switch(cmd) { + case IEEE802154_SRC_MATCH_EN: + RFCORE_XREG_FRMCTRL1 &= ~CC2538_FRMCTRL1_PENDING_OR_MASK; + if (*((const bool*) value) == true) { + RFCORE_XREG_FRMCTRL1 |= CC2538_FRMCTRL1_PENDING_OR_MASK; + } + break; + default: + return -ENOTSUP; } - return 0; } @@ -468,43 +488,6 @@ static int _set_cca_mode(ieee802154_dev_t *dev, ieee802154_cca_mode_t mode) return 0; } -static int _set_rx_mode(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode) -{ - (void) dev; - - bool promisc = false; - bool ack_filter = true; - switch (mode) { - case IEEE802154_RX_AACK_DISABLED: - RFCORE->XREG_FRMCTRL0bits.AUTOACK = 0; - break; - case IEEE802154_RX_AACK_ENABLED: - RFCORE->XREG_FRMCTRL0bits.AUTOACK = 1; - RFCORE_XREG_FRMCTRL1 &= ~CC2538_FRMCTRL1_PENDING_OR_MASK; - break; - case IEEE802154_RX_AACK_FRAME_PENDING: - RFCORE->XREG_FRMCTRL0bits.AUTOACK = 1; - RFCORE_XREG_FRMCTRL1 |= CC2538_FRMCTRL1_PENDING_OR_MASK; - break; - case IEEE802154_RX_PROMISC: - promisc = true; - break; - case IEEE802154_RX_WAIT_FOR_ACK: - ack_filter = false; - break; - } - - if (ack_filter) { - RFCORE_XREG_FRMFILT1 &= ~CC2538_ACCEPT_FT_2_ACK; - } - else { - RFCORE_XREG_FRMFILT1 |= CC2538_ACCEPT_FT_2_ACK; - } - - cc2538_set_monitor(promisc); - return 0; -} - static int _set_csma_params(ieee802154_dev_t *dev, const ieee802154_csma_be_t *bd, int8_t retries) { (void) dev; @@ -518,6 +501,34 @@ static int _set_csma_params(ieee802154_dev_t *dev, const ieee802154_csma_be_t *b return 0; } +static int _set_frame_filter_mode(ieee802154_dev_t *dev, ieee802154_filter_mode_t mode) +{ + (void) dev; + + uint8_t flags = 0; + bool promisc = false; + switch (mode) { + case IEEE802154_FILTER_ACCEPT: + flags = CC2538_ACCEPT_FT_0_BEACON + | CC2538_ACCEPT_FT_1_DATA + | CC2538_ACCEPT_FT_3_CMD; + break; + case IEEE802154_FILTER_PROMISC: + promisc = true; + break; + case IEEE802154_FILTER_ACK_ONLY: + flags = CC2538_ACCEPT_FT_2_ACK; + break; + default: + return -ENOTSUP; + } + + RFCORE_XREG_FRMFILT1 |= flags; + cc2538_set_monitor(promisc); + + return 0; + +} static const ieee802154_radio_ops_t cc2538_rf_ops = { .caps = IEEE802154_CAP_24_GHZ | IEEE802154_CAP_AUTO_CSMA @@ -543,7 +554,8 @@ static const ieee802154_radio_ops_t cc2538_rf_ops = { .set_cca_threshold = _set_cca_threshold, .set_cca_mode = _set_cca_mode, .config_phy = _config_phy, - .set_hw_addr_filter = _set_hw_addr_filter, + .config_addr_filter = _config_addr_filter, + .config_src_addr_match = _config_src_addr_match, .set_csma_params = _set_csma_params, - .set_rx_mode = _set_rx_mode, + .set_frame_filter_mode = _set_frame_filter_mode, }; From 6d64b537efd513dc62339fb5d3c57ecdfa1052e1 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 18 Nov 2020 14:00:04 +0100 Subject: [PATCH 7/8] ieee802154/hal: remove set_hw_addr_filter --- pkg/openwsn/contrib/radio_hal.c | 9 ++++-- sys/include/net/ieee802154/radio.h | 43 -------------------------- sys/include/net/ieee802154/submac.h | 10 +++--- sys/net/link_layer/ieee802154/submac.c | 8 ++--- tests/ieee802154_hal/main.c | 7 ++++- 5 files changed, 19 insertions(+), 58 deletions(-) diff --git a/pkg/openwsn/contrib/radio_hal.c b/pkg/openwsn/contrib/radio_hal.c index ae35306740..c7e61fa694 100644 --- a/pkg/openwsn/contrib/radio_hal.c +++ b/pkg/openwsn/contrib/radio_hal.c @@ -71,9 +71,12 @@ void _idmanager_addr_override(void) /* Set all IEEE addresses */ uint16_t panid = OPENWSN_PANID; - ieee802154_radio_set_hw_addr_filter(openwsn_radio.dev, &short_addr, - &eui64, &panid); - + ieee802154_radio_config_addr_filter(openwsn_radio.dev, IEEE802154_AF_SHORT_ADDR, + &short_addr); + ieee802154_radio_config_addr_filter(openwsn_radio.dev, IEEE802154_AF_EXT_ADDR, + &eui64); + ieee802154_radio_config_addr_filter(openwsn_radio.dev, IEEE802154_AF_PANID, + &panid); } static void _hal_radio_cb(ieee802154_dev_t *dev, ieee802154_trx_ev_t status) diff --git a/sys/include/net/ieee802154/radio.h b/sys/include/net/ieee802154/radio.h index 409d1052fd..e980b9ca33 100644 --- a/sys/include/net/ieee802154/radio.h +++ b/sys/include/net/ieee802154/radio.h @@ -658,7 +658,6 @@ struct ieee802154_radio_ops { * - @ref config_addr_filter * - @ref set_csma_params * - @ref set_rx_mode - * - @ref set_hw_addr_filter * - @ref set_frame_filter_mode * - @ref config_src_addr_match * - @ref set_frame_retrans (if available) @@ -791,26 +790,6 @@ struct ieee802154_radio_ops { */ int (*config_phy)(ieee802154_dev_t *dev, const ieee802154_phy_conf_t *conf); - /** - * @brief Set IEEE802.15.4 addresses in hardware address filter - * - * @pre the device is on - * - * @param[in] dev IEEE802.15.4 device descriptor - * @param[in] short_addr the IEEE802.15.4 short address. If NULL, the short - * address is not altered.. - * @param[in] ext_addr the IEEE802.15.4 extended address (Network Byte Order). - * If NULL, the extended address is not altered. - * @param[in] pan_id the IEEE802.15.4 PAN ID. If NULL, the PAN ID is not altered. - * - * @return 0 on success - * @return negative errno on error - */ - int (*set_hw_addr_filter)(ieee802154_dev_t *dev, - const network_uint16_t *short_addr, - const eui64_t *ext_addr, - const uint16_t *pan_id); - /** * @brief Set number of frame retransmissions * @@ -1057,28 +1036,6 @@ static inline int ieee802154_radio_off(ieee802154_dev_t *dev) return dev->driver->off(dev); } -/** - * @brief Shortcut to @ref ieee802154_radio_ops::set_hw_addr_filter - * - * @pre the device is on - * - * @param[in] dev IEEE802.15.4 device descriptor - * @param[in] short_addr the IEEE802.15.4 short address. If NULL, the short - * address is not altered.. - * @param[in] ext_addr the IEEE802.15.4 extended address (Network Byte Order). - * If NULL, the extended address is not altered. - * @param[in] pan_id the IEEE802.15.4 PAN ID. If NULL, the PAN ID is not altered. - * - * @return result of @ref ieee802154_radio_ops::set_hw_addr_filter - */ -static inline int ieee802154_radio_set_hw_addr_filter(ieee802154_dev_t *dev, - const network_uint16_t *short_addr, - const eui64_t *ext_addr, - const uint16_t *pan_id) -{ - return dev->driver->set_hw_addr_filter(dev, short_addr, ext_addr, pan_id); -} - /** * @brief Shortcut to @ref ieee802154_radio_ops::config_addr_filter * diff --git a/sys/include/net/ieee802154/submac.h b/sys/include/net/ieee802154/submac.h index 9ec703b231..7f3913c277 100644 --- a/sys/include/net/ieee802154/submac.h +++ b/sys/include/net/ieee802154/submac.h @@ -173,8 +173,8 @@ int ieee802154_send(ieee802154_submac_t *submac, const iolist_t *iolist); static inline int ieee802154_set_short_addr(ieee802154_submac_t *submac, const network_uint16_t *short_addr) { - int res = ieee802154_radio_set_hw_addr_filter(submac->dev, short_addr, NULL, - NULL); + + int res = ieee802154_radio_config_addr_filter(submac->dev, IEEE802154_AF_SHORT_ADDR, short_addr); if (res >= 0) { memcpy(&submac->short_addr, short_addr, IEEE802154_SHORT_ADDRESS_LEN); @@ -195,8 +195,7 @@ static inline int ieee802154_set_short_addr(ieee802154_submac_t *submac, static inline int ieee802154_set_ext_addr(ieee802154_submac_t *submac, const eui64_t *ext_addr) { - int res = ieee802154_radio_set_hw_addr_filter(submac->dev, NULL, ext_addr, - NULL); + int res = ieee802154_radio_config_addr_filter(submac->dev, IEEE802154_AF_EXT_ADDR, ext_addr); if (res >= 0) { memcpy(&submac->ext_addr, ext_addr, IEEE802154_LONG_ADDRESS_LEN); @@ -216,8 +215,7 @@ static inline int ieee802154_set_ext_addr(ieee802154_submac_t *submac, static inline int ieee802154_set_panid(ieee802154_submac_t *submac, const uint16_t *panid) { - int res = ieee802154_radio_set_hw_addr_filter(submac->dev, NULL, NULL, - panid); + int res = ieee802154_radio_config_addr_filter(submac->dev, IEEE802154_AF_PANID, panid); if (res >= 0) { submac->panid = *panid; diff --git a/sys/net/link_layer/ieee802154/submac.c b/sys/net/link_layer/ieee802154/submac.c index f9ea58a933..8a7b65d292 100644 --- a/sys/net/link_layer/ieee802154/submac.c +++ b/sys/net/link_layer/ieee802154/submac.c @@ -363,12 +363,10 @@ int ieee802154_submac_init(ieee802154_submac_t *submac, const network_uint16_t * /* If the radio is still not in TRX_OFF state, spin */ while (ieee802154_radio_confirm_on(dev) == -EAGAIN) {} - /* Enable Auto ACK */ - ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_AACK_ENABLED); - /* Configure address filter */ - ieee802154_radio_set_hw_addr_filter(dev, &submac->short_addr, - &submac->ext_addr, &submac->panid); + ieee802154_radio_config_addr_filter(dev, IEEE802154_AF_SHORT_ADDR, &submac->short_addr); + ieee802154_radio_config_addr_filter(dev, IEEE802154_AF_EXT_ADDR, &submac->ext_addr); + ieee802154_radio_config_addr_filter(dev, IEEE802154_AF_PANID, &submac->panid); /* Configure PHY settings (mode, channel, TX power) */ ieee802154_phy_conf_t conf = diff --git a/tests/ieee802154_hal/main.c b/tests/ieee802154_hal/main.c index a3bf2be2c7..2dd91c846d 100644 --- a/tests/ieee802154_hal/main.c +++ b/tests/ieee802154_hal/main.c @@ -246,7 +246,12 @@ static int _init(void) uint16_t panid = CONFIG_IEEE802154_DEFAULT_PANID; /* Set all IEEE addresses */ - ieee802154_radio_set_hw_addr_filter(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), &short_addr, &ext_addr, &panid); + ieee802154_radio_config_addr_filter(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), + IEEE802154_AF_SHORT_ADDR, &short_addr); + ieee802154_radio_config_addr_filter(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), + IEEE802154_AF_EXT_ADDR, &ext_addr); + ieee802154_radio_config_addr_filter(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), + IEEE802154_AF_PANID, &panid); /* Set PHY configuration */ ieee802154_phy_conf_t conf = {.channel=CONFIG_IEEE802154_DEFAULT_CHANNEL, .page=CONFIG_IEEE802154_DEFAULT_SUBGHZ_PAGE, .pow=CONFIG_IEEE802154_DEFAULT_TXPOWER}; From 7d14fb3571e3d56ed97e6f3b4bf9021bf6d3eab6 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 18 Nov 2020 14:01:31 +0100 Subject: [PATCH 8/8] ieee802154/hal: remove set_rx_mode --- pkg/openwsn/Makefile.include | 5 +++ pkg/openwsn/contrib/radio_hal.c | 6 +-- sys/include/net/ieee802154/radio.h | 60 -------------------------- sys/net/link_layer/ieee802154/submac.c | 9 ++-- tests/ieee802154_hal/main.c | 37 ++++++---------- 5 files changed, 25 insertions(+), 92 deletions(-) diff --git a/pkg/openwsn/Makefile.include b/pkg/openwsn/Makefile.include index e688f15b16..1ed97f0cc9 100644 --- a/pkg/openwsn/Makefile.include +++ b/pkg/openwsn/Makefile.include @@ -72,5 +72,10 @@ ifneq (,$(filter at86rf2xx,$(USEMODULE))) CFLAGS += -DAT86RF2XX_BASIC_MODE endif +# Auto ACK should be disabled in order to run OpenWSN +ifndef CONFIG_KCONFIG_USEMODULE_IEEE802154 + CFLAGS += -DCONFIG_IEEE802154_AUTO_ACK_DISABLE +endif + # LLVM ARM shows issues with missing definitions for stdatomic TOOLCHAINS_BLACKLIST += llvm diff --git a/pkg/openwsn/contrib/radio_hal.c b/pkg/openwsn/contrib/radio_hal.c index c7e61fa694..b69aeddc38 100644 --- a/pkg/openwsn/contrib/radio_hal.c +++ b/pkg/openwsn/contrib/radio_hal.c @@ -140,8 +140,8 @@ int openwsn_radio_init(void *radio_dev) /* If the radio is still not in TRX_OFF state, spin */ while (ieee802154_radio_confirm_on(dev) == -EAGAIN) {} - /* Enable basic mode, no AUTOACK. no CSMA */ - ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_AACK_DISABLED); + /* Enable basic mode (no AUTOACK. no CSMA-CA). + * Auto ACK is disabled via CONFIG_IEEE802154_AUTO_ACK_DISABLE. */ /* MAC layer retransmissions are disabled by _set_csma_params() */ ieee802154_radio_set_csma_params(dev, NULL, -1); @@ -150,7 +150,7 @@ int openwsn_radio_init(void *radio_dev) where the destination-address mode is 0 (no destination address). per rfc8180 4.5.1 the destination address must be set, which means the destination-address mode can't be 0 */ - ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_PROMISC); + ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_PROMISC); } /* Configure PHY settings (channel, TX power) */ diff --git a/sys/include/net/ieee802154/radio.h b/sys/include/net/ieee802154/radio.h index e980b9ca33..cb42d7abad 100644 --- a/sys/include/net/ieee802154/radio.h +++ b/sys/include/net/ieee802154/radio.h @@ -462,40 +462,6 @@ typedef enum { IEEE802154_CCA_MODE_ED_THRESH_OR_CS, } ieee802154_cca_mode_t; -/** - * @brief RX mode configuration - */ -typedef enum { - /** - * @brief Auto ACK is disabled - */ - IEEE802154_RX_AACK_DISABLED, - /** - * @brief Auto ACK is enabled - */ - IEEE802154_RX_AACK_ENABLED, - /** - * @brief Auto ACK is enabled and frame pending bit set in the next ACK frame - */ - IEEE802154_RX_AACK_FRAME_PENDING, - /** - * @brief Radio is in promiscuous mode - */ - IEEE802154_RX_PROMISC, - /** - * @brief Radio is ready to receive ACK frames - * - * This mode is optional. If a radio decides to implement it, the radio - * should allow ACK frames (and block ACK frames in all other RX modes). - * Note that this mode cannot guarantee that only ACK frames will be - * received. - * - * Expected to be implemented when either @ref IEEE802154_CAP_FRAME_RETRANS - * or @ref IEEE802154_CAP_IRQ_ACK_TIMEOUT is not there. - */ - IEEE802154_RX_WAIT_FOR_ACK, -} ieee802154_rx_mode_t; - /** * @brief Holder of the PHY configuration */ @@ -657,7 +623,6 @@ struct ieee802154_radio_ops { * - @ref config_phy * - @ref config_addr_filter * - @ref set_csma_params - * - @ref set_rx_mode * - @ref set_frame_filter_mode * - @ref config_src_addr_match * - @ref set_frame_retrans (if available) @@ -827,17 +792,6 @@ struct ieee802154_radio_ops { int (*set_csma_params)(ieee802154_dev_t *dev, const ieee802154_csma_be_t *bd, int8_t retries); - /** - * @brief Set the RX mode. - * - * @param[in] dev IEEE802.15.4 device descriptor - * @param[in] mode RX mode - * - * @return 0 on success - * @return negative errno on error - */ - int (*set_rx_mode)(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode); - /** * @brief Set the frame filter moder. * @@ -1456,20 +1410,6 @@ static inline uint32_t ieee802154_radio_get_phy_modes(ieee802154_dev_t *dev) return (dev->driver->caps & IEEE802154_RF_CAPS_PHY_MASK); } -/** - * @brief Shortcut to @ref ieee802154_radio_ops::set_rx_mode - * - * @param[in] dev IEEE802.15.4 device descriptor - * @param[in] mode RX mode - * - * @return result of @ref ieee802154_radio_ops::set_rx_mode - */ -static inline int ieee802154_radio_set_rx_mode(ieee802154_dev_t *dev, - ieee802154_rx_mode_t mode) -{ - return dev->driver->set_rx_mode(dev, mode); -} - /** * @brief Convert a @ref ieee802154_phy_mode_t to a @ref ieee802154_rf_caps_t * value. diff --git a/sys/net/link_layer/ieee802154/submac.c b/sys/net/link_layer/ieee802154/submac.c index 8a7b65d292..3869dcc630 100644 --- a/sys/net/link_layer/ieee802154/submac.c +++ b/sys/net/link_layer/ieee802154/submac.c @@ -76,7 +76,7 @@ static int _perform_csma_ca(ieee802154_submac_t *submac) submac->csma_retries_nb++; } else { - ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_AACK_ENABLED); + ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACCEPT); _tx_end(submac, TX_STATUS_MEDIUM_BUSY, NULL); } @@ -134,7 +134,7 @@ static void _perform_retrans(ieee802154_submac_t *submac) ieee802154_csma_ca_transmit(submac); } else { - ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_AACK_ENABLED); + ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACCEPT); _tx_end(submac, TX_STATUS_NO_ACK, NULL); } } @@ -169,8 +169,7 @@ void ieee802154_submac_rx_done_cb(ieee802154_submac_t *submac) ieee802154_tx_info_t tx_info; tx_info.retrans = submac->retrans; bool fp = (ack[0] & IEEE802154_FCF_FRAME_PEND); - ieee802154_radio_set_rx_mode(submac->dev, - IEEE802154_RX_AACK_ENABLED); + ieee802154_radio_set_frame_filter_mode(submac->dev, IEEE802154_FILTER_ACCEPT); _tx_end(submac, fp ? TX_STATUS_FRAME_PENDING : TX_STATUS_SUCCESS, &tx_info); } @@ -216,7 +215,7 @@ static void _handle_tx_success(ieee802154_submac_t *submac, _tx_end(submac, info->status, info); } else { - ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_WAIT_FOR_ACK); + ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACK_ONLY); /* Handle ACK reception */ ieee802154_submac_ack_timer_set(submac, ACK_TIMEOUT_US); diff --git a/tests/ieee802154_hal/main.c b/tests/ieee802154_hal/main.c index 2dd91c846d..18a9b8bcb3 100644 --- a/tests/ieee802154_hal/main.c +++ b/tests/ieee802154_hal/main.c @@ -48,7 +48,6 @@ static xtimer_t timer_ack; static mutex_t lock; static const char *str_states[3]= {"TRX_OFF", "RX", "TX"}; -static ieee802154_rx_mode_t current_rx_mode; static eui64_t ext_addr; static network_uint16_t short_addr; static uint8_t seq; @@ -86,7 +85,7 @@ static void _ack_timeout(event_t *event) (void) event; ieee802154_dev_t *dev = ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID); - ieee802154_radio_set_rx_mode(dev, current_rx_mode); + ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACCEPT); } static event_t _ack_timeout_ev = { @@ -217,8 +216,8 @@ static void _send(iolist_t *pkt) while(ieee802154_radio_confirm_set_trx_state(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)) == -EAGAIN); /* Trigger the transmit and wait for the mutex unlock (TX_DONE event) */ + ieee802154_radio_set_frame_filter_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), IEEE802154_FILTER_ACK_ONLY); ieee802154_radio_request_transmit(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)); - ieee802154_radio_set_rx_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), IEEE802154_RX_WAIT_FOR_ACK); mutex_lock(&lock); event_post(EVENT_PRIO_HIGHEST, &_tx_finish_ev); @@ -241,8 +240,7 @@ static int _init(void) ieee802154_radio_request_on(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)); while(ieee802154_radio_confirm_on(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)) == -EAGAIN) {} - current_rx_mode = IEEE802154_RX_AACK_ENABLED; - ieee802154_radio_set_rx_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), current_rx_mode); + ieee802154_radio_set_frame_filter_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), IEEE802154_FILTER_ACCEPT); uint16_t panid = CONFIG_IEEE802154_DEFAULT_PANID; /* Set all IEEE addresses */ @@ -462,33 +460,24 @@ int txtsnd(int argc, char **argv) return send(addr, res, len); } -static int rx_mode_cmd(int argc, char **argv) +static int promisc(int argc, char **argv) { - ieee802154_rx_mode_t conf; + ieee802154_filter_mode_t conf; if (argc < 2) { - printf("Usage: %s ", argv[0]); + printf("Usage: %s ", argv[0]); return 1; } - if (strcmp(argv[1], "pend") == 0) { - conf = IEEE802154_RX_AACK_FRAME_PENDING; - puts("ACK enabled with Frame Pending"); - } - else if (strcmp(argv[1], "off") == 0) { - conf = IEEE802154_RX_AACK_DISABLED; - puts("ACK disabled"); - } - else if (strcmp(argv[1], "promisc") == 0) { - conf = IEEE802154_RX_PROMISC; - puts("Promiscuous mode enabled"); + if (strcmp(argv[1], "on") == 0) { + conf = IEEE802154_FILTER_PROMISC; + puts("Enabled promiscuos mode"); } else { - conf = IEEE802154_RX_AACK_ENABLED; - puts("ACK enabled"); + conf = IEEE802154_FILTER_ACCEPT; + puts("Disabled promiscuos mode"); } - current_rx_mode = conf; - ieee802154_radio_set_rx_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), conf); + ieee802154_radio_set_frame_filter_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), conf); return 0; } @@ -734,7 +723,7 @@ static const shell_command_t shell_commands[] = { { "test_states", "Test state changes", _test_states }, { "cca", "Perform CCA", _cca }, { "config_cca", "Config CCA parameters", _config_cca_cmd }, - { "rx_mode", "Enable/Disable AACK or set Frame Pending bit or set promiscuos mode", rx_mode_cmd }, + { "promisc", "Set promiscuos mode", promisc }, { "tx_mode", "Enable CSMA-CA, CCA or direct transmission", txmode_cmd }, { "caps", "Get a list of caps supported by the device", _caps_cmd }, { NULL, NULL, NULL }