mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 09:49:21 +08:00
Merged in merlin17/nuttx/ieee802154 (pull request #342)
Ieee802154 Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
commit
352d8260f2
4 changed files with 150 additions and 30 deletions
|
@ -168,7 +168,7 @@
|
|||
#define IEEE802154_GTS_DESC_PERSISTENCE_TIME 4
|
||||
#define IEEE802154_MAX_BEACON_OVERHEAD 75
|
||||
|
||||
#define IEEE802154_MAX_BEACON_PAYLOAD_LENGTH \
|
||||
#define IEEE802154_MAX_BEACON_PAYLOAD_LEN \
|
||||
(IEEE802154_MAX_PHY_PACKET_SIZE - IEEE802154_MAX_BEACON_OVERHEAD)
|
||||
|
||||
#define IEEE802154_MAX_LOST_BEACONS 4
|
||||
|
@ -840,12 +840,12 @@ struct ieee802154_beaconnotify_ind_s
|
|||
|
||||
/* Beacon payload */
|
||||
|
||||
uint8_t sdu[IEEE802154_MAX_BEACON_PAYLOAD_LENGTH];
|
||||
uint8_t sdu[IEEE802154_MAX_BEACON_PAYLOAD_LEN];
|
||||
};
|
||||
|
||||
#define SIZEOF_IEEE802154_BEACONNOTIFY_IND_S(n) \
|
||||
(sizeof(struct ieee802154_beaconnotify_ind_s) \
|
||||
- IEEE802154_MAX_BEACON_PAYLOAD_LENGTH + (n))
|
||||
- IEEE802154_MAX_BEACON_PAYLOAD_LEN + (n))
|
||||
|
||||
/*****************************************************************************
|
||||
* Primitive: MLME-COMM-STATUS.indication
|
||||
|
|
|
@ -187,7 +187,7 @@ struct ieee802154_privmac_s
|
|||
|
||||
/* Contents of beacon payload */
|
||||
|
||||
uint8_t beacon_payload[IEEE802154_MAX_BEACON_PAYLOAD_LENGTH];
|
||||
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
|
||||
|
@ -219,8 +219,8 @@ struct ieee802154_privmac_s
|
|||
|
||||
uint32_t batt_life_ext : 1; /* Is BLE enabled */
|
||||
uint32_t gts_permit : 1; /* Is PAN Coord. accepting GTS reqs. */
|
||||
uint32_t promiscuous_mode : 1; /* Is promiscuous mode on? */
|
||||
uint32_t ranging_supported : 1; /* Does MAC sublayer support ranging */
|
||||
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 sec_enabled : 1; /* Does MAC sublayer have security en. */
|
||||
|
||||
|
@ -415,7 +415,60 @@ static FAR struct mac802154_trans_s *
|
|||
|
||||
static int mac802154_defaultmib(FAR struct ieee802154_privmac_s *priv)
|
||||
{
|
||||
/* TODO: Set all MAC fields to default values */
|
||||
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->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 */
|
||||
#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->sec_enabled = false; /* Security disabled by default */
|
||||
priv->tx_total_dur = 0; /* 0 transmit duration */
|
||||
|
||||
priv->trans_persist_time = 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, 8);
|
||||
|
||||
/* Reset the device's address */
|
||||
|
||||
priv->addr.mode = IEEE802154_ADDRMODE_NONE;
|
||||
priv->addr.panid = IEEE802154_PAN_UNSPEC;
|
||||
priv->addr.saddr = IEEE802154_SADDR_UNSPEC;
|
||||
memcpy(&priv->addr.eaddr[0], IEEE802154_EADDR_UNSPEC, 8);
|
||||
|
||||
|
||||
/* These attributes are effected and determined based on the PHY. Need to
|
||||
* figure out how to "share" attributes between the radio driver and this
|
||||
* MAC layer
|
||||
*
|
||||
* macAckWaitDuration
|
||||
* macBattLifeExtPeriods
|
||||
* macMaxFrameTotalWaitTime
|
||||
* macLIFSPeriod
|
||||
* macSIFSPeriod
|
||||
* macSyncSymbolOffset
|
||||
* macTimestampSupported
|
||||
* macTxControlActiveDuration
|
||||
* macTxControlPauseDuration
|
||||
*/
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -807,6 +860,9 @@ int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg)
|
|||
(FAR struct ieee802154_privmac_s *)mac;
|
||||
int ret = -EINVAL;
|
||||
|
||||
FAR union ieee802154_macarg_u *macarg =
|
||||
(FAR union ieee802154_macarg_u *)((uintptr_t)arg);
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
/* Check for IOCTLs aimed at the IEEE802.15.4 MAC layer */
|
||||
|
@ -814,7 +870,75 @@ int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg)
|
|||
if (_MAC802154IOCVALID(cmd))
|
||||
{
|
||||
/* Handle the MAC IOCTL command */
|
||||
#warning Missing logic
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case MAC802154IOC_MLME_ASSOC_REQUEST:
|
||||
{
|
||||
mac802154_req_associate(mac, &macarg->assocreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_ASSOC_RESPONSE:
|
||||
{
|
||||
mac802154_resp_associate(mac, &macarg->assocresp);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_DISASSOC_REQUEST:
|
||||
{
|
||||
mac802154_req_disassociate(mac, &macarg->disassocreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_GET_REQUEST:
|
||||
{
|
||||
mac802154_req_get(mac, &macarg->getreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_GTS_REQUEST:
|
||||
{
|
||||
mac802154_req_gts(mac, &macarg->gtsreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_ORPHAN_RESPONSE:
|
||||
{
|
||||
mac802154_resp_orphan(mac, &macarg->orphanresp);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_RESET_REQUEST:
|
||||
{
|
||||
mac802154_req_reset(mac, &macarg->resetreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_RXENABLE_REQUEST:
|
||||
{
|
||||
mac802154_req_rxenable(mac, &macarg->rxenabreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_SCAN_REQUEST:
|
||||
{
|
||||
mac802154_req_scan(mac, &macarg->scanreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_SET_REQUEST:
|
||||
{
|
||||
mac802154_req_set(mac, &macarg->setreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_START_REQUEST:
|
||||
{
|
||||
mac802154_req_start(mac, &macarg->startreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_SYNC_REQUEST:
|
||||
{
|
||||
mac802154_req_sync(mac, &macarg->syncreq);
|
||||
}
|
||||
break;
|
||||
case MAC802154IOC_MLME_POLL_REQUEST:
|
||||
{
|
||||
mac802154_req_poll(mac, &macarg->pollreq);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* No, other IOCTLs must be aimed at the IEEE802.15.4 radio layer */
|
||||
|
@ -1392,7 +1516,7 @@ int mac802154_req_poll(MACHANDLE mac, FAR struct ieee802154_poll_req_s *req)
|
|||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_rsp_associate
|
||||
* Name: mac802154_resp_associate
|
||||
*
|
||||
* Description:
|
||||
* The MLME-ASSOCIATE.response primitive is used to initiate a response to
|
||||
|
@ -1400,7 +1524,7 @@ int mac802154_req_poll(MACHANDLE mac, FAR struct ieee802154_poll_req_s *req)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mac802154_rsp_associate(MACHANDLE mac,
|
||||
int mac802154_resp_associate(MACHANDLE mac,
|
||||
FAR struct ieee802154_assoc_resp_s *resp)
|
||||
{
|
||||
FAR struct ieee802154_privmac_s *priv =
|
||||
|
@ -1409,7 +1533,7 @@ int mac802154_rsp_associate(MACHANDLE mac,
|
|||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_rsp_orphan
|
||||
* Name: mac802154_resp_orphan
|
||||
*
|
||||
* Description:
|
||||
* The MLME-ORPHAN.response primitive allows the next higher layer of a
|
||||
|
@ -1417,7 +1541,7 @@ int mac802154_rsp_associate(MACHANDLE mac,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mac802154_rsp_orphan(MACHANDLE mac,
|
||||
int mac802154_resp_orphan(MACHANDLE mac,
|
||||
FAR struct ieee802154_orphan_resp_s *resp)
|
||||
{
|
||||
FAR struct ieee802154_privmac_s *priv =
|
||||
|
|
|
@ -282,7 +282,7 @@ int mac802154_req_sync(MACHANDLE mac, FAR struct ieee802154_sync_req_s *req);
|
|||
int mac802154_req_poll(MACHANDLE mac, FAR struct ieee802154_poll_req_s *req);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_rsp_associate
|
||||
* Name: mac802154_resp_associate
|
||||
*
|
||||
* Description:
|
||||
* The MLME-ASSOCIATE.response primitive is used to initiate a response to
|
||||
|
@ -290,11 +290,11 @@ int mac802154_req_poll(MACHANDLE mac, FAR struct ieee802154_poll_req_s *req);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mac802154_rsp_associate(MACHANDLE mac,
|
||||
int mac802154_resp_associate(MACHANDLE mac,
|
||||
FAR struct ieee802154_assoc_resp_s *resp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_rsp_orphan
|
||||
* Name: mac802154_resp_orphan
|
||||
*
|
||||
* Description:
|
||||
* The MLME-ORPHAN.response primitive allows the next higher layer of a
|
||||
|
@ -302,7 +302,7 @@ int mac802154_rsp_associate(MACHANDLE mac,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mac802154_rsp_orphan(MACHANDLE mac,
|
||||
int mac802154_resp_orphan(MACHANDLE mac,
|
||||
FAR struct ieee802154_orphan_resp_s *resp);
|
||||
|
||||
#undef EXTERN
|
||||
|
|
|
@ -602,17 +602,13 @@ static int mac802154dev_ioctl(FAR struct file *filep, int cmd,
|
|||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MAC802154IOC_MLME_ASSOC_REQUEST:
|
||||
{
|
||||
FAR struct ieee802154_assoc_req_s *req =
|
||||
(FAR struct ieee802154_assoc_req_s *)((uintptr_t)arg);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
wlerr("ERROR: Unrecognized command %ld\n", cmd);
|
||||
ret = -EINVAL;
|
||||
{
|
||||
/* Forward any unrecognized commands to the MAC layer */
|
||||
|
||||
mac802154_ioctl(dev->md_mac, cmd, arg);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue