mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
ieee802154: Finishes transmission of beacon frames, and performing a passive scan
This commit is contained in:
@@ -73,6 +73,16 @@ config MAC802154_NNOTIF
|
||||
receiver with an allocated notification structure indicating the event. The
|
||||
events are primitives such as Association Indication etc.
|
||||
|
||||
config MAC802154_NPANDESC
|
||||
int "Number of PAN descriptors"
|
||||
default 5
|
||||
---help---
|
||||
Configured number of PAN descriptors Default: 5
|
||||
|
||||
When performing a scan to find a suitable PAN, the MAC must store
|
||||
information for all unique beacons received. This is the number of unique
|
||||
descriptors that can be held before the scan cancels with LIMIT_REACHED.
|
||||
|
||||
config IEEE802154_IND_PREALLOC
|
||||
int "Number of pre-allocated meta-data structures"
|
||||
default 20
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
This will eventually hold some general documentation for the IEEE 802.15.4
|
||||
MAC implementation.
|
||||
|
||||
NOTE: Throughout the code, excerpts from the standard are quoted as to make
|
||||
the code thoroughly readable. I have tried, to always put a reference [1] and
|
||||
page number. Below is the references that correspond with the reference number
|
||||
|
||||
[1]
|
||||
+220
-30
@@ -59,6 +59,7 @@
|
||||
#include "mac802154_notif.h"
|
||||
#include "mac802154_internal.h"
|
||||
#include "mac802154_assoc.h"
|
||||
#include "mac802154_scan.h"
|
||||
#include "mac802154_data.h"
|
||||
#include "mac802154_poll.h"
|
||||
|
||||
@@ -98,10 +99,12 @@ static void mac802154_timeout_expiry(int argc, wdparm_t arg, ...);
|
||||
static uint32_t mac802154_symtoticks(FAR struct ieee802154_privmac_s *priv,
|
||||
uint32_t symbols);
|
||||
|
||||
static void mac802154_rx_datareq(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind);
|
||||
static void mac802154_rx_dataframe(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind);
|
||||
static void mac802154_rxdatareq(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind);
|
||||
static void mac802154_rxdataframe(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind);
|
||||
static void mac802154_rxbeaconframe(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -438,20 +441,20 @@ void mac802154_updatebeacon(FAR struct ieee802154_privmac_s *priv)
|
||||
beacon->bf_data[beacon->bf_len + 1] = 0;
|
||||
|
||||
IEEE802154_SETBEACONORDER(beacon->bf_data, beacon->bf_len,
|
||||
priv->sf_spec.beaconorder);
|
||||
priv->sfspec.beaconorder);
|
||||
IEEE802154_SETSFORDER(beacon->bf_data, beacon->bf_len,
|
||||
priv->sf_spec.sforder);
|
||||
priv->sfspec.sforder);
|
||||
IEEE802154_SETFINCAPSLOT(beacon->bf_data, beacon->bf_len,
|
||||
priv->sf_spec.final_capslot);
|
||||
if (priv->sf_spec.ble)
|
||||
priv->sfspec.final_capslot);
|
||||
if (priv->sfspec.ble)
|
||||
{
|
||||
IEEE802154_SETBLE(beacon->bf_data, beacon->bf_len);
|
||||
}
|
||||
if (priv->sf_spec.pancoord)
|
||||
if (priv->sfspec.pancoord)
|
||||
{
|
||||
IEEE802154_SETPANCOORD(beacon->bf_data, beacon->bf_len);
|
||||
}
|
||||
if (priv->sf_spec.assocpermit)
|
||||
if (priv->sfspec.assocpermit)
|
||||
{
|
||||
IEEE802154_SETASSOCPERMIT(beacon->bf_data, beacon->bf_len);
|
||||
}
|
||||
@@ -546,10 +549,10 @@ void mac802154_setupindirect(FAR struct ieee802154_privmac_s *priv,
|
||||
* aBaseSuperframeDuration. [1] pg. 129
|
||||
*/
|
||||
|
||||
if (priv->sf_spec.beaconorder < 15)
|
||||
if (priv->sfspec.beaconorder < 15)
|
||||
{
|
||||
symbols = priv->trans_persisttime *
|
||||
(IEEE802154_BASE_SUPERFRAME_DURATION * (1 << priv->sf_spec.beaconorder));
|
||||
(IEEE802154_BASE_SUPERFRAME_DURATION * (1 << priv->sfspec.beaconorder));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -562,7 +565,7 @@ void mac802154_setupindirect(FAR struct ieee802154_privmac_s *priv,
|
||||
|
||||
/* Make sure the beacon gets updated */
|
||||
|
||||
if (priv->sf_spec.beaconorder < 15)
|
||||
if (priv->sfspec.beaconorder < 15)
|
||||
{
|
||||
priv->beaconupdate = true;
|
||||
}
|
||||
@@ -1056,7 +1059,7 @@ static void mac802154_rxframe_worker(FAR void *arg)
|
||||
{
|
||||
case IEEE802154_FRAME_DATA:
|
||||
{
|
||||
mac802154_rx_dataframe(priv, ind);
|
||||
mac802154_rxdataframe(priv, ind);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1072,33 +1075,43 @@ static void mac802154_rxframe_worker(FAR void *arg)
|
||||
switch (cmdtype)
|
||||
{
|
||||
case IEEE802154_CMD_ASSOC_REQ:
|
||||
wlinfo("Assoc request received\n");
|
||||
mac802154_rx_assocreq(priv, ind);
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_ASSOC_RESP:
|
||||
wlinfo("Assoc response received\n");
|
||||
mac802154_rx_assocresp(priv, ind);
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_DISASSOC_NOT:
|
||||
wlinfo("Disassoc notif received\n");
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_DATA_REQ:
|
||||
mac802154_rx_datareq(priv, ind);
|
||||
wlinfo("Data request received\n");
|
||||
mac802154_rxdatareq(priv, ind);
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_PANID_CONF_NOT:
|
||||
wlinfo("PAN ID Conflict notif received\n");
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_ORPHAN_NOT:
|
||||
wlinfo("Orphan notif received\n");
|
||||
break;
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_BEACON_REQ:
|
||||
wlinfo("Beacon request received\n");
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_COORD_REALIGN:
|
||||
wlinfo("Coord realign received\n");
|
||||
break;
|
||||
|
||||
case IEEE802154_CMD_GTS_REQ:
|
||||
wlinfo("GTS request received\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1110,15 +1123,9 @@ static void mac802154_rxframe_worker(FAR void *arg)
|
||||
|
||||
case IEEE802154_FRAME_BEACON:
|
||||
{
|
||||
/* TODO: Add logic here to handle extracting association response from
|
||||
* coordinator if beacon tracking was enabled during the Association
|
||||
* operation.
|
||||
*
|
||||
* mac802154_txdesc_alloc(priv, &respdec, false);
|
||||
* mac802154_createdatareq(priv, &req->coordaddr,
|
||||
* IEEE802154_ADDRMODE_EXTENDED, respdesc);
|
||||
* sq_addlast((FAR sq_entry_t *)respdesc, &priv->csma_queue);
|
||||
*/
|
||||
wlinfo("Beacon frame received\n");
|
||||
mac802154_rxbeaconframe(priv, ind);
|
||||
ieee802154_ind_free(ind);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1137,7 +1144,7 @@ static void mac802154_rxframe_worker(FAR void *arg)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_rx_dataframe
|
||||
* Name: mac802154_rxdataframe
|
||||
*
|
||||
* Description:
|
||||
* Function called from the generic RX Frame worker to parse and handle the
|
||||
@@ -1145,8 +1152,8 @@ static void mac802154_rxframe_worker(FAR void *arg)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_rx_dataframe(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind)
|
||||
static void mac802154_rxdataframe(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind)
|
||||
{
|
||||
FAR struct ieee802154_notif_s *notif;
|
||||
|
||||
@@ -1326,7 +1333,7 @@ notify_without_lock:
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_rx_datareq
|
||||
* Name: mac802154_rxdatareq
|
||||
*
|
||||
* Description:
|
||||
* Function called from the generic RX Frame worker to parse and handle the
|
||||
@@ -1334,7 +1341,7 @@ notify_without_lock:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_rx_datareq(FAR struct ieee802154_privmac_s *priv,
|
||||
static void mac802154_rxdatareq(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind)
|
||||
{
|
||||
FAR struct ieee802154_txdesc_s *txdesc;
|
||||
@@ -1529,6 +1536,189 @@ static void mac802154_sfevent(FAR const struct ieee802154_radiocb_s *radiocb,
|
||||
mac802154_givesem(&priv->exclsem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_rxbeaconframe
|
||||
*
|
||||
* Description:
|
||||
* Function called from the generic RX Frame worker to parse and handle the
|
||||
* reception of a beacon frame.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_rxbeaconframe(FAR struct ieee802154_privmac_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind)
|
||||
{
|
||||
FAR struct iob_s *iob = ind->frame;
|
||||
struct ieee802154_pandesc_s pandesc;
|
||||
FAR struct ieee802154_txdesc_s *respdesc;
|
||||
uint8_t numgtsdesc;
|
||||
uint8_t gtsdirmask;
|
||||
uint8_t npendsaddr;
|
||||
uint8_t npendeaddr;
|
||||
int i;
|
||||
|
||||
/* Copy the coordinator address and channel info into the pan descriptor */
|
||||
|
||||
memcpy(&pandesc.coordaddr, &ind->src, sizeof(struct ieee802154_addr_s));
|
||||
pandesc.chan = priv->currscan.channels[priv->scanindex];
|
||||
pandesc.chpage = priv->currscan.chpage;
|
||||
pandesc.lqi = ind->lqi;
|
||||
pandesc.timestamp = ind->timestamp;
|
||||
|
||||
/* Parse the superframe specification field */
|
||||
|
||||
pandesc.sfspec.beaconorder = IEEE802154_GETBEACONORDER(iob->io_data,
|
||||
iob->io_offset);
|
||||
|
||||
pandesc.sfspec.sforder = IEEE802154_GETSFORDER(iob->io_data, iob->io_offset);
|
||||
pandesc.sfspec.final_capslot = IEEE802154_GETFINCAPSLOT(iob->io_data,
|
||||
iob->io_offset);
|
||||
pandesc.sfspec.ble = IEEE802154_GETBLE(iob->io_data, iob->io_offset);
|
||||
pandesc.sfspec.pancoord = IEEE802154_GETPANCOORD(iob->io_data, iob->io_offset);
|
||||
pandesc.sfspec.assocpermit = IEEE802154_GETASSOCPERMIT(iob->io_data,
|
||||
iob->io_offset);
|
||||
iob->io_offset += 2;
|
||||
|
||||
/* Parse the GTS Specification field */
|
||||
|
||||
numgtsdesc = IEEE802154_GETGTSDESCCOUNT(iob->io_data, iob->io_offset);
|
||||
pandesc.gtspermit = IEEE802154_GETGTSPERMIT(iob->io_data, iob->io_offset);
|
||||
iob->io_offset++;
|
||||
|
||||
/* We only need to parse the rest of the frame if we are not performing a
|
||||
* scan
|
||||
*/
|
||||
|
||||
if (priv->curr_op == MAC802154_OP_SCAN)
|
||||
{
|
||||
/* Check to see if we already have a frame from this coordinator */
|
||||
|
||||
for (i = 0; i < priv->npandesc; i++)
|
||||
{
|
||||
if (priv->currscan.channels[priv->scanindex] != priv->pandescs[i].chan)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (memcmp(&ind->src, &priv->pandescs[i].coordaddr,
|
||||
sizeof(struct ieee802154_addr_s)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The beacon is the same as another, so discard it */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Copy the pan desc to the list of pan desc */
|
||||
|
||||
memcpy(&priv->pandescs[priv->npandesc], &pandesc,
|
||||
sizeof(struct ieee802154_pandesc_s));
|
||||
priv->npandesc++;
|
||||
|
||||
if (priv->npandesc == MAC802154_NPANDESC)
|
||||
{
|
||||
mac802154_scanfinish(priv, IEEE802154_STATUS_LIMITREACHED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If there are any GTS descriptors, handle the GTS Directions and
|
||||
* GTS List fields
|
||||
*/
|
||||
|
||||
if (numgtsdesc > 0)
|
||||
{
|
||||
gtsdirmask = IEEE802154_GETGTSDIRMASK(iob->io_data, iob->io_offset);
|
||||
iob->io_offset++;
|
||||
|
||||
for (i = 0; i < numgtsdesc; i++)
|
||||
{
|
||||
/* For now we just discard the data by skipping over it */
|
||||
|
||||
iob->io_offset += 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pending address fields. Min 1 byte, the Pending Address Specification */
|
||||
|
||||
npendsaddr = IEEE802154_GETNPENDSADDR(iob->io_data, iob->io_offset);
|
||||
npendeaddr = IEEE802154_GETNPENDEADDR(iob->io_data, iob->io_offset);
|
||||
iob->io_offset++;
|
||||
|
||||
/* The pending address field tells us whether or not there is any data
|
||||
* pending for us.
|
||||
*/
|
||||
|
||||
for (i = 0; i < npendsaddr; i++)
|
||||
{
|
||||
/* If the short address matches our short address */
|
||||
|
||||
if (IEEE802154_SADDRCMP(&iob->io_data[iob->io_offset], priv->addr.saddr))
|
||||
{
|
||||
/* TODO: Handle data pending in coordinator for us */
|
||||
}
|
||||
iob->io_offset += IEEE802154_SADDRSIZE;
|
||||
}
|
||||
|
||||
for (i = 0; i < npendeaddr; i++)
|
||||
{
|
||||
/* If the extended address matches our extended address */
|
||||
|
||||
if (IEEE802154_EADDRCMP(&iob->io_data[iob->io_offset], priv->addr.eaddr))
|
||||
{
|
||||
/* If we are associating, polling, or if macAutoRequest is TRUE,
|
||||
* extract the data.
|
||||
*/
|
||||
|
||||
if ((priv->autoreq) || (priv->curr_op == MAC802154_OP_ASSOC) ||
|
||||
(priv->curr_op == MAC802154_OP_POLL))
|
||||
{
|
||||
mac802154_txdesc_alloc(priv, &respdesc, false);
|
||||
|
||||
mac802154_createdatareq(priv, &priv->pandesc.coordaddr,
|
||||
IEEE802154_ADDRMODE_EXTENDED, respdesc);
|
||||
|
||||
if (priv->curr_op == MAC802154_OP_ASSOC ||
|
||||
priv->curr_op == MAC802154_OP_POLL)
|
||||
{
|
||||
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
|
||||
}
|
||||
|
||||
/* Link the transaction into the CSMA transaction list */
|
||||
|
||||
sq_addlast((FAR sq_entry_t *)respdesc, &priv->csma_queue);
|
||||
|
||||
/* Notify the radio driver that there is data available */
|
||||
|
||||
priv->radio->txnotify(priv->radio, false);
|
||||
}
|
||||
}
|
||||
iob->io_offset += IEEE802154_EADDRSIZE;
|
||||
}
|
||||
|
||||
/* TODO: Process incoming beacon payload
|
||||
* If there is anything left in the frame, process it as the beacon payload
|
||||
*/
|
||||
|
||||
/* Check the superframe structure and update the appropriate attributes. */
|
||||
|
||||
if (memcmp(&priv->sfspec, &pandesc.sfspec,
|
||||
sizeof(struct ieee802154_superframespec_s)) != 0)
|
||||
{
|
||||
/* Copy in the new superframe spec */
|
||||
|
||||
memcpy(&priv->sfspec, &pandesc.sfspec,
|
||||
sizeof(struct ieee802154_superframespec_s));
|
||||
|
||||
/* Tell the radio layer about the superframe spec update */
|
||||
|
||||
priv->radio->sfupdate(priv->radio, &pandesc.sfspec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_symtoticks
|
||||
*
|
||||
@@ -1737,7 +1927,7 @@ MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev)
|
||||
}
|
||||
|
||||
IEEE802154_EADDRCOPY(mac->addr.eaddr, eaddr);
|
||||
mac->radio->set_attr(mac->radio, IEEE802154_ATTR_MAC_EXTENDED_ADDR,
|
||||
mac->radio->set_attr(mac->radio, IEEE802154_ATTR_MAC_EADDR,
|
||||
(union ieee802154_attr_u *)&eaddr[0]);
|
||||
|
||||
return (MACHANDLE)mac;
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_timeout_assoc(FAR struct ieee802154_privmac_s *priv);
|
||||
static void mac802154_assoctimeout(FAR struct ieee802154_privmac_s *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Public MAC Functions
|
||||
@@ -120,22 +120,18 @@ int mac802154_req_associate(MACHANDLE mac,
|
||||
|
||||
/* Set the channel and channel page of the PHY layer */
|
||||
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_PHY_CURRENT_CHANNEL,
|
||||
(FAR const union ieee802154_attr_u *)&req->chnum);
|
||||
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_PHY_CURRENT_PAGE,
|
||||
(FAR const union ieee802154_attr_u *)&req->chpage);
|
||||
mac802154_setchannel(priv, req->chan);
|
||||
mac802154_setchpage(priv, req->chpage);
|
||||
|
||||
/* Set the coordinator address attributes */
|
||||
|
||||
memcpy(&priv->coordaddr, &req->coordaddr, sizeof(struct ieee802154_addr_s));
|
||||
mac802154_setcoordaddr(priv, &req->coordaddr);
|
||||
|
||||
/* TODO: Need to send coordinator address to radio layer */
|
||||
|
||||
/* Copy the coordinator PAN ID to our PAN ID */
|
||||
|
||||
IEEE802154_PANIDCOPY(priv->addr.panid, req->coordaddr.panid);
|
||||
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_PANID,
|
||||
(FAR const union ieee802154_attr_u *)req->coordaddr.panid);
|
||||
mac802154_setpanid(priv, req->coordaddr.panid);
|
||||
|
||||
/* Copy in the capabilities information bitfield */
|
||||
|
||||
@@ -181,7 +177,7 @@ int mac802154_req_associate(MACHANDLE mac,
|
||||
|
||||
IEEE802154_SETACKREQ(iob->io_data, 0);
|
||||
IEEE802154_SETFTYPE(iob->io_data, 0, IEEE802154_FRAME_COMMAND);
|
||||
IEEE802154_SETDADDRMODE(iob->io_data, 0, priv->coordaddr.mode);
|
||||
IEEE802154_SETDADDRMODE(iob->io_data, 0, priv->pandesc.coordaddr.mode);
|
||||
IEEE802154_SETSADDRMODE(iob->io_data, 0, IEEE802154_ADDRMODE_EXTENDED);
|
||||
|
||||
iob->io_len = 2;
|
||||
@@ -197,20 +193,20 @@ int mac802154_req_associate(MACHANDLE mac,
|
||||
* PAN to which to associate. [1] pg. 68
|
||||
*/
|
||||
|
||||
mac802154_putpanid(iob, priv->coordaddr.panid);
|
||||
mac802154_putpanid(iob, priv->pandesc.coordaddr.panid);
|
||||
|
||||
/* The Destination Address field shall contain the address from the beacon
|
||||
* frame that was transmitted by the coordinator to which the association
|
||||
* request command is being sent. [1] pg. 68
|
||||
*/
|
||||
|
||||
if (priv->coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
|
||||
if (priv->pandesc.coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
|
||||
{
|
||||
mac802154_putsaddr(iob, priv->coordaddr.saddr);
|
||||
mac802154_putsaddr(iob, priv->pandesc.coordaddr.saddr);
|
||||
}
|
||||
else if (priv->coordaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||
else if (priv->pandesc.coordaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||
{
|
||||
mac802154_puteaddr(iob, priv->coordaddr.eaddr);
|
||||
mac802154_puteaddr(iob, priv->pandesc.coordaddr.eaddr);
|
||||
}
|
||||
|
||||
/* The Source PAN Identifier field shall contain the broadcast PAN identifier.*/
|
||||
@@ -258,7 +254,7 @@ int mac802154_req_associate(MACHANDLE mac,
|
||||
|
||||
mac802154_givesem(&priv->exclsem);
|
||||
|
||||
/* Association Request commands get sent out immediately */
|
||||
/* Association Request command gets sent out immediately */
|
||||
|
||||
priv->radio->txdelayed(priv->radio, txdesc, 0);
|
||||
|
||||
@@ -464,7 +460,7 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
|
||||
* the coordinator after macResponseWaitTime. [1] pg. 34
|
||||
*/
|
||||
|
||||
if (priv->trackingbeacon)
|
||||
if (priv->sfspec.beaconorder < 15)
|
||||
{
|
||||
/* We are tracking the beacon, so we should see our address in the
|
||||
* beacon frame within macResponseWaitTime if the coordinator is going
|
||||
@@ -475,7 +471,7 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
|
||||
|
||||
mac802154_timerstart(priv, (priv->resp_waittime *
|
||||
IEEE802154_BASE_SUPERFRAME_DURATION),
|
||||
mac802154_timeout_assoc);
|
||||
mac802154_assoctimeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -484,7 +480,7 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
|
||||
* extended
|
||||
*/
|
||||
|
||||
DEBUGASSERT(priv->coordaddr.mode != IEEE802154_ADDRMODE_NONE);
|
||||
DEBUGASSERT(priv->pandesc.coordaddr.mode != IEEE802154_ADDRMODE_NONE);
|
||||
|
||||
/* Send the Data Request MAC command after macResponseWaitTime to
|
||||
* extract the data from the coordinator.
|
||||
@@ -492,7 +488,7 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
|
||||
|
||||
mac802154_txdesc_alloc(priv, &respdesc, false);
|
||||
|
||||
mac802154_createdatareq(priv, &priv->coordaddr,
|
||||
mac802154_createdatareq(priv, &priv->pandesc.coordaddr,
|
||||
IEEE802154_ADDRMODE_EXTENDED, respdesc);
|
||||
|
||||
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
|
||||
@@ -589,7 +585,7 @@ void mac802154_txdone_datareq_assoc(FAR struct ieee802154_privmac_s *priv,
|
||||
* the corresponding data frame from the coordinator. [1] pg.43
|
||||
*/
|
||||
|
||||
priv->radio->rxenable(priv->radio, true);
|
||||
mac802154_rxenable(priv);
|
||||
|
||||
/* Start a timer, if we receive the data frame, we will cancel
|
||||
* the timer, otherwise it will expire and we will notify the
|
||||
@@ -597,7 +593,7 @@ void mac802154_txdone_datareq_assoc(FAR struct ieee802154_privmac_s *priv,
|
||||
*/
|
||||
|
||||
mac802154_timerstart(priv, priv->max_frame_waittime,
|
||||
mac802154_timeout_assoc);
|
||||
mac802154_assoctimeout);
|
||||
|
||||
/* We can deallocate the data conf notification as it is no longer
|
||||
* needed. We can't use the public function here since we already
|
||||
@@ -724,7 +720,7 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
|
||||
|
||||
/* Inform the radio of the address change */
|
||||
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_SHORT_ADDRESS,
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_SADDR,
|
||||
(FAR union ieee802154_attr_u *)priv->addr.saddr);
|
||||
|
||||
/* A Short Address field value equal to 0xfffe shall indicate that the device
|
||||
@@ -775,7 +771,7 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_timeout_assoc
|
||||
* Name: mac802154_assoctimeout
|
||||
*
|
||||
* Description:
|
||||
* Function registered with MAC timer that gets called via the work queue to
|
||||
@@ -783,7 +779,7 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_timeout_assoc(FAR struct ieee802154_privmac_s *priv)
|
||||
static void mac802154_assoctimeout(FAR struct ieee802154_privmac_s *priv)
|
||||
{
|
||||
FAR struct ieee802154_notif_s *notif;
|
||||
|
||||
@@ -805,7 +801,7 @@ static void mac802154_timeout_assoc(FAR struct ieee802154_privmac_s *priv)
|
||||
|
||||
/* We are no longer performing the association operation */
|
||||
priv->curr_op = MAC802154_OP_NONE;
|
||||
priv->cmd_desc = NULL;
|
||||
priv->cmd_desc = NULL;
|
||||
mac802154_givesem(&priv->opsem);
|
||||
|
||||
/* Release the MAC */
|
||||
|
||||
@@ -86,10 +86,10 @@ int mac802154_req_get(MACHANDLE mac, enum ieee802154_attr_e attr,
|
||||
case IEEE802154_ATTR_MAC_PANID:
|
||||
IEEE802154_PANIDCOPY(attrval->mac.panid, priv->addr.panid);
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
|
||||
case IEEE802154_ATTR_MAC_SADDR:
|
||||
IEEE802154_SADDRCOPY(attrval->mac.saddr, priv->addr.saddr);
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_EXTENDED_ADDR:
|
||||
case IEEE802154_ATTR_MAC_EADDR:
|
||||
IEEE802154_EADDRCOPY(attrval->mac.eaddr, priv->addr.eaddr);
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_DEVMODE:
|
||||
@@ -100,7 +100,7 @@ int mac802154_req_get(MACHANDLE mac, enum ieee802154_attr_e attr,
|
||||
* it along.
|
||||
*/
|
||||
|
||||
ret = priv->radio->set_attr(priv->radio, attr, attrval);
|
||||
ret = priv->radio->get_attr(priv->radio, attr, attrval);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -133,42 +133,37 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_attr_e attr,
|
||||
{
|
||||
case IEEE802154_ATTR_MAC_PANID:
|
||||
{
|
||||
IEEE802154_PANIDCOPY(priv->addr.panid, attrval->mac.panid);
|
||||
|
||||
/* Tell the radio about the attribute */
|
||||
|
||||
priv->radio->set_attr(priv->radio, attr, attrval);
|
||||
|
||||
mac802154_setpanid(priv, attrval->mac.panid);
|
||||
ret = IEEE802154_STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
|
||||
case IEEE802154_ATTR_MAC_SADDR:
|
||||
{
|
||||
IEEE802154_SADDRCOPY(priv->addr.saddr, attrval->mac.saddr);
|
||||
|
||||
/* Tell the radio about the attribute */
|
||||
|
||||
priv->radio->set_attr(priv->radio, attr, attrval);
|
||||
|
||||
mac802154_setsaddr(priv, attrval->mac.saddr);
|
||||
ret = IEEE802154_STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_EXTENDED_ADDR:
|
||||
case IEEE802154_ATTR_MAC_EADDR:
|
||||
{
|
||||
/* Set the MAC copy of the address in the table */
|
||||
|
||||
IEEE802154_EADDRCOPY(priv->addr.eaddr, attrval->mac.eaddr);
|
||||
|
||||
/* Tell the radio about the attribute */
|
||||
|
||||
priv->radio->set_attr(priv->radio, attr, attrval);
|
||||
|
||||
mac802154_seteaddr(priv, attrval->mac.eaddr);
|
||||
ret = IEEE802154_STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_COORD_SADDR:
|
||||
{
|
||||
mac802154_setcoordsaddr(priv, attrval->mac.coordsaddr);
|
||||
ret = IEEE802154_STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_COORD_EADDR:
|
||||
{
|
||||
mac802154_setcoordeaddr(priv, attrval->mac.coordeaddr);
|
||||
ret = IEEE802154_STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
case IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT:
|
||||
{
|
||||
priv->sf_spec.assocpermit = attrval->mac.assocpermit;
|
||||
priv->sfspec.assocpermit = attrval->mac.assocpermit;
|
||||
priv->beaconupdate = true;
|
||||
ret = IEEE802154_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -735,14 +735,14 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
IEEE802154_PANIDCOPY(g_panid, setreq->attrval.mac.panid);
|
||||
break;
|
||||
|
||||
case IEEE802154_ATTR_MAC_EXTENDED_ADDR:
|
||||
case IEEE802154_ATTR_MAC_EADDR:
|
||||
IEEE802154_EADDRCOPY(g_eaddr, setreq->attrval.mac.eaddr);
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
lo_addr2ip(dev);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
|
||||
case IEEE802154_ATTR_MAC_SADDR:
|
||||
IEEE802154_SADDRCOPY(g_saddr, setreq->attrval.mac.saddr);
|
||||
#ifndef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
lo_addr2ip(dev);
|
||||
@@ -765,11 +765,11 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
IEEE802154_PANIDCOPY(getreq->attrval.mac.panid, g_panid);
|
||||
break;
|
||||
|
||||
case IEEE802154_ATTR_MAC_EXTENDED_ADDR:
|
||||
case IEEE802154_ATTR_MAC_EADDR:
|
||||
IEEE802154_EADDRCOPY(getreq->attrval.mac.eaddr, g_eaddr);
|
||||
break;
|
||||
|
||||
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
|
||||
case IEEE802154_ATTR_MAC_SADDR:
|
||||
IEEE802154_SADDRCOPY(getreq->attrval.mac.saddr, g_saddr);
|
||||
break;
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
/* Get the eaddr from the MAC */
|
||||
|
||||
memcpy(arg.ifr_name, dev->d_ifname, IFNAMSIZ);
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_EADDR;
|
||||
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
@@ -283,7 +283,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
/* Get the saddr from the MAC */
|
||||
|
||||
memcpy(arg.ifr_name, dev->d_ifname, IFNAMSIZ);
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
arg.u.getreq.attr = IEEE802154_ATTR_MAC_SADDR;
|
||||
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_timeout_poll(FAR struct ieee802154_privmac_s *priv);
|
||||
static void mac802154_polltimeout(FAR struct ieee802154_privmac_s *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Public MAC Functions
|
||||
@@ -235,7 +235,7 @@ void mac802154_txdone_datareq_poll(FAR struct ieee802154_privmac_s *priv,
|
||||
* the corresponding data frame from the coordinator. [1] pg.43
|
||||
*/
|
||||
|
||||
priv->radio->rxenable(priv->radio, true);
|
||||
mac802154_rxenable(priv);
|
||||
|
||||
/* Start a timer, if we receive the data frame, we will cancel
|
||||
* the timer, otherwise it will expire and we will notify the
|
||||
@@ -243,7 +243,7 @@ void mac802154_txdone_datareq_poll(FAR struct ieee802154_privmac_s *priv,
|
||||
*/
|
||||
|
||||
mac802154_timerstart(priv, priv->max_frame_waittime,
|
||||
mac802154_timeout_poll);
|
||||
mac802154_polltimeout);
|
||||
|
||||
/* We can deallocate the data conf notification as it is no longer
|
||||
* needed. We can't use the public function here since we already
|
||||
@@ -256,7 +256,7 @@ void mac802154_txdone_datareq_poll(FAR struct ieee802154_privmac_s *priv,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_timeout_poll
|
||||
* Name: mac802154_polltimeout
|
||||
*
|
||||
* Description:
|
||||
* Function registered with MAC timer that gets called via the work queue to
|
||||
@@ -264,7 +264,7 @@ void mac802154_txdone_datareq_poll(FAR struct ieee802154_privmac_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mac802154_timeout_poll(FAR struct ieee802154_privmac_s *priv)
|
||||
void mac802154_polltimeout(FAR struct ieee802154_privmac_s *priv)
|
||||
{
|
||||
FAR struct ieee802154_notif_s *notif;
|
||||
|
||||
|
||||
@@ -88,12 +88,12 @@ int mac802154_req_reset(MACHANDLE mac, bool rst_pibattr)
|
||||
{
|
||||
priv->isassoc = false; /* Not associated with a PAN */
|
||||
priv->trackingbeacon = false; /* Not tracking beacon by default */
|
||||
priv->sf_spec.assocpermit = false; /* Device (if coord) not accepting ssociation */
|
||||
priv->sfspec.assocpermit = false; /* Device (if coord) not accepting ssociation */
|
||||
priv->autoreq = true; /* Auto send data req if addr. in beacon */
|
||||
priv->sf_spec.ble = false; /* BLE disabled */
|
||||
priv->sfspec.ble = false; /* BLE disabled */
|
||||
priv->beaconpayloadlength = 0; /* Beacon payload NULL */
|
||||
priv->sf_spec.beaconorder = 15; /* Non-beacon enabled network */
|
||||
priv->sf_spec.sforder = 15; /* Length of active portion of outgoing SF */
|
||||
priv->sfspec.beaconorder = 15; /* Non-beacon enabled network */
|
||||
priv->sfspec.sforder = 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;
|
||||
@@ -113,10 +113,10 @@ int mac802154_req_reset(MACHANDLE mac, bool rst_pibattr)
|
||||
|
||||
/* Reset the Coordinator address */
|
||||
|
||||
priv->coordaddr.mode = IEEE802154_ADDRMODE_NONE;
|
||||
IEEE802154_PANIDCOPY(priv->coordaddr.panid, &IEEE802154_PANID_UNSPEC);
|
||||
IEEE802154_SADDRCOPY(priv->coordaddr.saddr, &IEEE802154_SADDR_UNSPEC);
|
||||
IEEE802154_EADDRCOPY(priv->coordaddr.eaddr, &IEEE802154_EADDR_UNSPEC);
|
||||
priv->pandesc.coordaddr.mode = IEEE802154_ADDRMODE_NONE;
|
||||
IEEE802154_PANIDCOPY(priv->pandesc.coordaddr.panid, &IEEE802154_PANID_UNSPEC);
|
||||
IEEE802154_SADDRCOPY(priv->pandesc.coordaddr.saddr, &IEEE802154_SADDR_UNSPEC);
|
||||
IEEE802154_EADDRCOPY(priv->pandesc.coordaddr.eaddr, &IEEE802154_EADDR_UNSPEC);
|
||||
|
||||
/* Reset the device's address */
|
||||
|
||||
|
||||
@@ -51,9 +51,17 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "mac802154.h"
|
||||
#include "mac802154_internal.h"
|
||||
#include "mac802154_scan.h"
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_scantimeout(FAR struct ieee802154_privmac_s *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Public MAC Functions
|
||||
****************************************************************************/
|
||||
@@ -79,7 +87,7 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
|
||||
(FAR struct ieee802154_privmac_s *)mac;
|
||||
int ret;
|
||||
|
||||
if (req->duration > 15)
|
||||
if (req->duration > 15 || req->numchan < 0 || req->numchan > 15)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto errout;
|
||||
@@ -92,23 +100,60 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
|
||||
ret = mac802154_takesem(&priv->opsem, true);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
ret = -EINTR;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
priv->curr_op = MAC802154_OP_SCAN;
|
||||
|
||||
/* Get exclusive access to the MAC */
|
||||
|
||||
ret = mac802154_takesem(&priv->exclsem, true);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
mac802154_givesem(&priv->opsem);
|
||||
ret = -EINTR;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Copy the request so we have a reference */
|
||||
|
||||
memcpy(&priv->currscan, req, sizeof(struct ieee802154_scan_req_s));
|
||||
priv->scanindex = 0;
|
||||
priv->npandesc = 0;
|
||||
|
||||
switch (req->type)
|
||||
{
|
||||
case IEEE802154_SCANTYPE_PASSIVE:
|
||||
{
|
||||
/* Set the channel to the first channel in the list */
|
||||
|
||||
mac802154_setchannel(priv, req->channels[priv->scanindex]);
|
||||
mac802154_setchpage(priv, req->chpage);
|
||||
|
||||
/* Before commencing an active or passive scan, the MAC sublayer shall
|
||||
* store the value of macPANId and then set it to 0xffff for the
|
||||
* duration of the scan. This enables the receive filter to accept all
|
||||
* beacons rather than just the beacons from its current PAN, as
|
||||
* described in 5.1.6.2. On completion of the scan, the MAC sublayer
|
||||
* shall restore the value of macPANId to the value stored before the
|
||||
* scan began. [1] pg. 24
|
||||
*/
|
||||
|
||||
IEEE802154_PANIDCOPY(priv->panidbeforescan, priv->addr.panid);
|
||||
mac802154_setpanid(priv, (const uint8_t *)&IEEE802154_PANID_UNSPEC);
|
||||
|
||||
/* ...after switching to the channel for a passive scan, the device
|
||||
* shall enable its receiver for at most
|
||||
* [aBaseSuperframeDuration × (2 * n + 1)],
|
||||
* where n is the value of the ScanDuration parameter. [1] pg. 25
|
||||
*/
|
||||
|
||||
mac802154_rxenable(priv);
|
||||
|
||||
priv->scansymdur = IEEE802154_BASE_SUPERFRAME_DURATION *
|
||||
((1 << req->duration) + 1);
|
||||
mac802154_timerstart(priv, priv->scansymdur, mac802154_scantimeout);
|
||||
}
|
||||
break;
|
||||
case IEEE802154_SCANTYPE_ACTIVE:
|
||||
@@ -137,11 +182,103 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
|
||||
break;
|
||||
}
|
||||
|
||||
mac802154_givesem(&priv->exclsem);
|
||||
return OK;
|
||||
|
||||
errout_with_sem;
|
||||
errout_with_sem:
|
||||
mac802154_givesem(&priv->exclsem);
|
||||
mac802154_givesem(&priv->opsem);
|
||||
errout:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Internal MAC Functions
|
||||
****************************************************************************/
|
||||
|
||||
void mac802154_scanfinish(FAR struct ieee802154_privmac_s *priv,
|
||||
enum ieee802154_status_e status)
|
||||
{
|
||||
FAR struct ieee802154_notif_s * notif;
|
||||
|
||||
mac802154_takesem(&priv->exclsem, false);
|
||||
mac802154_notif_alloc(priv, ¬if, false);
|
||||
|
||||
priv->curr_op = MAC802154_OP_NONE;
|
||||
mac802154_givesem(&priv->opsem);
|
||||
|
||||
notif->notiftype = IEEE802154_NOTIFY_CONF_SCAN;
|
||||
notif->u.scanconf.type = priv->currscan.type;
|
||||
notif->u.scanconf.chpage = priv->currscan.chpage;
|
||||
|
||||
/* Copy in the channels that did not get scanned */
|
||||
|
||||
if (priv->scanindex != priv->currscan.numchan)
|
||||
{
|
||||
notif->u.scanconf.numunscanned = priv->currscan.numchan - priv->scanindex;
|
||||
memcpy(notif->u.scanconf.unscanned, &priv->currscan.channels[priv->scanindex],
|
||||
notif->u.scanconf.numunscanned);
|
||||
}
|
||||
|
||||
notif->u.scanconf.numdesc = priv->npandesc;
|
||||
memcpy(notif->u.scanconf.pandescs, priv->pandescs,
|
||||
sizeof(struct ieee802154_pandesc_s) * priv->npandesc);
|
||||
notif->u.scanconf.status = status;
|
||||
|
||||
/* Reset the PAN ID to the setting before the scan started */
|
||||
|
||||
mac802154_setpanid(priv, priv->panidbeforescan);
|
||||
|
||||
mac802154_givesem(&priv->exclsem);
|
||||
|
||||
mac802154_notify(priv, notif);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_scantimeout
|
||||
*
|
||||
* Description:
|
||||
* Function registered with MAC timer that gets called via the work queue to
|
||||
* handle a timeout for performing a scan operation.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void mac802154_scantimeout(FAR struct ieee802154_privmac_s *priv)
|
||||
{
|
||||
DEBUGASSERT(priv->curr_op == MAC802154_OP_SCAN);
|
||||
|
||||
/* If we got here it means we are done scanning that channel */
|
||||
|
||||
mac802154_rxdisable(priv);
|
||||
priv->scanindex++;
|
||||
|
||||
/* Check to see if this was the last channel to scan */
|
||||
|
||||
if (priv->scanindex == priv->currscan.numchan)
|
||||
{
|
||||
if (priv->npandesc > 0)
|
||||
{
|
||||
mac802154_scanfinish(priv, IEEE802154_STATUS_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
mac802154_scanfinish(priv, IEEE802154_STATUS_NO_BEACON);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
mac802154_setchannel(priv, priv->currscan.channels[priv->scanindex]);
|
||||
|
||||
/* ...after switching to the channel for a passive scan, the device
|
||||
* shall enable its receiver for at most
|
||||
* [aBaseSuperframeDuration × (2 * n + 1)],
|
||||
* where n is the value of the ScanDuration parameter. [1] pg. 25
|
||||
*/
|
||||
|
||||
mac802154_rxenable(priv);
|
||||
mac802154_timerstart(priv, priv->scansymdur, mac802154_scantimeout);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* wireless/ieee802154/mac802154_scan.h
|
||||
*
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
*
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* The naming and comments for various fields are taken directly
|
||||
* from the IEEE 802.15.4 2011 standard.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __WIRELESS_IEEE802154__MAC802154_SCAN_H
|
||||
#define __WIRELESS_IEEE802154__MAC802154_SCAN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
struct ieee802154_privmac_s; /* Forward Reference */
|
||||
|
||||
void mac802154_scanfinish(FAR struct ieee802154_privmac_s *priv,
|
||||
enum ieee802154_status_e status);
|
||||
|
||||
#endif /* __WIRELESS_IEEE802154__MAC802154_SCAN_H */
|
||||
@@ -97,14 +97,12 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
||||
|
||||
/* Set the PANID attribute */
|
||||
|
||||
IEEE802154_PANIDCOPY(priv->addr.panid, req->panid);
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_PANID,
|
||||
(FAR const union ieee802154_attr_u *)req->panid);
|
||||
mac802154_setpanid(priv, req->panid);
|
||||
|
||||
/* Tell the radio layer to set the channel number and channel page */
|
||||
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_PHY_CURRENT_CHANNEL,
|
||||
(FAR const union ieee802154_attr_u *)&req->chnum);
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_PHY_CHAN,
|
||||
(FAR const union ieee802154_attr_u *)&req->chan);
|
||||
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_PHY_CURRENT_PAGE,
|
||||
(FAR const union ieee802154_attr_u *)&req->chpage);
|
||||
|
||||
@@ -130,11 +128,11 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
priv->sf_spec.beaconorder = req->beaconorder;
|
||||
priv->sfspec.beaconorder = req->beaconorder;
|
||||
|
||||
/* The value of macSuperframeOrder shall be ignored if macBeaconOrder = 15. pg. 19 */
|
||||
|
||||
if (priv->sf_spec.beaconorder < 15)
|
||||
if (priv->sfspec.beaconorder < 15)
|
||||
{
|
||||
/* Set the superframe order */
|
||||
|
||||
@@ -144,7 +142,7 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
priv->sf_spec.sforder = req->superframeorder;
|
||||
priv->sfspec.sforder = req->superframeorder;
|
||||
}
|
||||
|
||||
if (req->pancoord)
|
||||
@@ -156,9 +154,9 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
||||
priv->devmode = IEEE802154_DEVMODE_COORD;
|
||||
}
|
||||
|
||||
priv->sf_spec.pancoord = req->pancoord;
|
||||
priv->sfspec.pancoord = req->pancoord;
|
||||
|
||||
if (priv->sf_spec.beaconorder < 15)
|
||||
if (priv->sfspec.beaconorder < 15)
|
||||
{
|
||||
/* If the BeaconOrder parameter is less than 15, the MLME sets macBattLifeExt to
|
||||
* the value of the BatteryLifeExtension parameter. If the BeaconOrder parameter
|
||||
@@ -166,11 +164,11 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
||||
* [1] pg. 106
|
||||
*/
|
||||
|
||||
priv->sf_spec.ble = req->battlifeext;
|
||||
priv->sfspec.ble = req->battlifeext;
|
||||
|
||||
/* For now we just set the CAP Slot to 15 */
|
||||
|
||||
priv->sf_spec.final_capslot = 15;
|
||||
priv->sfspec.final_capslot = 15;
|
||||
|
||||
/* If the PAN coordinator parameter is set to TRUE, the MLME ignores the
|
||||
* StartTime parameter and begins beacon transmissions immediately.
|
||||
@@ -184,7 +182,7 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
||||
|
||||
/* Tell the radio to start transmitting beacon frames */
|
||||
|
||||
priv->radio->beaconstart(priv->radio, &priv->sf_spec,
|
||||
priv->radio->beaconstart(priv->radio, &priv->sfspec,
|
||||
&priv->beaconframe[priv->bf_ind]);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user