diff --git a/drivers/wireless/ieee802154/mrf24j40.c b/drivers/wireless/ieee802154/mrf24j40.c index e4553a3b8c..fe022d5114 100644 --- a/drivers/wireless/ieee802154/mrf24j40.c +++ b/drivers/wireless/ieee802154/mrf24j40.c @@ -234,10 +234,10 @@ static int mrf24j40_txnotify_csma(FAR struct ieee802154_radio_s *radio); static int mrf24j40_txnotify_gts(FAR struct ieee802154_radio_s *radio); static int mrf24j40_get_attr(FAR struct ieee802154_radio_s *radio, enum ieee802154_pib_attr_e pib_attr, - FAR union ieee802154_attr_val_u *attr_value); + FAR union ieee802154_attr_u *attrval); static int mrf24j40_set_attr(FAR struct ieee802154_radio_s *radio, enum ieee802154_pib_attr_e pib_attr, - FAR const union ieee802154_attr_val_u *attr_value); + FAR const union ieee802154_attr_u *attrval); /**************************************************************************** * Private Data @@ -349,7 +349,7 @@ static int mrf24j40_txnotify_gts(FAR struct ieee802154_radio_s *radio) static int mrf24j40_get_attr(FAR struct ieee802154_radio_s *radio, enum ieee802154_pib_attr_e pib_attr, - FAR union ieee802154_attr_val_u *attr_value) + FAR union ieee802154_attr_u *attrval) { FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio; int ret; @@ -358,7 +358,7 @@ static int mrf24j40_get_attr(FAR struct ieee802154_radio_s *radio, { case IEEE802154_PIB_MAC_EXTENDED_ADDR: { - memcpy(&attr_value->mac.eaddr[0], &dev->addr.eaddr[0], 8); + memcpy(&attrval->mac.eaddr[0], &dev->addr.eaddr[0], 8); ret = IEEE802154_STATUS_SUCCESS; } break; @@ -370,7 +370,7 @@ static int mrf24j40_get_attr(FAR struct ieee802154_radio_s *radio, static int mrf24j40_set_attr(FAR struct ieee802154_radio_s *radio, enum ieee802154_pib_attr_e pib_attr, - FAR const union ieee802154_attr_val_u *attr_value) + FAR const union ieee802154_attr_u *attrval) { FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio; int ret; @@ -379,13 +379,13 @@ static int mrf24j40_set_attr(FAR struct ieee802154_radio_s *radio, { case IEEE802154_PIB_MAC_EXTENDED_ADDR: { - mrf24j40_seteaddr(dev, &attr_value->mac.eaddr[0]); + mrf24j40_seteaddr(dev, &attrval->mac.eaddr[0]); ret = IEEE802154_STATUS_SUCCESS; } break; case IEEE802154_PIB_MAC_PROMISCUOUS_MODE: { - if (attr_value->mac.promisc_mode) + if (attrval->mac.promisc_mode) { mrf24j40_setrxmode(dev, MRF24J40_RXMODE_PROMISC); } @@ -399,7 +399,7 @@ static int mrf24j40_set_attr(FAR struct ieee802154_radio_s *radio, break; case IEEE802154_PIB_MAC_RX_ON_WHEN_IDLE: { - dev->rxonidle = attr_value->mac.rxonidle; + dev->rxonidle = attrval->mac.rxonidle; mrf24j40_rxenable(dev, dev->rxonidle); } break; diff --git a/include/nuttx/wireless/ieee802154/ieee802154_mac.h b/include/nuttx/wireless/ieee802154/ieee802154_mac.h index 2c6a846af7..15963b46e1 100644 --- a/include/nuttx/wireless/ieee802154/ieee802154_mac.h +++ b/include/nuttx/wireless/ieee802154/ieee802154_mac.h @@ -299,7 +299,7 @@ enum ieee802154_pib_attr_e IEEE802154_PIB_MAC_MIN_BE, IEEE802154_PIB_MAC_LIFS_PERIOD, IEEE802154_PIB_MAC_SIFS_PERIOD, - IEEE802154_PIB_MAC_PAN_ID, + IEEE802154_PIB_MAC_PANID, IEEE802154_PIB_MAC_PROMISCUOUS_MODE, IEEE802154_PIB_MAC_RANGING_SUPPORT, IEEE802154_PIB_MAC_RESPONSE_WAIT_TIME, @@ -329,6 +329,13 @@ enum ieee802154_pib_attr_e IEEE802154_PIB_MAC_PANCOORD_SHORT_ADDR, }; +enum ieee802154_devmode_e +{ + IEEE802154_DEVMODE_ENDPOINT, + IEEE802154_DEVMODE_COORD, + IEEE802154_DEVMODE_PANCOORD +}; + #define IEEE802154_EADDR_LEN 8 /* IEEE 802.15.4 Device address @@ -338,7 +345,7 @@ enum ieee802154_pib_attr_e * Extended address + PAN id : PPPP/LLLLLLLLLLLLLLLL */ -enum ieee802154_addr_mode_e +enum ieee802154_addrmode_e { IEEE802154_ADDRMODE_NONE = 0, IEEE802154_ADDRMODE_SHORT = 2, @@ -349,7 +356,7 @@ struct ieee802154_addr_s { /* Address mode. Short or Extended */ - enum ieee802154_addr_mode_e mode; + enum ieee802154_addrmode_e mode; uint16_t panid; /* PAN identifier, can be * IEEE802154_PAN_UNSPEC */ @@ -549,7 +556,7 @@ union ieee802154_secattr_u /* TODO: Fill this out as we implement supported get/set commands */ }; -union ieee802154_attr_val_u +union ieee802154_attr_u { union ieee802154_macattr_u mac; union ieee802154_phyattr_u phy; @@ -574,7 +581,7 @@ enum ieee802154_scantype_e struct ieee802154_frame_meta_s { - enum ieee802154_addr_mode_e src_addr_mode; /* Source Address Mode */ + enum ieee802154_addrmode_e src_addrmode; /* Source Address Mode */ struct ieee802154_addr_s dest_addr; /* Destination Address */ uint8_t msdu_handle; /* Handle assoc. with MSDU */ @@ -1159,7 +1166,7 @@ struct ieee802154_scan_conf_s struct ieee802154_get_req_s { enum ieee802154_pib_attr_e pib_attr; - union ieee802154_attr_val_u attr_value; + union ieee802154_attr_u attrval; }; /***************************************************************************** @@ -1179,7 +1186,7 @@ struct ieee802154_get_req_s struct ieee802154_set_req_s { enum ieee802154_pib_attr_e pib_attr; - union ieee802154_attr_val_u attr_value; + union ieee802154_attr_u attrval; }; /***************************************************************************** @@ -1195,23 +1202,23 @@ struct ieee802154_set_req_s struct ieee802154_start_req_s { - uint16_t pan_id; - uint8_t ch_num; - uint8_t ch_page; + uint16_t panid; + uint8_t chnum; + uint8_t chpage; - uint32_t start_time : 24; - uint32_t beacon_order : 8; + uint32_t starttime : 24; + uint32_t beaconorder : 8; - uint8_t sf_order; + uint8_t superframeorder; - uint8_t pan_coord : 1; - uint8_t batt_life_ext : 1; - uint8_t coord_realign : 1; + uint8_t pancoord : 1; + uint8_t battlifeext : 1; + uint8_t coordrealign : 1; #ifdef CONFIG_IEEE802154_SECURITY /* Security information if enabled */ - struct ieee802154_security_s coord_realign; + struct ieee802154_security_s coordrealign; struct ieee802154_security_s beacon; #endif }; diff --git a/include/nuttx/wireless/ieee802154/ieee802154_radio.h b/include/nuttx/wireless/ieee802154/ieee802154_radio.h index fcbc7ec1b7..d3fcb5db74 100644 --- a/include/nuttx/wireless/ieee802154/ieee802154_radio.h +++ b/include/nuttx/wireless/ieee802154/ieee802154_radio.h @@ -84,10 +84,10 @@ struct ieee802154_radioops_s CODE int (*txnotify_gts)(FAR struct ieee802154_radio_s *radio); CODE int (*get_attr) (FAR struct ieee802154_radio_s *radio, enum ieee802154_pib_attr_e pib_attr, - FAR union ieee802154_attr_val_u *attr_value); + FAR union ieee802154_attr_u *attrval); CODE int (*set_attr) (FAR struct ieee802154_radio_s *radio, enum ieee802154_pib_attr_e pib_attr, - FAR const union ieee802154_attr_val_u *attr_value); + FAR const union ieee802154_attr_u *attrval); }; struct ieee802154_radio_s diff --git a/net/sixlowpan/sixlowpan_framer.c b/net/sixlowpan/sixlowpan_framer.c index eef8583dd3..2d8d54480a 100644 --- a/net/sixlowpan/sixlowpan_framer.c +++ b/net/sixlowpan/sixlowpan_framer.c @@ -163,7 +163,7 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee, /* Source address mode */ - meta->src_addr_mode = pktmeta->sextended != 0? + meta->src_addrmode = pktmeta->sextended != 0? IEEE802154_ADDRMODE_EXTENDED : IEEE802154_ADDRMODE_SHORT; diff --git a/net/sixlowpan/sixlowpan_utils.c b/net/sixlowpan/sixlowpan_utils.c index d04ce878c7..75da3ed556 100644 --- a/net/sixlowpan/sixlowpan_utils.c +++ b/net/sixlowpan/sixlowpan_utils.c @@ -195,7 +195,7 @@ int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee, int ret; memcpy(arg.ifr_name, ieee->i_dev.d_ifname, IFNAMSIZ); - arg.u.getreq.pib_attr = IEEE802154_PIB_MAC_PAN_ID; + arg.u.getreq.pib_attr = IEEE802154_PIB_MAC_PANID; ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST, (unsigned long)((uintptr_t)&arg)); if (ret < 0) @@ -204,7 +204,7 @@ int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee, return ret; } - *panid = arg.u.getreq.attr_value.mac.panid; + *panid = arg.u.getreq.attrval.mac.panid; return OK; } diff --git a/wireless/ieee802154/mac802154.c b/wireless/ieee802154/mac802154.c index 738eb47f30..a345d81933 100644 --- a/wireless/ieee802154/mac802154.c +++ b/wireless/ieee802154/mac802154.c @@ -161,7 +161,7 @@ struct ieee802154_privmac_s /* Holds all address information (Extended, Short) for Coordinator */ - struct ieee802154_addr_s coord_addr; + struct ieee802154_addr_s coordaddr; /* The maximum number of symbols to wait for an acknowledgement frame to * arrive following a transmitted data frame. [1] pg. 126 @@ -170,7 +170,7 @@ struct ieee802154_privmac_s * sure at the time what the range of reasonable values was. */ - uint32_t ack_wait_dur; + uint32_t ack_waitdur; /* The maximum time to wait either for a frame intended as a response to a * data request frame or for a broadcast frame following a beacon with the @@ -180,59 +180,59 @@ struct ieee802154_privmac_s * sure at the time what the range of reasonable values was. */ - uint32_t max_frame_wait_time; + uint32_t max_frame_waittime; /* The maximum time (in unit periods) that a transaction is stored by a * coordinator and indicated in its beacon. */ - uint16_t trans_persist_time; + uint16_t trans_persisttime; /* Contents of beacon payload */ uint8_t beacon_payload[IEEE802154_MAX_BEACON_PAYLOAD_LEN]; uint8_t beacon_payload_len; /* Length of beacon payload */ - uint8_t batt_life_ext_periods; /* # of backoff periods during which rx is + uint8_t battlifeext_periods; /* # of backoff periods during which rx is * enabled after the IFS following beacon */ uint8_t bsn; /* Seq. num added to tx beacon frame */ uint8_t dsn; /* Seq. num added to tx data or MAC frame */ - uint8_t max_retries; /* Max # of retries alloed after tx failure */ + uint8_t maxretries; /* Max # of retries alloed after tx failure */ /* The maximum time, in multiples of aBaseSuperframeDuration, a device shall * wait for a response command frame to be available following a request * command frame. [1] 128. */ - uint8_t resp_wait_time; + uint8_t resp_waittime; /* The total transmit duration (including PHY header and FCS) specified in * symbols. [1] pg. 129. */ - uint32_t tx_total_dur; + uint32_t tx_totaldur; /* Start of 32-bit bitfield */ - uint32_t is_assoc : 1; /* Are we associated to the PAN */ - uint32_t assoc_permit : 1; /* Are we allowing assoc. as a coord. */ - uint32_t auto_req : 1; /* Automatically send data req. if addr + uint32_t isassoc : 1; /* Are we associated to the PAN */ + uint32_t assocpermit : 1; /* Are we allowing assoc. as a coord. */ + uint32_t autoreq : 1; /* Automatically send data req. if addr * addr is in the beacon frame */ - uint32_t batt_life_ext : 1; /* Is BLE enabled */ - uint32_t gts_permit : 1; /* Is PAN Coord. accepting GTS reqs. */ - uint32_t promisc_mode : 1; /* Is promiscuous mode on? */ - uint32_t rng_support : 1; /* Does MAC sublayer support ranging */ - uint32_t rx_when_idle : 1; /* Recvr. on during idle periods */ + uint32_t battlifeext : 1; /* Is BLE enabled */ + uint32_t gtspermit : 1; /* Is PAN Coord. accepting GTS reqs. */ + uint32_t promisc : 1; /* Is promiscuous mode on? */ + uint32_t rngsupport : 1; /* Does MAC sublayer support ranging */ uint32_t sec_enabled : 1; /* Does MAC sublayer have security en. */ + uint32_t timestamp_support : 1; /* Does MAC layer supports timestamping */ - uint32_t max_csma_backoffs : 3; /* Max num backoffs for CSMA algorithm + uint32_t max_csmabackoffs : 3; /* Max num backoffs for CSMA algorithm * before declaring ch access failure */ - uint32_t beacon_order : 4; /* Freq. that beacon is transmitted */ + uint32_t beaconorder : 4; /* Freq. that beacon is transmitted */ - uint32_t superframe_order : 4; /* Length of active portion of outgoing + uint32_t superframeorder : 4; /* Length of active portion of outgoing * superframe, including the beacon */ /* The offset, measured is symbols, between the symbol boundary at which the @@ -241,27 +241,30 @@ struct ieee802154_privmac_s * the frames [1] pg. 129. */ - uint32_t sync_symb_offset : 12; + uint32_t sync_symboffset : 12; /* End of 32-bit bitfield */ /* Start of 32-bit bitfield */ - uint32_t beacon_tx_time : 24; /* Time of last beacon transmit */ - uint32_t min_be : 4; /* Min value of backoff exponent (BE) */ - uint32_t max_be : 4; /* Max value of backoff exponent (BE) */ + uint32_t beacon_txtime : 24; /* Time of last beacon transmit */ + uint32_t minbe : 4; /* Min value of backoff exponent (BE) */ + uint32_t maxbe : 4; /* Max value of backoff exponent (BE) */ /* End of 32-bit bitfield */ /* Start of 32-bit bitfield */ - uint32_t tx_ctrl_active_dur : 17; /* Duration for which tx is permitted to - * be active */ - uint32_t tx_ctrl_pause_dur : 1; /* Duration after tx before another tx is + uint32_t txctrl_activedur : 17; /* Duration for which tx is permitted to + * be active */ + uint32_t txctrl_pausedur : 1; /* Duration after tx before another tx is * permitted. 0=2000, 1= 10000 */ - uint32_t timestamp_support : 1; /* Does MAC layer supports timestamping */ - uint32_t is_coord : 1; /* Is this device acting as coordinator */ - /* 12-bits remaining */ + + /* What type of device is this node acting as */ + + enum ieee802154_devmode_e devmode : 2; + + /* 11-bits remaining */ /* End of 32-bit bitfield. */ @@ -303,7 +306,7 @@ static void mac802154_rxframe(FAR const struct ieee802154_radiocb_s *radiocb, * Private Data ****************************************************************************/ -/* Map between ieee802154_addr_mode_e enum and actual address length */ +/* Map between ieee802154_addrmode_e enum and actual address length */ static const uint8_t mac802154_addr_length[4] = {0, 0, 2, 8}; @@ -491,37 +494,36 @@ static FAR struct ieee802154_data_ind_s * static int mac802154_defaultmib(FAR struct ieee802154_privmac_s *priv) { - priv->is_assoc = false; /* Not associated with a PAN */ - priv->assoc_permit = false; /* Device (if coord) not accepting association */ - priv->auto_req = true; /* Auto send data req if addr. in beacon */ - priv->batt_life_ext = false; /* BLE disabled */ + priv->isassoc = false; /* Not associated with a PAN */ + priv->assocpermit = false; /* Device (if coord) not accepting association */ + priv->autoreq = true; /* Auto send data req if addr. in beacon */ + priv->battlifeext = false; /* BLE disabled */ priv->beacon_payload_len = 0; /* Beacon payload NULL */ - priv->beacon_order = 15; /* Non-beacon enabled network */ - priv->superframe_order = 15; /* Length of active portion of outgoing SF */ - priv->beacon_tx_time = 0; /* Device never sent a beacon */ + priv->beaconorder = 15; /* Non-beacon enabled network */ + priv->superframeorder = 15; /* Length of active portion of outgoing SF */ + priv->beacon_txtime = 0; /* Device never sent a beacon */ #warning Set BSN and DSN to random values! priv->bsn = 0; priv->dsn = 0; - priv->gts_permit = true; /* PAN Coord accepting GTS requests */ - priv->min_be = 3; /* Min value of backoff exponent (BE) */ - priv->max_be = 5; /* Max value of backoff exponent (BE) */ - priv->max_csma_backoffs = 4; /* Max # of backoffs before failure */ - priv->max_retries = 3; /* Max # of retries allowed after failure */ - priv->promisc_mode = false; /* Device not in promiscuous mode */ - priv->rng_support = false; /* Ranging not yet supported */ - priv->resp_wait_time = 32; /* 32 SF durations */ - priv->rx_when_idle = false; /* Don't receive while idle */ + priv->gtspermit = true; /* PAN Coord accepting GTS requests */ + priv->minbe = 3; /* Min value of backoff exponent (BE) */ + priv->maxbe = 5; /* Max value of backoff exponent (BE) */ + priv->max_csmabackoffs = 4; /* Max # of backoffs before failure */ + priv->maxretries = 3; /* Max # of retries allowed after failure */ + priv->promisc = false; /* Device not in promiscuous mode */ + priv->rngsupport = false; /* Ranging not yet supported */ + priv->resp_waittime = 32; /* 32 SF durations */ priv->sec_enabled = false; /* Security disabled by default */ - priv->tx_total_dur = 0; /* 0 transmit duration */ + priv->tx_totaldur = 0; /* 0 transmit duration */ - priv->trans_persist_time = 0x01F4; + priv->trans_persisttime = 0x01F4; /* Reset the Coordinator address */ - priv->coord_addr.mode = IEEE802154_ADDRMODE_NONE; - priv->coord_addr.saddr = IEEE802154_SADDR_UNSPEC; - memcpy(&priv->coord_addr.eaddr[0], IEEE802154_EADDR_UNSPEC, + priv->coordaddr.mode = IEEE802154_ADDRMODE_NONE; + priv->coordaddr.saddr = IEEE802154_SADDR_UNSPEC; + memcpy(&priv->coordaddr.eaddr[0], IEEE802154_EADDR_UNSPEC, IEEE802154_EADDR_LEN); /* Reset the device's address */ @@ -545,6 +547,7 @@ static int mac802154_defaultmib(FAR struct ieee802154_privmac_s *priv) * macTimestampSupported * macTxControlActiveDuration * macTxControlPauseDuration + * macRxOnWhenIdle */ return OK; @@ -1111,7 +1114,7 @@ int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg) case MAC802154IOC_MLME_GET_REQUEST: { ret = mac802154_req_get(mac, macarg->getreq.pib_attr, - &macarg->getreq.attr_value); + &macarg->getreq.attrval); } break; case MAC802154IOC_MLME_GTS_REQUEST: @@ -1142,7 +1145,7 @@ int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg) case MAC802154IOC_MLME_SET_REQUEST: { ret = mac802154_req_set(mac, macarg->setreq.pib_attr, - &macarg->setreq.attr_value); + &macarg->setreq.attrval); } break; case MAC802154IOC_MLME_START_REQUEST: @@ -1192,14 +1195,15 @@ int mac802154_get_mhrlen(MACHANDLE mac, * to NONE */ if (meta->dest_addr.mode == IEEE802154_ADDRMODE_NONE && - meta->src_addr_mode == IEEE802154_ADDRMODE_NONE) + meta->src_addrmode == IEEE802154_ADDRMODE_NONE) { return -EINVAL; } /* The source address can only be set to NONE if the device is the PAN coord */ - if (meta->src_addr_mode == IEEE802154_ADDRMODE_NONE && !priv->is_coord) + if (meta->src_addrmode == IEEE802154_ADDRMODE_NONE && + priv->devmode != IEEE802154_DEVMODE_PANCOORD) { return -EINVAL; } @@ -1210,14 +1214,14 @@ int mac802154_get_mhrlen(MACHANDLE mac, /* Add the source address length */ - ret += mac802154_addr_length[ meta->src_addr_mode]; + ret += mac802154_addr_length[ meta->src_addrmode]; /* If both destination and source addressing information is present, the MAC * sublayer shall compare the destination and source PAN identifiers. * [1] pg. 41. */ - if (meta->src_addr_mode != IEEE802154_ADDRMODE_NONE && + if (meta->src_addrmode != IEEE802154_ADDRMODE_NONE && meta->dest_addr.mode != IEEE802154_ADDRMODE_NONE) { /* If the PAN identifiers are identical, the PAN ID Compression field @@ -1236,7 +1240,7 @@ int mac802154_get_mhrlen(MACHANDLE mac, * PAN ID if the respective address is included */ - if (meta->src_addr_mode != IEEE802154_ADDRMODE_NONE) + if (meta->src_addrmode != IEEE802154_ADDRMODE_NONE) { ret += 2; /* 2 bytes for source PAN ID */ } @@ -1347,7 +1351,7 @@ int mac802154_req_data(MACHANDLE mac, * [1] pg. 41. */ - if (meta->src_addr_mode != IEEE802154_ADDRMODE_NONE && + if (meta->src_addrmode != IEEE802154_ADDRMODE_NONE && meta->dest_addr.mode != IEEE802154_ADDRMODE_NONE) { /* If the PAN identifiers are identical, the PAN ID Compression field @@ -1361,7 +1365,7 @@ int mac802154_req_data(MACHANDLE mac, } } - if (meta->src_addr_mode != IEEE802154_ADDRMODE_NONE) + if (meta->src_addrmode != IEEE802154_ADDRMODE_NONE) { /* If the destination address is not included, or if PAN ID Compression * is off, we need to include the Source PAN ID. @@ -1374,12 +1378,12 @@ int mac802154_req_data(MACHANDLE mac, mhr_len += 2; } - if (meta->src_addr_mode == IEEE802154_ADDRMODE_SHORT) + if (meta->src_addrmode == IEEE802154_ADDRMODE_SHORT) { memcpy(&frame->io_data[mhr_len], &priv->addr.saddr, 2); mhr_len += 2; } - else if (meta->src_addr_mode == IEEE802154_ADDRMODE_EXTENDED) + else if (meta->src_addrmode == IEEE802154_ADDRMODE_EXTENDED) { memcpy(&frame->io_data[mhr_len], &priv->addr.eaddr, IEEE802154_EADDR_LEN); @@ -1390,7 +1394,7 @@ int mac802154_req_data(MACHANDLE mac, /* Set the source addr mode inside the frame control field */ - *frame_ctrl |= (meta->src_addr_mode << IEEE802154_FRAMECTRL_SHIFT_SADDR); + *frame_ctrl |= (meta->src_addrmode << IEEE802154_FRAMECTRL_SHIFT_SADDR); /* Each time a data or a MAC command frame is generated, the MAC sublayer * shall copy the value of macDSN into the Sequence Number field of the MHR @@ -1458,7 +1462,8 @@ int mac802154_req_data(MACHANDLE mac, * error, since this really shouldn't be happening. */ - if (priv->is_coord && meta->dest_addr.mode != IEEE802154_ADDRMODE_NONE) + if (priv->devmode == IEEE802154_DEVMODE_PANCOORD && + meta->dest_addr.mode != IEEE802154_ADDRMODE_NONE) { /* Link the transaction into the indirect_trans list */ @@ -1482,7 +1487,11 @@ int mac802154_req_data(MACHANDLE mac, priv->radio->ops->txnotify_csma(priv->radio); - sem_wait(&trans.sem); + ret = sem_wait(&trans.sem); + if (ret < 0) + { + return -EINTR; + } } } @@ -1677,7 +1686,7 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req) ****************************************************************************/ int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, - FAR union ieee802154_attr_val_u *attr_value) + FAR union ieee802154_attr_u *attrval) { FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; @@ -1700,7 +1709,7 @@ int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, ****************************************************************************/ int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, - FAR const union ieee802154_attr_val_u *attr_value) + FAR const union ieee802154_attr_u *attrval) { FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; @@ -1712,12 +1721,12 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, { /* Set the MAC copy of the address in the table */ - memcpy(&priv->addr.eaddr[0], &attr_value->mac.eaddr[0], + memcpy(&priv->addr.eaddr[0], &attrval->mac.eaddr[0], IEEE802154_EADDR_LEN); /* Tell the radio about the attribute */ - priv->radio->ops->set_attr(priv->radio, pib_attr, attr_value); + priv->radio->ops->set_attr(priv->radio, pib_attr, attrval); ret = IEEE802154_STATUS_SUCCESS; } @@ -1728,7 +1737,7 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, * it along. */ - ret = priv->radio->ops->set_attr(priv->radio, pib_attr, attr_value); + ret = priv->radio->ops->set_attr(priv->radio, pib_attr, attrval); } break; } @@ -1749,7 +1758,95 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req) { FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; + int ret; + + /* Get exclusive access to the MAC */ + + ret = mac802154_takesem(&priv->exclsem); + if (ret < 0) + { + wlerr("ERROR: mac802154_takesem failed: %d\n", ret); + return ret; + } + + /* When the CoordRealignment parameter is set to TRUE, the coordinator + * attempts to transmit a coordinator realignment command frame as described + * in 5.1.2.3.2. If the transmission of the coordinator realignment command + * fails due to a channel access failure, the MLME will not make any changes + * to the superframe configuration. (i.e., no PIB attributes will be changed). + * If the coordinator realignment command is successfully transmitted, the + * MLME updates the PIB attributes BeaconOrder, SuperframeOrder, PANId, + * ChannelPage, and ChannelNumber parameters. [1] pg. 106 + */ + + if (req->coordrealign) + { + /* TODO: Finish the realignment functionality */ + + return -ENOTTY; + } + + /* Set the PANID attribute */ + + priv->addr.panid = req->panid; + priv->radio->ops->set_attr(priv->radio, IEEE802154_PIB_MAC_PANID, + (FAR const union ieee802154_attr_u *)&req->panid); + + /* Set the radio attributes */ + priv->radio->ops->set_attr(priv->radio, IEEE802154_PIB_PHY_CURRENT_CHANNEL, + (FAR const union ieee802154_attr_u *)&req->chnum); + + priv->radio->ops->set_attr(priv->radio, IEEE802154_PIB_PHY_CURRENT_PAGE, + (FAR const union ieee802154_attr_u *)&req->chpage); + + /* Set the superframe order */ + + if(req->superframeorder > 15) + { + ret = -EINVAL; + goto errout; + } + + priv->superframeorder = req->superframeorder; + + /* Set the beacon order */ + + if(req->beaconorder > 15) + { + ret = -EINVAL; + goto errout; + } + + priv->beaconorder = req->beaconorder; + + if (req->pancoord) + { + priv->devmode = IEEE802154_DEVMODE_PANCOORD; + } + else + { + priv->devmode = IEEE802154_DEVMODE_COORD; + } + + /* If the BeaconOrder parameter is less than 15, the MLME sets macBattLifeExt to + * the value of the BatteryLifeExtension parameter. If the BeaconOrder parameter + * equals 15, the value of the BatteryLifeExtension parameter is ignored. + * [1] pg. 106 + */ + + if (priv->beaconorder < 15) + { + priv->battlifeext = req->battlifeext; + + /* TODO: Finish starting beacon enabled network */ + return -ENOTTY; + } + + return OK; + +errout: + mac802154_givesem(&priv->exclsem); + return ret; } /**************************************************************************** diff --git a/wireless/ieee802154/mac802154.h b/wireless/ieee802154/mac802154.h index 66fa5495ca..168bc33cf2 100644 --- a/wireless/ieee802154/mac802154.h +++ b/wireless/ieee802154/mac802154.h @@ -254,7 +254,7 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req); ****************************************************************************/ int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, - FAR union ieee802154_attr_val_u *attr_value); + FAR union ieee802154_attr_u *attrval); /**************************************************************************** * Name: mac802154_req_set @@ -272,7 +272,7 @@ int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, ****************************************************************************/ int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr, - FAR const union ieee802154_attr_val_u *attr_value); + FAR const union ieee802154_attr_u *attrval); /**************************************************************************** * Name: mac802154_req_start diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 21aae1c50f..309ca2c99c 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -653,7 +653,6 @@ static ssize_t mac802154dev_write(FAR struct file *filep, /* Pass the request to the MAC layer */ ret = mac802154_req_data(dev->md_mac, &tx->meta, iob); - if (ret < 0) { wlerr("ERROR: req_data failed %d\n", ret);