Beacon logic: Damage control. Looks like something went wrong with the PR merge.
This commit is contained in:
parent
2069a90220
commit
1f81b14610
@ -281,7 +281,7 @@ enum ieee802154_status_e
|
|||||||
/* This first section of enums is defined in the standard. [1] pg. 70
|
/* This first section of enums is defined in the standard. [1] pg. 70
|
||||||
* They must be in this order
|
* They must be in this order
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IEEE802154_STATUS_SUCCESS = 0,
|
IEEE802154_STATUS_SUCCESS = 0,
|
||||||
IEEE802154_STATUS_OUT_OF_CAPACITY,
|
IEEE802154_STATUS_OUT_OF_CAPACITY,
|
||||||
IEEE802154_STATUS_DENIED,
|
IEEE802154_STATUS_DENIED,
|
||||||
@ -906,7 +906,7 @@ struct ieee802154_assoc_req_s
|
|||||||
* enabled PAN or non-beacon enabled PAN. If it is beacon-enabled, the MAC
|
* enabled PAN or non-beacon enabled PAN. If it is beacon-enabled, the MAC
|
||||||
* will track the beacon first before transmitting the association. This can
|
* will track the beacon first before transmitting the association. This can
|
||||||
* take some time depending on the beacon interval. If the PAN is non-beacon
|
* take some time depending on the beacon interval. If the PAN is non-beacon
|
||||||
* enabled, the association request is sent immediately via CSMA.
|
* enabled, the association request is sent immediately via CSMA.
|
||||||
*
|
*
|
||||||
* The catch 22: The standard outlines the procedure for associating: reset
|
* The catch 22: The standard outlines the procedure for associating: reset
|
||||||
* the MAC, scan to find PAN's and pass coordinator address info to
|
* the MAC, scan to find PAN's and pass coordinator address info to
|
||||||
@ -927,7 +927,7 @@ struct ieee802154_assoc_req_s
|
|||||||
* info if it is not associated.
|
* info if it is not associated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool beacon;
|
bool beacon;
|
||||||
|
|
||||||
/* Coordinator Address with which to associate */
|
/* Coordinator Address with which to associate */
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ struct ieee802154_beaconframe_s
|
|||||||
{
|
{
|
||||||
uint8_t bf_data[IEEE802154_MAX_PHY_PACKET_SIZE];
|
uint8_t bf_data[IEEE802154_MAX_PHY_PACKET_SIZE];
|
||||||
uint8_t bf_len;
|
uint8_t bf_len;
|
||||||
uint8_t bf_offset;
|
uint8_t bf_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ieee802154_sfevent_e
|
enum ieee802154_sfevent_e
|
||||||
|
@ -5,4 +5,4 @@ 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
|
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
|
page number. Below is the references that correspond with the reference number
|
||||||
|
|
||||||
[1]
|
[1]
|
@ -399,7 +399,7 @@ void mac802154_updatebeacon(FAR struct ieee802154_privmac_s *priv)
|
|||||||
|
|
||||||
/* Clear the frame control fields */
|
/* Clear the frame control fields */
|
||||||
|
|
||||||
beacon->bf_data[0] = 0;
|
beacon->bf_data[0] = 0;
|
||||||
beacon->bf_data[1] = 0;
|
beacon->bf_data[1] = 0;
|
||||||
beacon->bf_len = 2;
|
beacon->bf_len = 2;
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ void mac802154_updatebeacon(FAR struct ieee802154_privmac_s *priv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* TODO: handle broadcast frame */
|
/* TODO: handle broadcast frame */
|
||||||
|
|
||||||
DEBUGASSERT(priv->addr.mode != IEEE802154_ADDRMODE_NONE);
|
DEBUGASSERT(priv->addr.mode != IEEE802154_ADDRMODE_NONE);
|
||||||
|
|
||||||
IEEE802154_SETDADDRMODE(beacon->bf_data, 0, IEEE802154_ADDRMODE_NONE);
|
IEEE802154_SETDADDRMODE(beacon->bf_data, 0, IEEE802154_ADDRMODE_NONE);
|
||||||
@ -471,7 +471,7 @@ void mac802154_updatebeacon(FAR struct ieee802154_privmac_s *priv)
|
|||||||
/* Skip the pending address specification field for now */
|
/* Skip the pending address specification field for now */
|
||||||
|
|
||||||
pendaddrspec_ind = beacon->bf_len++;
|
pendaddrspec_ind = beacon->bf_len++;
|
||||||
|
|
||||||
txdesc = (FAR struct ieee802154_txdesc_s *)sq_peek(&priv->indirect_queue);
|
txdesc = (FAR struct ieee802154_txdesc_s *)sq_peek(&priv->indirect_queue);
|
||||||
|
|
||||||
while(txdesc != NULL)
|
while(txdesc != NULL)
|
||||||
@ -488,7 +488,7 @@ void mac802154_updatebeacon(FAR struct ieee802154_privmac_s *priv)
|
|||||||
IEEE802154_EADDRCOPY(&beacon->bf_data[beacon->bf_len], txdesc->destaddr.eaddr);
|
IEEE802154_EADDRCOPY(&beacon->bf_data[beacon->bf_len], txdesc->destaddr.eaddr);
|
||||||
beacon->bf_len += IEEE802154_EADDRSIZE;
|
beacon->bf_len += IEEE802154_EADDRSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we are up to 7 addresses yet */
|
/* Check if we are up to 7 addresses yet */
|
||||||
|
|
||||||
if ((pendsaddr + pendeaddr) == 7)
|
if ((pendsaddr + pendeaddr) == 7)
|
||||||
@ -500,11 +500,11 @@ void mac802154_updatebeacon(FAR struct ieee802154_privmac_s *priv)
|
|||||||
|
|
||||||
txdesc = (FAR struct ieee802154_txdesc_s *)sq_next((FAR sq_entry_t *)txdesc);
|
txdesc = (FAR struct ieee802154_txdesc_s *)sq_next((FAR sq_entry_t *)txdesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point, we know how many of each transaction we have, we can setup
|
/* At this point, we know how many of each transaction we have, we can setup
|
||||||
* the Pending Address Specification field
|
* the Pending Address Specification field
|
||||||
*/
|
*/
|
||||||
|
|
||||||
beacon->bf_data[pendaddrspec_ind] = (pendsaddr & 0x07) | ((pendeaddr << 4) & 0x70);
|
beacon->bf_data[pendaddrspec_ind] = (pendsaddr & 0x07) | ((pendeaddr << 4) & 0x70);
|
||||||
|
|
||||||
/* Copy in the beacon payload */
|
/* Copy in the beacon payload */
|
||||||
@ -1035,7 +1035,7 @@ static void mac802154_rxframe_worker(FAR void *arg)
|
|||||||
{
|
{
|
||||||
/* The source PAN ID is equal to the destination PAN ID */
|
/* The source PAN ID is equal to the destination PAN ID */
|
||||||
|
|
||||||
IEEE802154_PANIDCOPY(ind->src.panid, ind->dest.panid);
|
IEEE802154_PANIDCOPY(ind->src.panid, ind->dest.panid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1570,7 +1570,7 @@ static void mac802154_rxbeaconframe(FAR struct ieee802154_privmac_s *priv,
|
|||||||
pandesc.sfspec.beaconorder = IEEE802154_GETBEACONORDER(iob->io_data,
|
pandesc.sfspec.beaconorder = IEEE802154_GETBEACONORDER(iob->io_data,
|
||||||
iob->io_offset);
|
iob->io_offset);
|
||||||
|
|
||||||
pandesc.sfspec.sforder = IEEE802154_GETSFORDER(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,
|
pandesc.sfspec.final_capslot = IEEE802154_GETFINCAPSLOT(iob->io_data,
|
||||||
iob->io_offset);
|
iob->io_offset);
|
||||||
pandesc.sfspec.ble = IEEE802154_GETBLE(iob->io_data, iob->io_offset);
|
pandesc.sfspec.ble = IEEE802154_GETBLE(iob->io_data, iob->io_offset);
|
||||||
@ -1595,11 +1595,11 @@ static void mac802154_rxbeaconframe(FAR struct ieee802154_privmac_s *priv,
|
|||||||
|
|
||||||
for (i = 0; i < priv->npandesc; i++)
|
for (i = 0; i < priv->npandesc; i++)
|
||||||
{
|
{
|
||||||
if (priv->currscan.channels[priv->scanindex] != priv->pandescs[i].chan)
|
if (priv->currscan.channels[priv->scanindex] != priv->pandescs[i].chan)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(&ind->src, &priv->pandescs[i].coordaddr,
|
if (memcmp(&ind->src, &priv->pandescs[i].coordaddr,
|
||||||
sizeof(struct ieee802154_addr_s)))
|
sizeof(struct ieee802154_addr_s)))
|
||||||
{
|
{
|
||||||
@ -1607,10 +1607,10 @@ static void mac802154_rxbeaconframe(FAR struct ieee802154_privmac_s *priv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The beacon is the same as another, so discard it */
|
/* The beacon is the same as another, so discard it */
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the pan desc to the list of pan desc */
|
/* Copy the pan desc to the list of pan desc */
|
||||||
|
|
||||||
memcpy(&priv->pandescs[priv->npandesc], &pandesc,
|
memcpy(&priv->pandescs[priv->npandesc], &pandesc,
|
||||||
@ -1703,12 +1703,12 @@ static void mac802154_rxbeaconframe(FAR struct ieee802154_privmac_s *priv,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Check the superframe structure and update the appropriate attributes. */
|
/* Check the superframe structure and update the appropriate attributes. */
|
||||||
|
|
||||||
if (memcmp(&priv->sfspec, &pandesc.sfspec,
|
if (memcmp(&priv->sfspec, &pandesc.sfspec,
|
||||||
sizeof(struct ieee802154_superframespec_s)) != 0)
|
sizeof(struct ieee802154_superframespec_s)) != 0)
|
||||||
{
|
{
|
||||||
/* Copy in the new superframe spec */
|
/* Copy in the new superframe spec */
|
||||||
|
|
||||||
memcpy(&priv->sfspec, &pandesc.sfspec,
|
memcpy(&priv->sfspec, &pandesc.sfspec,
|
||||||
sizeof(struct ieee802154_superframespec_s));
|
sizeof(struct ieee802154_superframespec_s));
|
||||||
|
|
||||||
|
@ -318,9 +318,9 @@ int mac802154_resp_associate(MACHANDLE mac,
|
|||||||
* Destination PAN Identifier field shall contain the value of macPANId, while
|
* Destination PAN Identifier field shall contain the value of macPANId, while
|
||||||
* the Source PAN Identifier field shall be omitted. [1] pg. 69
|
* the Source PAN Identifier field shall be omitted. [1] pg. 69
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mac802154_putpanid(iob, priv->addr.panid);
|
mac802154_putpanid(iob, priv->addr.panid);
|
||||||
|
|
||||||
/* The Destination Address field shall contain the extended address of the
|
/* The Destination Address field shall contain the extended address of the
|
||||||
* device requesting association. [1] pg. 69 */
|
* device requesting association. [1] pg. 69 */
|
||||||
|
|
||||||
|
@ -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
|
* the corresponding data frame from the coordinator. [1] pg.43
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mac802154_rxenable(priv);
|
mac802154_rxenable(priv);
|
||||||
|
|
||||||
/* Start a timer, if we receive the data frame, we will cancel
|
/* Start a timer, if we receive the data frame, we will cancel
|
||||||
* the timer, otherwise it will expire and we will notify the
|
* the timer, otherwise it will expire and we will notify the
|
||||||
|
@ -105,9 +105,9 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv->curr_op = MAC802154_OP_SCAN;
|
priv->curr_op = MAC802154_OP_SCAN;
|
||||||
|
|
||||||
/* Get exclusive access to the MAC */
|
/* Get exclusive access to the MAC */
|
||||||
|
|
||||||
ret = mac802154_takesem(&priv->exclsem, true);
|
ret = mac802154_takesem(&priv->exclsem, true);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
|
|||||||
ret = -EINTR;
|
ret = -EINTR;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the request so we have a reference */
|
/* Copy the request so we have a reference */
|
||||||
|
|
||||||
memcpy(&priv->currscan, req, sizeof(struct ieee802154_scan_req_s));
|
memcpy(&priv->currscan, req, sizeof(struct ieee802154_scan_req_s));
|
||||||
@ -139,7 +139,7 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
|
|||||||
* shall restore the value of macPANId to the value stored before the
|
* shall restore the value of macPANId to the value stored before the
|
||||||
* scan began. [1] pg. 24
|
* scan began. [1] pg. 24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IEEE802154_PANIDCOPY(priv->panidbeforescan, priv->addr.panid);
|
IEEE802154_PANIDCOPY(priv->panidbeforescan, priv->addr.panid);
|
||||||
mac802154_setpanid(priv, (const uint8_t *)&IEEE802154_PANID_UNSPEC);
|
mac802154_setpanid(priv, (const uint8_t *)&IEEE802154_PANID_UNSPEC);
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
|
|||||||
* [aBaseSuperframeDuration × (2 * n + 1)],
|
* [aBaseSuperframeDuration × (2 * n + 1)],
|
||||||
* where n is the value of the ScanDuration parameter. [1] pg. 25
|
* where n is the value of the ScanDuration parameter. [1] pg. 25
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mac802154_rxenable(priv);
|
mac802154_rxenable(priv);
|
||||||
|
|
||||||
priv->scansymdur = IEEE802154_BASE_SUPERFRAME_DURATION *
|
priv->scansymdur = IEEE802154_BASE_SUPERFRAME_DURATION *
|
||||||
@ -219,7 +219,7 @@ void mac802154_scanfinish(FAR struct ieee802154_privmac_s *priv,
|
|||||||
memcpy(notif->u.scanconf.unscanned, &priv->currscan.channels[priv->scanindex],
|
memcpy(notif->u.scanconf.unscanned, &priv->currscan.channels[priv->scanindex],
|
||||||
notif->u.scanconf.numunscanned);
|
notif->u.scanconf.numunscanned);
|
||||||
}
|
}
|
||||||
|
|
||||||
notif->u.scanconf.numdesc = priv->npandesc;
|
notif->u.scanconf.numdesc = priv->npandesc;
|
||||||
memcpy(notif->u.scanconf.pandescs, priv->pandescs,
|
memcpy(notif->u.scanconf.pandescs, priv->pandescs,
|
||||||
sizeof(struct ieee802154_pandesc_s) * priv->npandesc);
|
sizeof(struct ieee802154_pandesc_s) * priv->npandesc);
|
||||||
@ -270,7 +270,7 @@ static void mac802154_scantimeout(FAR struct ieee802154_privmac_s *priv)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mac802154_setchannel(priv, priv->currscan.channels[priv->scanindex]);
|
mac802154_setchannel(priv, priv->currscan.channels[priv->scanindex]);
|
||||||
|
|
||||||
/* ...after switching to the channel for a passive scan, the device
|
/* ...after switching to the channel for a passive scan, the device
|
||||||
@ -278,7 +278,7 @@ static void mac802154_scantimeout(FAR struct ieee802154_privmac_s *priv)
|
|||||||
* [aBaseSuperframeDuration × (2 * n + 1)],
|
* [aBaseSuperframeDuration × (2 * n + 1)],
|
||||||
* where n is the value of the ScanDuration parameter. [1] pg. 25
|
* where n is the value of the ScanDuration parameter. [1] pg. 25
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mac802154_rxenable(priv);
|
mac802154_rxenable(priv);
|
||||||
mac802154_timerstart(priv, priv->scansymdur, mac802154_scantimeout);
|
mac802154_timerstart(priv, priv->scansymdur, mac802154_scantimeout);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
|||||||
* contain the value of macExtendedAddress if macShortAddress is equal to
|
* contain the value of macExtendedAddress if macShortAddress is equal to
|
||||||
* 0xfffe or macShortAddress otherwise. [1] pg. 32
|
* 0xfffe or macShortAddress otherwise. [1] pg. 32
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (IEEE802154_SADDRCMP(priv->addr.saddr, &IEEE802154_SADDR_BCAST))
|
if (IEEE802154_SADDRCMP(priv->addr.saddr, &IEEE802154_SADDR_BCAST))
|
||||||
{
|
{
|
||||||
priv->addr.mode = IEEE802154_ADDRMODE_EXTENDED;
|
priv->addr.mode = IEEE802154_ADDRMODE_EXTENDED;
|
||||||
@ -167,7 +167,7 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
|
|||||||
priv->sfspec.ble = req->battlifeext;
|
priv->sfspec.ble = req->battlifeext;
|
||||||
|
|
||||||
/* For now we just set the CAP Slot to 15 */
|
/* For now we just set the CAP Slot to 15 */
|
||||||
|
|
||||||
priv->sfspec.final_capslot = 15;
|
priv->sfspec.final_capslot = 15;
|
||||||
|
|
||||||
/* If the PAN coordinator parameter is set to TRUE, the MLME ignores the
|
/* If the PAN coordinator parameter is set to TRUE, the MLME ignores the
|
||||||
|
Loading…
Reference in New Issue
Block a user