2017-06-14 08:49:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* wireless/ieee802154/mac802154_reset.c
|
|
|
|
*
|
2024-09-11 09:04:25 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-09-06 13:39:36 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2017-06-14 08:49:27 +02:00
|
|
|
*
|
2021-09-06 13:39:36 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2017-06-14 08:49:27 +02:00
|
|
|
*
|
2021-09-06 13:39:36 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2017-06-14 08:49:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "mac802154.h"
|
|
|
|
#include "mac802154_internal.h"
|
|
|
|
|
|
|
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
2020-04-23 11:51:21 +02:00
|
|
|
* Public Functions
|
2017-06-14 08:49:27 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mac802154_req_reset
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The MLME-RESET.request primitive allows the next higher layer to request
|
|
|
|
* that the MLME performs a reset operation.
|
|
|
|
*
|
|
|
|
* NOTE: The standard specifies that confirmation should be provided via
|
2020-02-23 09:50:23 +01:00
|
|
|
* via the asynchronous MLME-RESET.confirm primitive. However, in our
|
2020-04-23 11:51:21 +02:00
|
|
|
* implementation we synchronously return the value immediately.
|
|
|
|
* Therefore, we merge the functionality of the MLME-RESET.request and
|
|
|
|
* MLME-RESET.confirm primitives together.
|
2017-06-14 08:49:27 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
2020-04-23 11:51:21 +02:00
|
|
|
* mac - Handle to the MAC layer instance
|
|
|
|
* resetattr - Whether or not to reset the MAC PIB attributes to defaults
|
2017-06-14 08:49:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-07-01 23:02:40 +02:00
|
|
|
int mac802154_req_reset(MACHANDLE mac, bool resetattr)
|
2017-06-14 08:49:27 +02:00
|
|
|
{
|
|
|
|
FAR struct ieee802154_privmac_s * priv =
|
|
|
|
(FAR struct ieee802154_privmac_s *) mac;
|
|
|
|
union ieee802154_attr_u attr;
|
|
|
|
|
2017-07-01 23:02:40 +02:00
|
|
|
if (resetattr)
|
2017-06-14 08:49:27 +02:00
|
|
|
{
|
2017-09-15 16:04:38 +02:00
|
|
|
/* We do not reset the extended address. The extended address must be
|
|
|
|
* manually overwritten.
|
|
|
|
*/
|
|
|
|
|
|
|
|
priv->radio->reset(priv->radio);
|
|
|
|
|
2017-07-12 06:57:55 +02:00
|
|
|
priv->isassoc = false; /* Not associated with a PAN */
|
|
|
|
priv->trackingbeacon = false; /* Not tracking beacon by default */
|
|
|
|
priv->sfspec.assocpermit = false; /* Dev (if coord) not accepting assoc */
|
|
|
|
priv->autoreq = true; /* Auto send data req if addr in beacon */
|
2017-06-26 00:07:50 +02:00
|
|
|
priv->sfspec.ble = false; /* BLE disabled */
|
2017-07-12 06:57:55 +02:00
|
|
|
priv->beaconpayloadlength = 0; /* Beacon payload NULL */
|
|
|
|
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 */
|
|
|
|
priv->dsn = 0; /* Data sequence number */
|
|
|
|
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_totaldur = 0; /* 0 transmit duration */
|
2017-06-14 08:49:27 +02:00
|
|
|
|
2020-04-23 11:51:21 +02:00
|
|
|
priv->trans_persisttime = 0x01f4;
|
2017-06-14 08:49:27 +02:00
|
|
|
|
2017-09-15 16:04:38 +02:00
|
|
|
/* Reset the short address and PAN ID. The extended address does not
|
2019-08-10 20:25:13 +02:00
|
|
|
* get reset. It is a read-only attribute and the radio driver should
|
2020-04-23 11:51:21 +02:00
|
|
|
* be in charge of managing it. We pull a local copy for us to use
|
|
|
|
* below.
|
2017-09-15 16:04:38 +02:00
|
|
|
*/
|
2017-06-14 08:49:27 +02:00
|
|
|
|
2017-09-15 16:04:38 +02:00
|
|
|
priv->addr.mode = IEEE802154_ADDRMODE_EXTENDED;
|
|
|
|
mac802154_setsaddr(priv, IEEE802154_SADDR_UNSPEC);
|
|
|
|
mac802154_setpanid(priv, IEEE802154_PANID_UNSPEC);
|
2017-06-14 08:49:27 +02:00
|
|
|
|
2017-09-15 16:04:38 +02:00
|
|
|
priv->pandesc.coordaddr.mode = IEEE802154_ADDRMODE_NONE;
|
|
|
|
mac802154_setcoordeaddr(priv, IEEE802154_EADDR_UNSPEC);
|
|
|
|
mac802154_setcoordsaddr(priv, IEEE802154_SADDR_UNSPEC);
|
2017-06-14 08:49:27 +02:00
|
|
|
|
2017-09-15 16:04:38 +02:00
|
|
|
mac802154_setdevmode(priv, IEEE802154_DEVMODE_ENDPOINT);
|
2017-06-14 08:49:27 +02:00
|
|
|
|
|
|
|
/* The radio is in control of certain attributes, but we keep a mirror
|
|
|
|
* for easy access. Copy in the radio's values now that they've been
|
|
|
|
* reset.
|
|
|
|
*/
|
|
|
|
|
2020-04-23 11:51:21 +02:00
|
|
|
priv->radio->getattr(priv->radio,
|
|
|
|
IEEE802154_ATTR_MAC_EADDR, &attr);
|
|
|
|
IEEE802154_EADDRCOPY(priv->addr.eaddr,
|
|
|
|
attr.mac.eaddr);
|
2019-08-10 20:25:13 +02:00
|
|
|
|
2020-04-23 11:51:21 +02:00
|
|
|
priv->radio->getattr(priv->radio,
|
|
|
|
IEEE802154_ATTR_MAC_MAX_FRAME_WAITTIME,
|
|
|
|
&attr);
|
2017-06-14 08:49:27 +02:00
|
|
|
priv->max_frame_waittime = attr.mac.max_frame_waittime;
|
|
|
|
}
|
|
|
|
|
2017-09-15 16:04:38 +02:00
|
|
|
priv->nrxusers = 0;
|
|
|
|
|
2017-06-14 08:49:27 +02:00
|
|
|
return OK;
|
|
|
|
}
|