wireless/ieee802154: Removes radio IOCTL. Starts bringing radio and MAC closer with well-defined interface.

This commit is contained in:
Anthony Merlino
2017-05-05 11:15:28 -04:00
parent abc15c8429
commit dd40014279
18 changed files with 270 additions and 1890 deletions
-8
View File
@@ -60,14 +60,6 @@ config IEEE802154_NTXDESC
endif # IEEE802154_MAC
config IEEE802154_DEV
bool "Debug character driver for ieee802.15.4 radio interfaces"
default n
depends on WIRELESS_IEEE802154
---help---
Enables a device driver to expose ieee802.15.4 radio controls
to user space as IOCTLs.
config IEEE802154_NETDEV
bool "IEEE802154 6loWPAN Network Device"
default n
-2
View File
@@ -37,8 +37,6 @@ ifeq ($(CONFIG_WIRELESS_IEEE802154),y)
# Include IEEE 802.15.4 support
CSRCS = radio802154_ioctl.c
# Include wireless devices build support
ifeq ($(CONFIG_IEEE802154_MAC),y)
+47 -67
View File
@@ -2,7 +2,9 @@
* wireless/ieee802154/mac802154.c
*
* Copyright (C) 2016 Sebastien Lorquet. All rights reserved.
* Copyright (C) 2017 Verge Inc. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
* Author: Anthony Merlino <anthony@vergeaero.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -51,6 +53,7 @@
#include <nuttx/drivers/iob.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "mac802154.h"
@@ -445,14 +448,15 @@ static int mac802154_defaultmib(FAR struct ieee802154_privmac_s *priv)
priv->coord_addr.mode = IEEE802154_ADDRMODE_NONE;
priv->coord_addr.saddr = IEEE802154_SADDR_UNSPEC;
memcpy(&priv->coord_addr.eaddr[0], IEEE802154_EADDR_UNSPEC, 8);
memcpy(&priv->coord_addr.eaddr[0], IEEE802154_EADDR_UNSPEC,
IEEE802154_EADDR_LEN);
/* 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);
memcpy(&priv->addr.eaddr[0], IEEE802154_EADDR_UNSPEC, IEEE802154_EADDR_LEN);
/* These attributes are effected and determined based on the PHY. Need to
@@ -875,85 +879,78 @@ int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg)
{
case MAC802154IOC_MLME_ASSOC_REQUEST:
{
mac802154_req_associate(mac, &macarg->assocreq);
ret = mac802154_req_associate(mac, &macarg->assocreq);
}
break;
case MAC802154IOC_MLME_ASSOC_RESPONSE:
{
mac802154_resp_associate(mac, &macarg->assocresp);
ret = mac802154_resp_associate(mac, &macarg->assocresp);
}
break;
case MAC802154IOC_MLME_DISASSOC_REQUEST:
{
mac802154_req_disassociate(mac, &macarg->disassocreq);
ret = mac802154_req_disassociate(mac, &macarg->disassocreq);
}
break;
case MAC802154IOC_MLME_GET_REQUEST:
{
mac802154_req_get(mac, macarg->getreq.pib_attr,
macarg->getreq.attr_value);
ret = mac802154_req_get(mac, macarg->getreq.pib_attr,
&macarg->getreq.attr_value);
}
break;
case MAC802154IOC_MLME_GTS_REQUEST:
{
mac802154_req_gts(mac, &macarg->gtsreq);
ret = mac802154_req_gts(mac, &macarg->gtsreq);
}
break;
case MAC802154IOC_MLME_ORPHAN_RESPONSE:
{
mac802154_resp_orphan(mac, &macarg->orphanresp);
ret = mac802154_resp_orphan(mac, &macarg->orphanresp);
}
break;
case MAC802154IOC_MLME_RESET_REQUEST:
{
mac802154_req_reset(mac, macarg->resetreq.rst_pibattr);
ret = mac802154_req_reset(mac, macarg->resetreq.rst_pibattr);
}
break;
case MAC802154IOC_MLME_RXENABLE_REQUEST:
{
mac802154_req_rxenable(mac, &macarg->rxenabreq);
ret = mac802154_req_rxenable(mac, &macarg->rxenabreq);
}
break;
case MAC802154IOC_MLME_SCAN_REQUEST:
{
mac802154_req_scan(mac, &macarg->scanreq);
ret = mac802154_req_scan(mac, &macarg->scanreq);
}
break;
case MAC802154IOC_MLME_SET_REQUEST:
{
mac802154_req_set(mac, &macarg->setreq);
ret = mac802154_req_set(mac, macarg->setreq.pib_attr,
&macarg->setreq.attr_value);
}
break;
case MAC802154IOC_MLME_START_REQUEST:
{
mac802154_req_start(mac, &macarg->startreq);
ret = mac802154_req_start(mac, &macarg->startreq);
}
break;
case MAC802154IOC_MLME_SYNC_REQUEST:
{
mac802154_req_sync(mac, &macarg->syncreq);
ret = mac802154_req_sync(mac, &macarg->syncreq);
}
break;
case MAC802154IOC_MLME_POLL_REQUEST:
{
mac802154_req_poll(mac, &macarg->pollreq);
ret = mac802154_req_poll(mac, &macarg->pollreq);
}
break;
default:
wlerr("ERROR: Unrecognized cmd: %d\n", cmd);
ret = -ENOTTY;
break;
}
}
/* No, other IOCTLs must be aimed at the IEEE802.15.4 radio layer */
else
{
DEBUGASSERT(priv->radio != NULL &&
priv->radio->ops != NULL &&
priv->radio->ops->ioctl != NULL);
ret = priv->radio->ops->ioctl(priv->radio, cmd, arg);
}
return ret;
return ret;
}
/****************************************************************************
@@ -1109,8 +1106,10 @@ int mac802154_req_data(MACHANDLE mac,
}
else if (meta->dest_addr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&frame->io_data[mhr_len], &meta->dest_addr.eaddr, 8);
mhr_len += 8;
memcpy(&frame->io_data[mhr_len], &meta->dest_addr.eaddr,
IEEE802154_EADDR_LEN);
mhr_len += IEEE802154_EADDR_LEN;
}
}
@@ -1166,8 +1165,10 @@ int mac802154_req_data(MACHANDLE mac,
}
else if (meta->src_addr_mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&frame->io_data[mhr_len], &priv->addr.eaddr, 8);
mhr_len += 8;
memcpy(&frame->io_data[mhr_len], &priv->addr.eaddr,
IEEE802154_EADDR_LEN);
mhr_len += IEEE802154_EADDR_LEN;
}
}
@@ -1482,60 +1483,39 @@ int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
*
****************************************************************************/
int mac802154_req_set(MACHANDLE mac, FAR struct ieee802154_set_req_s *req)
int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
FAR const union ieee802154_attr_val_u *attr_value)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
union ieee802154_radioarg_u radio_arg;
int ret;
switch (req->pib_attr)
switch (pib_attr)
{
case IEEE802154_PIB_MAC_EXTENDED_ADDR:
{
/* Update the radio's extended address */
/* Set the MAC copy of the address in the table */
memcpy(&radio_arg.eaddr[0], &priv->addr.eaddr[0], 8);
ret = priv->radio->ops->ioctl(priv->radio, PHY802154IOC_SET_EADDR,
(unsigned long)&radio_arg);
if (ret < 0)
{
return -IEEE802154_STATUS_FAILED;
}
memcpy(&priv->addr.eaddr[0], &attr_value->mac.eaddr[0],
IEEE802154_EADDR_LEN);
/* Set the attribute in the table */
/* Tell the radio about the attribute */
memcpy(&priv->addr.eaddr[0], &req->attr_value.eaddr[0], 8);
priv->radio->ops->set_attr(priv->radio, pib_attr, attr_value);
ret = IEEE802154_STATUS_SUCCESS;
}
break;
case IEEE802154_PIB_MAC_PROMISCUOUS_MODE:
{
/* Try and enable/disable promiscuous mode at the radio */
radio_arg.promisc = priv->promisc_mode;
ret = priv->radio->ops->ioctl(priv->radio, PHY802154IOC_SET_PROMISC,
(unsigned long)&radio_arg);
if (ret < 0)
{
return -IEEE802154_STATUS_FAILED;
}
/* Set the attribute in the table */
priv->promisc_mode = req->attr_value.promics_mode;
ret = IEEE802154_STATUS_SUCCESS;
}
break;
default:
{
ret = -IEEE802154_STATUS_UNSUPPORTED_ATTRIBUTE;
/* The attribute may be handled soley in the radio driver, so pass
* it along.
*/
ret = priv->radio->ops->set_attr(priv->radio, pib_attr, attr_value);
}
break;
}
return ret;
}
+2 -1
View File
@@ -269,7 +269,8 @@ int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
*
****************************************************************************/
int mac802154_req_set(MACHANDLE mac, FAR struct ieee802154_set_req_s *req);
int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
FAR const union ieee802154_attr_val_u *attr_value);
/****************************************************************************
* Name: mac802154_req_start
-27
View File
@@ -54,7 +54,6 @@
#include <nuttx/net/net.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/sixlowpan.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
#include "mac802154.h"
@@ -594,32 +593,6 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
else
#endif
if (_PHY802154IOCVALID(cmd))
{
FAR struct ieee802154_netradio_s *netradio =
(FAR struct ieee802154_netradio_s *)arg;
/* Pick out radio settings of interest. There is, of course, no
* radio in this loopback.
*/
switch (cmd)
{
case PHY802154IOC_SET_PANID:
priv->lo_panid = netradio->u.panid;
ret = OK;
break;
case PHY802154IOC_GET_PANID:
netradio->u.panid = priv->lo_panid;
ret = OK;
break;
default:
break;
}
}
return ret;
}
#endif
-14
View File
@@ -1381,20 +1381,6 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd,
}
}
/* No, check for IOCTLs aimed at the IEEE802.15.4 radio layer */
else if (_PHY802154IOCVALID(cmd))
{
FAR struct ieee802154_netradio_s *netradio =
(FAR struct ieee802154_netradio_s *)arg;
if (netradio != NULL)
{
unsigned long radioarg = (unsigned int)((uintptr_t)&netradio->u);
ret = priv->md_mac.macops.ioctl(priv->md_mac, cmd, radioarg);
}
}
/* Okay, we have no idea what this command is.. just give to the
* IEEE802.15.4 MAC layer without modification.
*/
File diff suppressed because it is too large Load Diff
-487
View File
@@ -1,487 +0,0 @@
/****************************************************************************
* wireless/ieee802154/radio802154_ioctl.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <debug.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define RADIO_IOCTL(r,c,a) \
(r)->ops->ioctl((r),(c),(unsigned long)((uintptr_t)(a)))
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: radio802154_setchannel
*
* Description:
* Define the current radio channel the device is operating on.
* In the 2.4 GHz, there are 16 channels, each 2 MHz wide, 5 MHz spacing:
* Chan MHz Chan MHz Chan MHz Chan MHz
* 11 2405 15 2425 19 2445 23 2465
* 12 2410 16 2430 20 2450 24 2470
* 13 2415 17 2435 21 2455 25 2475
* 14 2420 18 2440 22 2460 26 2480
*
****************************************************************************/
int radio802154_setchannel(FAR struct ieee802154_radio_s *radio,
uint8_t chan)
{
union ieee802154_radioarg_u arg;
int ret;
arg.channel = chan;
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_CHAN, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_CHAN failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_getchannel
*
* Description:
* Define the current radio channel the device is operating on.
*
****************************************************************************/
int radio802154_getchannel(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *chan)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_CHAN, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_CHAN failed: %d\n", ret);
}
*chan = arg.channel;
return ret;
}
/****************************************************************************
* Name: radio802154_setpanid
*
* Description:
* Define the PAN ID the device is operating on.
*
****************************************************************************/
int radio802154_setpanid(FAR struct ieee802154_radio_s *radio,
uint16_t panid)
{
union ieee802154_radioarg_u arg;
int ret;
arg.panid = panid;
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_PANID, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_PANID failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_getpanid
*
* Description:
* Define the current PAN ID the device is operating on.
*
****************************************************************************/
int radio802154_getpanid(FAR struct ieee802154_radio_s *radio,
FAR uint16_t *panid)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_PANID, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_PANID failed: %d\n", ret);
}
*panid = arg.panid;
return ret;
}
/****************************************************************************
* Name: radio802154_setsaddr
*
* Description:
* Define the device short address. The following addresses are special:
* FFFEh : Broadcast
* FFFFh : Unspecified
*
****************************************************************************/
int radio802154_setsaddr(FAR struct ieee802154_radio_s *radio,
uint16_t saddr)
{
union ieee802154_radioarg_u arg;
int ret;
arg.saddr = saddr;
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_SADDR, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_SADDR failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_getsaddr
*
* Description:
* Define the current short address the device is using.
*
****************************************************************************/
int radio802154_getsaddr(FAR struct ieee802154_radio_s *radio,
FAR uint16_t *saddr)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_SADDR, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_SADDR failed: %d\n", ret);
}
*saddr = arg.saddr;
return ret;
}
/****************************************************************************
* Name: radio802154_seteaddr
*
* Description:
* Define the device extended address. The following addresses are special:
* FFFFFFFFFFFFFFFFh : Unspecified
*
****************************************************************************/
int radio802154_seteaddr(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *eaddr)
{
union ieee802154_radioarg_u arg;
int ret;
memcpy(arg.eaddr, eaddr, EADDR_SIZE); /* REVISIT */
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_EADDR, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_EADDR failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_geteaddr
*
* Description:
* Define the current extended address the device is using.
*
****************************************************************************/
int radio802154_geteaddr(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *eaddr)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_EADDR, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_EADDR failed: %d\n", ret);
}
memcpy(eaddr, arg.eaddr, EADDR_SIZE); /* REVISIT */
return ret;
}
/****************************************************************************
* Name: radio802154_setpromisc
*
* Description:
* Set the device into promiscuous mode, e.g do not filter any incoming
* frame.
*
****************************************************************************/
int radio802154_setpromisc(FAR struct ieee802154_radio_s *radio,
bool promisc)
{
union ieee802154_radioarg_u arg;
int ret;
arg.promisc = promisc;
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_PROMISC, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_PROMISC failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_getpromisc
*
* Description:
* Get the device receive mode.
*
****************************************************************************/
int radio802154_getpromisc(FAR struct ieee802154_radio_s *radio,
FAR bool *promisc)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_PROMISC, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_PROMISC failed: %d\n", ret);
}
*promisc = arg.promisc;
return ret;
}
/****************************************************************************
* Name: radio802154_setdevmode
*
* Description:
* Define the device behaviour: normal end device or coordinator
*
****************************************************************************/
int radio802154_setdevmode(FAR struct ieee802154_radio_s *radio,
uint8_t mode)
{
union ieee802154_radioarg_u arg;
int ret;
arg.devmode = mode;
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_DEVMODE, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_DEVMODE failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_setdevmode
*
* Description:
* Return the current device mode
*
****************************************************************************/
int radio802154_getdevmode(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *mode)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_DEVMODE, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_DEVMODE failed: %d\n", ret);
}
*mode = arg.devmode;
return ret;
}
/****************************************************************************
* Name: radio802154_settxpower
*
* Description:
* Define the transmit power. Value is passed in mBm, it is rounded to
* the nearest value. Some MRF modules have a power amplifier, this routine
* does not care about this. We only change the CHIP output power.
*
****************************************************************************/
int radio802154_settxpower(FAR struct ieee802154_radio_s *radio,
int32_t txpwr)
{
union ieee802154_radioarg_u arg;
int ret;
arg.txpwr = txpwr;
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_TXPWR, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_TXPWR failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_gettxpower
*
* Description:
* Return the actual transmit power, in mBm.
*
****************************************************************************/
int radio802154_gettxpower(FAR struct ieee802154_radio_s *radio,
FAR int32_t *txpwr)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_TXPWR, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_TXPWR failed: %d\n", ret);
}
*txpwr = arg.txpwr;
return ret;
}
/****************************************************************************
* Name: radio802154_setcca
*
* Description:
* Define the Clear Channel Assessement method.
*
****************************************************************************/
int radio802154_setcca(FAR struct ieee802154_radio_s *radio,
FAR struct ieee802154_cca_s *cca)
{
union ieee802154_radioarg_u arg;
int ret;
memcpy(&arg.cca, cca, sizeof(struct ieee802154_cca_s));
ret = RADIO_IOCTL(radio, PHY802154IOC_SET_CCA, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_SET_CCA failed: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: radio802154_getcca
*
* Description:
* Return the Clear Channel Assessement method.
*
****************************************************************************/
int radio802154_getcca(FAR struct ieee802154_radio_s *radio,
FAR struct ieee802154_cca_s *cca)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_GET_CCA, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_GET_CCA failed: %d\n", ret);
}
memcpy(cca, &arg.cca, sizeof(struct ieee802154_cca_s));
return ret;
}
/****************************************************************************
* Name: radio802154_energydetect
*
* Description:
* Measure the RSSI level for the current channel.
*
****************************************************************************/
int radio802154_energydetect(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *energy)
{
union ieee802154_radioarg_u arg;
int ret;
ret = RADIO_IOCTL(radio, PHY802154IOC_ENERGYDETECT, &arg);
if (ret < 0)
{
wlerr("ERROR: PHY802154IOC_ENERGYDETECT failed: %d\n", ret);
}
*energy = arg.energy;
return ret;
}
-255
View File
@@ -1,255 +0,0 @@
/****************************************************************************
* wireless/ieee802154/radio802154_ioctl.h
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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_RADIO802154_IOCTL_H
#define __WIRELESS_IEEE802154_RADIO802154_IOCTL_H 1
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "radio802154_ioctl.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: radio802154_setchannel
*
* Description:
* Define the current radio channel the device is operating on.
* In the 2.4 GHz, there are 16 channels, each 2 MHz wide, 5 MHz spacing:
* Chan MHz Chan MHz Chan MHz Chan MHz
* 11 2405 15 2425 19 2445 23 2465
* 12 2410 16 2430 20 2450 24 2470
* 13 2415 17 2435 21 2455 25 2475
* 14 2420 18 2440 22 2460 26 2480
*
****************************************************************************/
int radio802154_setchannel(FAR struct ieee802154_radio_s *radio,
uint8_t chan);
/****************************************************************************
* Name: radio802154_getchannel
*
* Description:
* Define the current radio channel the device is operating on.
*
****************************************************************************/
int radio802154_getchannel(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *chan);
/****************************************************************************
* Name: radio802154_setpanid
*
* Description:
* Define the PAN ID the device is operating on.
*
****************************************************************************/
int radio802154_setpanid(FAR struct ieee802154_radio_s *radio,
uint16_t panid);
/****************************************************************************
* Name: radio802154_getpanid
*
* Description:
* Define the current PAN ID the device is operating on.
*
****************************************************************************/
int radio802154_getpanid(FAR struct ieee802154_radio_s *radio,
FAR uint16_t *panid);
/****************************************************************************
* Name: radio802154_setsaddr
*
* Description:
* Define the device short address. The following addresses are special:
* FFFEh : Broadcast
* FFFFh : Unspecified
*
****************************************************************************/
int radio802154_setsaddr(FAR struct ieee802154_radio_s *radio,
uint16_t saddr);
/****************************************************************************
* Name: radio802154_getsaddr
*
* Description:
* Define the current short address the device is using.
*
****************************************************************************/
int radio802154_getsaddr(FAR struct ieee802154_radio_s *radio,
FAR uint16_t *saddr);
/****************************************************************************
* Name: radio802154_seteaddr
*
* Description:
* Define the device extended address. The following addresses are special:
* FFFFFFFFFFFFFFFFh : Unspecified
*
****************************************************************************/
int radio802154_seteaddr(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *eaddr);
/****************************************************************************
* Name: radio802154_geteaddr
*
* Description:
* Define the current extended address the device is using.
*
****************************************************************************/
int radio802154_geteaddr(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *eaddr);
/****************************************************************************
* Name: radio802154_setpromisc
*
* Description:
* Set the device into promiscuous mode, e.g do not filter any incoming
* frame.
*
****************************************************************************/
int radio802154_setpromisc(FAR struct ieee802154_radio_s *radio,
bool promisc);
/****************************************************************************
* Name: radio802154_getpromisc
*
* Description:
* Get the device receive mode.
*
****************************************************************************/
int radio802154_getpromisc(FAR struct ieee802154_radio_s *radio,
FAR bool *promisc);
/****************************************************************************
* Name: radio802154_setdevmode
*
* Description:
* Define the device behaviour: normal end device or coordinator
*
****************************************************************************/
int radio802154_setdevmode(FAR struct ieee802154_radio_s *radio,
uint8_t mode);
/****************************************************************************
* Name: radio802154_setdevmode
*
* Description:
* Return the current device mode
*
****************************************************************************/
int radio802154_getdevmode(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *mode);
/****************************************************************************
* Name: radio802154_settxpower
*
* Description:
* Define the transmit power. Value is passed in mBm, it is rounded to
* the nearest value. Some MRF modules have a power amplifier, this routine
* does not care about this. We only change the CHIP output power.
*
****************************************************************************/
int radio802154_settxpower(FAR struct ieee802154_radio_s *radio,
int32_t txpwr);
/****************************************************************************
* Name: radio802154_gettxpower
*
* Description:
* Return the actual transmit power, in mBm.
*
****************************************************************************/
int radio802154_gettxpower(FAR struct ieee802154_radio_s *radio,
FAR int32_t *txpwr);
/****************************************************************************
* Name: radio802154_setcca
*
* Description:
* Define the Clear Channel Assessement method.
*
****************************************************************************/
int radio802154_setcca(FAR struct ieee802154_radio_s *radio,
FAR struct ieee802154_cca_s *cca);
/****************************************************************************
* Name: radio802154_getcca
*
* Description:
* Return the Clear Channel Assessement method.
*
****************************************************************************/
int radio802154_getcca(FAR struct ieee802154_radio_s *radio,
FAR struct ieee802154_cca_s *cca);
/****************************************************************************
* Name: radio802154_energydetect
*
* Description:
* Measure the RSSI level for the current channel.
*
****************************************************************************/
int radio802154_energydetect(FAR struct ieee802154_radio_s *radio,
FAR uint8_t *energy);
#endif /* __WIRELESS_IEEE802154_RADIO802154_IOCTL_H */