diff --git a/drivers/wireless/ieee802154/mrf24j40/mrf24j40_radif.c b/drivers/wireless/ieee802154/mrf24j40/mrf24j40_radif.c index c6f2a431d80..f5b06894f07 100644 --- a/drivers/wireless/ieee802154/mrf24j40/mrf24j40_radif.c +++ b/drivers/wireless/ieee802154/mrf24j40/mrf24j40_radif.c @@ -564,6 +564,13 @@ int mrf24j40_getattr(FAR struct ieee802154_radio_s *radio, } break; + case IEEE802154_ATTR_PHY_FCS_LEN: + { + attrval->phy.fcslen = 2; + ret = IEEE802154_STATUS_SUCCESS; + } + break; + default: ret = IEEE802154_STATUS_UNSUPPORTED_ATTRIBUTE; } diff --git a/drivers/wireless/ieee802154/xbee/xbee_mac.c b/drivers/wireless/ieee802154/xbee/xbee_mac.c index a68f65c1bc0..2fa632386d2 100644 --- a/drivers/wireless/ieee802154/xbee/xbee_mac.c +++ b/drivers/wireless/ieee802154/xbee/xbee_mac.c @@ -468,7 +468,14 @@ int xbee_req_get(XBEEHANDLE xbee, enum ieee802154_attr_e attr, } break; - case IEEE802154_ATTR_RADIO_REGDUMP: + case IEEE802154_ATTR_PHY_FCS_LEN: + { + attrval->phy.fcslen = 2; + ret = IEEE802154_STATUS_SUCCESS; + } + break + + case IEEE802154_ATTR_PHY_REGDUMP: { xbee_regdump(priv); } diff --git a/include/nuttx/wireless/ieee802154/ieee802154_mac.h b/include/nuttx/wireless/ieee802154/ieee802154_mac.h index e272a90b24c..08cafb9ee42 100644 --- a/include/nuttx/wireless/ieee802154/ieee802154_mac.h +++ b/include/nuttx/wireless/ieee802154/ieee802154_mac.h @@ -358,7 +358,7 @@ enum ieee802154_attr_e { /* PHY PIB Attributes */ - IEEE802154_ATTR_PHY_CHAN = 0x00, + IEEE802154_ATTR_PHY_CHAN, IEEE802154_ATTR_PHY_CHANNELS_SUPPORTED, IEEE802154_ATTR_PHY_TX_POWER_TOLERANCE, IEEE802154_ATTR_PHY_TX_POWER, @@ -394,11 +394,16 @@ enum ieee802154_attr_e IEEE802154_ATTR_PHY_UWB_RX_RMARKER, IEEE802154_ATTR_PHY_RFRAME_PROC_TIME, IEEE802154_ATTR_PHY_CCA_DURATION, - IEEE802154_ATTR_PHY_SYMBOL_DURATION, /* Non-standard attribute */ + + /* Non-standard PHY attributes */ + + IEEE802154_ATTR_PHY_SYMBOL_DURATION, + IEEE802154_ATTR_PHY_FCS_LEN, + IEEE802154_ATTR_PHY_REGDUMP, /* MAC PIB Attributes */ - IEEE802154_ATTR_MAC_EADDR = 0x40, + IEEE802154_ATTR_MAC_EADDR, IEEE802154_ATTR_MAC_ACK_WAIT_DUR, IEEE802154_ATTR_MAC_ASSOCIATED_PANCOORD, IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT, @@ -435,11 +440,10 @@ enum ieee802154_attr_e IEEE802154_ATTR_MAC_TX_CTRL_ACTIVE_DUR, IEEE802154_ATTR_MAC_TX_CTRL_PAUSE_DUR, IEEE802154_ATTR_MAC_TX_TOTAL_DUR, - IEEE802154_ATTR_MAC_DEVMODE, /* Non-standard */ /* MAC Security Attributes */ - IEEE802154_ATTR_MAC_KEY_TABLE = 0x70, + IEEE802154_ATTR_MAC_KEY_TABLE, IEEE802154_ATTR_MAC_DEV_TABLE, IEEE802154_ATTR_MAC_SEC_LVL_TABLE, IEEE802154_ATTR_MAC_FRAME_COUNTER, @@ -451,9 +455,9 @@ enum ieee802154_attr_e IEEE802154_ATTR_MAC_PANCOORD_EXT_ADDR, IEEE802154_ATTR_MAC_PANCOORD_SHORT_ADDR, - /* Special Attributes */ + /* Non-standard MAC Atrributes*/ - IEEE802154_ATTR_RADIO_REGDUMP = 0xF0, + IEEE802154_ATTR_MAC_DEVMODE, }; /* Frame Type */ @@ -671,9 +675,10 @@ union ieee802154_macattr_u union ieee802154_phyattr_u { - uint8_t chan; - int32_t txpwr; - uint32_t symdur_picosec; + uint8_t chan; + int32_t txpwr; + uint32_t symdur_picosec; + uint8_t fcslen; /* TODO: Fill this out as we implement supported get/set commands */ }; diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index d223965d74c..63aef4c5031 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -450,11 +450,7 @@ static ssize_t mac802154dev_read(FAR struct file *filep, FAR char *buffer, */ } - /* Check if the MAC layer is in promiscuous mode. If it is, pass the entire - * frame, including IEEE 802.15.4 header and checksum by assuming the frame - * starts at the beginning of the IOB and goes 2 past the length to account - * for the FCS that the radio driver "removes" - */ + /* Check if the MAC layer is in promiscuous mode. */ req.attr = IEEE802154_ATTR_MAC_PROMISCUOUS_MODE; @@ -463,8 +459,18 @@ static ssize_t mac802154dev_read(FAR struct file *filep, FAR char *buffer, if (ret == 0 && req.attrval.mac.promisc_mode) { - rx->length = ind->frame->io_len + 2; - rx->offset = ind->frame->io_offset; + /* If it is, add the FCS back into the frame by increasing the length + * by the PHY layer's FCS length. + */ + + req.attr = IEEE802154_ATTR_PHY_FCS_LEN; + ret = mac802154_ioctl(dev->md_mac, MAC802154IOC_MLME_GET_REQUEST, + (unsigned long)&req); + if (ret == OK) + { + rx->length = ind->frame->io_len + req.attrval.phy.fcslen; + rx->offset = ind->frame->io_offset; + } /* Copy the entire frame from the IOB to the user supplied struct */