mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
wireless/ieee802154: Removes radio IOCTL. Starts bringing radio and MAC closer with well-defined interface.
This commit is contained in:
@@ -47,7 +47,6 @@
|
|||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
#include <nuttx/wireless/ieee802154/mrf24j40.h>
|
#include <nuttx/wireless/ieee802154/mrf24j40.h>
|
||||||
|
|
||||||
@@ -84,8 +83,6 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RADIO_DEVNAME "/dev/mrf24j40"
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -287,18 +284,7 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#elif defined(CONFIG_IEEE802154_DEV)
|
|
||||||
/* Register a character driver to access the IEEE 802.15.4 radio from
|
|
||||||
* user-space
|
|
||||||
*/
|
|
||||||
|
|
||||||
ret = radio802154dev_register(radio, RADIO_DEVNAME);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
wlerr("ERROR: Failed to register the radio device %s: %d\n",
|
|
||||||
RADIO_DEVNAME, ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_IEEE802154_MAC */
|
#endif /* CONFIG_IEEE802154_MAC */
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ static void at86rf23x_irqwork_tx(FAR struct at86rf23x_dev_s *dev);
|
|||||||
static void at86rf23x_irqworker(FAR void *arg);
|
static void at86rf23x_irqworker(FAR void *arg);
|
||||||
static int at86rf23x_interrupt(int irq, FAR void *context, FAR void *arg);
|
static int at86rf23x_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||||
|
|
||||||
/* IOCTL helpers */
|
|
||||||
|
|
||||||
static int at86rf23x_setchannel(FAR struct ieee802154_radio_s *ieee,
|
static int at86rf23x_setchannel(FAR struct ieee802154_radio_s *ieee,
|
||||||
uint8_t chan);
|
uint8_t chan);
|
||||||
@@ -187,8 +186,6 @@ static int at86rf23x_energydetect(FAR struct ieee802154_radio_s *ieee,
|
|||||||
|
|
||||||
/* Driver operations */
|
/* Driver operations */
|
||||||
|
|
||||||
static int at86rf23x_ioctl(FAR struct ieee802154_radio_s *ieee, int cmd,
|
|
||||||
unsigned long arg);
|
|
||||||
static int at86rf23x_rxenable(FAR struct ieee802154_radio_s *ieee,
|
static int at86rf23x_rxenable(FAR struct ieee802154_radio_s *ieee,
|
||||||
bool state, FAR struct ieee802154_packet_s *packet);
|
bool state, FAR struct ieee802154_packet_s *packet);
|
||||||
static int at86rf23x_transmit(FAR struct ieee802154_radio_s *ieee,
|
static int at86rf23x_transmit(FAR struct ieee802154_radio_s *ieee,
|
||||||
@@ -1147,100 +1144,6 @@ static int at86rf23x_energydetect(FAR struct ieee802154_radio_s *ieee,
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: at86rf23x_ioctl
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Control operations for the radio.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int at86rf23x_ioctl(FAR struct ieee802154_radio_s *ieee, int cmd,
|
|
||||||
unsigned long arg)
|
|
||||||
{
|
|
||||||
FAR struct at86rf23x_dev_s *dev =
|
|
||||||
(FAR struct at86rf23x_dev_s *)ieee;
|
|
||||||
FAR union ieee802154_radioarg_u *u; =
|
|
||||||
(FAR union ieee802154_radioarg_u *)((uintptr_t)arg)
|
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case PHY802154IOC_SET_CHAN:
|
|
||||||
ret = at86rf23x_setchannel(ieee, u.channel);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_CHAN:
|
|
||||||
ret = at86rf23x_getchannel(ieee, &u.channel);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_PANID:
|
|
||||||
ret = at86rf23x_setpanid(ieee, u.panid);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_PANID:
|
|
||||||
ret = at86rf23x_getpanid(ieee, &u.panid);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_SADDR:
|
|
||||||
ret = at86rf23x_setsaddr(ieee, u.saddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_SADDR:
|
|
||||||
ret = at86rf23x_getsaddr(ieee, &u.saddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_EADDR:
|
|
||||||
ret = at86rf23x_seteaddr(ieee, u.eaddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_EADDR:
|
|
||||||
ret = at86rf23x_geteaddr(ieee, u.eaddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_PROMISC:
|
|
||||||
ret = at86rf23x_setpromisc(ieee, u.promisc);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_PROMISC:
|
|
||||||
ret = at86rf23x_getpromisc(ieee, &u.promisc);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_DEVMODE:
|
|
||||||
ret = at86rf23x_setdevmode(ieee, u.devmode);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_DEVMODE:
|
|
||||||
ret = at86rf23x_getdevmode(ieee, &u.devmode);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_TXPWR:
|
|
||||||
ret = at86rf23x_settxpower(ieee, u.txpwr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_TXPWR:
|
|
||||||
ret = at86rf23x_gettxpower(ieee, &u.txpwr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_CCA:
|
|
||||||
ret = at86rf23x_setcca(ieee, &u.cca);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_CCA:
|
|
||||||
ret = at86rf23x_getcca(ieee, &u.cca);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_ENERGYDETECT:
|
|
||||||
ret = at86rf23x_energydetect(ieee, &u.energy);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1000:
|
|
||||||
return at86rf23x_regdump(dev);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return -ENOTTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: at86rf23x_initialize
|
* Name: at86rf23x_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* drivers/wireless/ieee802154/mrf24j40.c
|
* drivers/wireless/ieee802154/mrf24j40.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015-2016 Sebastien Lorquet. All rights reserved.
|
* Copyright (C) 2015-2016 Sebastien Lorquet. All rights reserved.
|
||||||
|
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||||
*
|
*
|
||||||
@@ -90,6 +91,10 @@
|
|||||||
#define MRF24J40_RXMODE_PROMISC 1
|
#define MRF24J40_RXMODE_PROMISC 1
|
||||||
#define MRF24J40_RXMODE_NOCRC 2
|
#define MRF24J40_RXMODE_NOCRC 2
|
||||||
|
|
||||||
|
#define MRF24J40_MODE_DEVICE 0
|
||||||
|
#define MRF24J40_MODE_COORD 1
|
||||||
|
#define MRF24J40_MODE_PANCOORD 2
|
||||||
|
|
||||||
/* Definitions for PA control on high power modules */
|
/* Definitions for PA control on high power modules */
|
||||||
|
|
||||||
#define MRF24J40_PA_AUTO 1
|
#define MRF24J40_PA_AUTO 1
|
||||||
@@ -125,9 +130,8 @@ struct mrf24j40_radio_s
|
|||||||
struct work_s pollwork; /* For deferring poll work to the work queue */
|
struct work_s pollwork; /* For deferring poll work to the work queue */
|
||||||
sem_t exclsem; /* Exclusive access to this struct */
|
sem_t exclsem; /* Exclusive access to this struct */
|
||||||
|
|
||||||
uint16_t panid; /* PAN identifier, FFFF = not set */
|
struct ieee802154_addr_s addr;
|
||||||
uint16_t saddr; /* short address, FFFF = not set */
|
|
||||||
uint8_t eaddr[8]; /* extended address, FFFFFFFFFFFFFFFF = not set */
|
|
||||||
uint8_t channel; /* 11 to 26 for the 2.4 GHz band */
|
uint8_t channel; /* 11 to 26 for the 2.4 GHz band */
|
||||||
uint8_t devmode; /* device mode: device, coord, pancoord */
|
uint8_t devmode; /* device mode: device, coord, pancoord */
|
||||||
uint8_t paenabled; /* enable usage of PA */
|
uint8_t paenabled; /* enable usage of PA */
|
||||||
@@ -181,7 +185,6 @@ static int mrf24j40_gts_setup(FAR struct mrf24j40_radio_s *dev, uint8_t gts,
|
|||||||
static int mrf24j40_setup_fifo(FAR struct mrf24j40_radio_s *dev,
|
static int mrf24j40_setup_fifo(FAR struct mrf24j40_radio_s *dev,
|
||||||
FAR struct iob_s *frame, uint32_t fifo_addr);
|
FAR struct iob_s *frame, uint32_t fifo_addr);
|
||||||
|
|
||||||
/* IOCTL helpers */
|
|
||||||
|
|
||||||
static int mrf24j40_setchannel(FAR struct mrf24j40_radio_s *radio,
|
static int mrf24j40_setchannel(FAR struct mrf24j40_radio_s *radio,
|
||||||
uint8_t chan);
|
uint8_t chan);
|
||||||
@@ -196,7 +199,7 @@ static int mrf24j40_setsaddr(FAR struct mrf24j40_radio_s *radio,
|
|||||||
static int mrf24j40_getsaddr(FAR struct mrf24j40_radio_s *radio,
|
static int mrf24j40_getsaddr(FAR struct mrf24j40_radio_s *radio,
|
||||||
FAR uint16_t *saddr);
|
FAR uint16_t *saddr);
|
||||||
static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *radio,
|
static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *radio,
|
||||||
FAR uint8_t *eaddr);
|
FAR const uint8_t *eaddr);
|
||||||
static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *radio,
|
static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *radio,
|
||||||
FAR uint8_t *eaddr);
|
FAR uint8_t *eaddr);
|
||||||
static int mrf24j40_setpromisc(FAR struct mrf24j40_radio_s *radio,
|
static int mrf24j40_setpromisc(FAR struct mrf24j40_radio_s *radio,
|
||||||
@@ -222,11 +225,14 @@ static int mrf24j40_energydetect(FAR struct mrf24j40_radio_s *radio,
|
|||||||
|
|
||||||
static int mrf24j40_bind(FAR struct ieee802154_radio_s *radio,
|
static int mrf24j40_bind(FAR struct ieee802154_radio_s *radio,
|
||||||
FAR struct ieee802154_radiocb_s *radiocb);
|
FAR struct ieee802154_radiocb_s *radiocb);
|
||||||
static int mrf24j40_ioctl(FAR struct ieee802154_radio_s *radio, int cmd,
|
|
||||||
unsigned long arg);
|
|
||||||
static int mrf24j40_rxenable(FAR struct ieee802154_radio_s *radio bool enable);
|
|
||||||
static int mrf24j40_txnotify_csma(FAR struct ieee802154_radio_s *radio);
|
static int mrf24j40_txnotify_csma(FAR struct ieee802154_radio_s *radio);
|
||||||
static int mrf24j40_txnotify_gts(FAR struct ieee802154_radio_s *radio);
|
static int mrf24j40_txnotify_gts(FAR struct ieee802154_radio_s *radio);
|
||||||
|
static int mrf24j40_get_attr(FAR struct ieee802154_radio_s *radio,
|
||||||
|
enum ieee802154_pib_attr_e pib_attr,
|
||||||
|
FAR union ieee802154_attr_val_u *attr_value);
|
||||||
|
static int mrf24j40_set_attr(FAR struct ieee802154_radio_s *radio,
|
||||||
|
enum ieee802154_pib_attr_e pib_attr,
|
||||||
|
FAR const union ieee802154_attr_val_u *attr_value);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@@ -242,14 +248,14 @@ static int mrf24j40_txnotify_gts(FAR struct ieee802154_radio_s *radio);
|
|||||||
static const struct ieee802154_radioops_s mrf24j40_devops =
|
static const struct ieee802154_radioops_s mrf24j40_devops =
|
||||||
{
|
{
|
||||||
mrf24j40_bind,
|
mrf24j40_bind,
|
||||||
mrf24j40_ioctl,
|
|
||||||
mrf24j40_rxenable,
|
|
||||||
mrf24j40_txnotify_csma,
|
mrf24j40_txnotify_csma,
|
||||||
mrf24j40_txnotify_gts,
|
mrf24j40_txnotify_gts,
|
||||||
|
mrf24j40_get_attr,
|
||||||
|
mrf24j40_set_attr
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Radio Interface Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mrf24j40_bind(FAR struct ieee802154_radio_s *radio,
|
static int mrf24j40_bind(FAR struct ieee802154_radio_s *radio,
|
||||||
@@ -299,6 +305,103 @@ static int mrf24j40_txnotify_csma(FAR struct ieee802154_radio_s *radio)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: mrf24j40_txnotify_gts
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Driver callback invoked when new TX data is available. This is a
|
||||||
|
* stimulus perform an out-of-cycle poll and, thereby, reduce the TX
|
||||||
|
* latency.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* radio - Reference to the radio driver state structure
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int mrf24j40_txnotify_gts(FAR struct ieee802154_radio_s *radio)
|
||||||
|
{
|
||||||
|
FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio;
|
||||||
|
|
||||||
|
/* Is our single work structure available? It may not be if there are
|
||||||
|
* pending interrupt actions and we will have to ignore the Tx
|
||||||
|
* availability action.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (work_available(&dev->pollwork))
|
||||||
|
{
|
||||||
|
/* Schedule to serialize the poll on the worker thread. */
|
||||||
|
|
||||||
|
work_queue(HPWORK, &dev->pollwork, mrf24j40_dopoll_gts, dev, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mrf24j40_get_attr(FAR struct ieee802154_radio_s *radio,
|
||||||
|
enum ieee802154_pib_attr_e pib_attr,
|
||||||
|
FAR union ieee802154_attr_val_u *attr_value)
|
||||||
|
{
|
||||||
|
FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
switch (pib_attr)
|
||||||
|
{
|
||||||
|
case IEEE802154_PIB_MAC_EXTENDED_ADDR:
|
||||||
|
{
|
||||||
|
memcpy(&attr_value->mac.eaddr[0], &dev->addr.eaddr[0], 8);
|
||||||
|
ret = IEEE802154_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = IEEE802154_STATUS_UNSUPPORTED_ATTRIBUTE;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mrf24j40_set_attr(FAR struct ieee802154_radio_s *radio,
|
||||||
|
enum ieee802154_pib_attr_e pib_attr,
|
||||||
|
FAR const union ieee802154_attr_val_u *attr_value)
|
||||||
|
{
|
||||||
|
FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
switch (pib_attr)
|
||||||
|
{
|
||||||
|
case IEEE802154_PIB_MAC_EXTENDED_ADDR:
|
||||||
|
{
|
||||||
|
mrf24j40_seteaddr(dev, &attr_value->mac.eaddr[0]);
|
||||||
|
ret = IEEE802154_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IEEE802154_PIB_MAC_PROMISCUOUS_MODE:
|
||||||
|
{
|
||||||
|
if (attr_value->mac.promisc_mode)
|
||||||
|
{
|
||||||
|
mrf24j40_setrxmode(dev, MRF24J40_RXMODE_PROMISC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mrf24j40_setrxmode(dev, MRF24J40_RXMODE_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = IEEE802154_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = IEEE802154_STATUS_UNSUPPORTED_ATTRIBUTE;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Internal Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: mrf24j40_dopoll_csma
|
* Function: mrf24j40_dopoll_csma
|
||||||
*
|
*
|
||||||
@@ -353,43 +456,6 @@ static void mrf24j40_dopoll_csma(FAR void *arg)
|
|||||||
sem_post(&dev->exclsem);
|
sem_post(&dev->exclsem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Function: mrf24j40_txnotify_gts
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Driver callback invoked when new TX data is available. This is a
|
|
||||||
* stimulus perform an out-of-cycle poll and, thereby, reduce the TX
|
|
||||||
* latency.
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* radio - Reference to the radio driver state structure
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int mrf24j40_txnotify_gts(FAR struct ieee802154_radio_s *radio)
|
|
||||||
{
|
|
||||||
FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio;
|
|
||||||
|
|
||||||
/* Is our single work structure available? It may not be if there are
|
|
||||||
* pending interrupt actions and we will have to ignore the Tx
|
|
||||||
* availability action.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (work_available(&dev->pollwork))
|
|
||||||
{
|
|
||||||
/* Schedule to serialize the poll on the worker thread. */
|
|
||||||
|
|
||||||
work_queue(HPWORK, &dev->pollwork, mrf24j40_dopoll_gts, dev, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: mrf24j40_dopoll_gts
|
* Function: mrf24j40_dopoll_gts
|
||||||
*
|
*
|
||||||
@@ -772,7 +838,7 @@ static int mrf24j40_setpanid(FAR struct mrf24j40_radio_s *dev,
|
|||||||
mrf24j40_setreg(dev->spi, MRF24J40_PANIDH, (uint8_t)(panid>>8));
|
mrf24j40_setreg(dev->spi, MRF24J40_PANIDH, (uint8_t)(panid>>8));
|
||||||
mrf24j40_setreg(dev->spi, MRF24J40_PANIDL, (uint8_t)(panid&0xFF));
|
mrf24j40_setreg(dev->spi, MRF24J40_PANIDL, (uint8_t)(panid&0xFF));
|
||||||
|
|
||||||
dev->panid = panid;
|
dev->addr.panid = panid;
|
||||||
wlinfo("%04X\n", (unsigned)panid);
|
wlinfo("%04X\n", (unsigned)panid);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -789,7 +855,7 @@ static int mrf24j40_setpanid(FAR struct mrf24j40_radio_s *dev,
|
|||||||
static int mrf24j40_getpanid(FAR struct mrf24j40_radio_s *dev,
|
static int mrf24j40_getpanid(FAR struct mrf24j40_radio_s *dev,
|
||||||
FAR uint16_t *panid)
|
FAR uint16_t *panid)
|
||||||
{
|
{
|
||||||
*panid = dev->panid;
|
*panid = dev->addr.panid;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -810,7 +876,7 @@ static int mrf24j40_setsaddr(FAR struct mrf24j40_radio_s *dev,
|
|||||||
mrf24j40_setreg(dev->spi, MRF24J40_SADRH, (uint8_t)(saddr>>8));
|
mrf24j40_setreg(dev->spi, MRF24J40_SADRH, (uint8_t)(saddr>>8));
|
||||||
mrf24j40_setreg(dev->spi, MRF24J40_SADRL, (uint8_t)(saddr&0xFF));
|
mrf24j40_setreg(dev->spi, MRF24J40_SADRL, (uint8_t)(saddr&0xFF));
|
||||||
|
|
||||||
dev->saddr = saddr;
|
dev->addr.saddr = saddr;
|
||||||
wlinfo("%04X\n", (unsigned)saddr);
|
wlinfo("%04X\n", (unsigned)saddr);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -826,7 +892,7 @@ static int mrf24j40_setsaddr(FAR struct mrf24j40_radio_s *dev,
|
|||||||
static int mrf24j40_getsaddr(FAR struct mrf24j40_radio_s *dev,
|
static int mrf24j40_getsaddr(FAR struct mrf24j40_radio_s *dev,
|
||||||
FAR uint16_t *saddr)
|
FAR uint16_t *saddr)
|
||||||
{
|
{
|
||||||
*saddr = dev->saddr;
|
*saddr = dev->addr.saddr;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -841,14 +907,14 @@ static int mrf24j40_getsaddr(FAR struct mrf24j40_radio_s *dev,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *dev,
|
static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *dev,
|
||||||
FAR uint8_t *eaddr)
|
FAR const uint8_t *eaddr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
mrf24j40_setreg(dev->spi, MRF24J40_EADR0 + i, eaddr[i]);
|
mrf24j40_setreg(dev->spi, MRF24J40_EADR0 + i, eaddr[i]);
|
||||||
dev->eaddr[i] = eaddr[i];
|
dev->addr.eaddr[i] = eaddr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -865,39 +931,7 @@ static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *dev,
|
|||||||
static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *dev,
|
static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *dev,
|
||||||
FAR uint8_t *eaddr)
|
FAR uint8_t *eaddr)
|
||||||
{
|
{
|
||||||
memcpy(eaddr, dev->eaddr, 8);
|
memcpy(eaddr, dev->addr.eaddr, 8);
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mrf24j40_setpromisc
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set the device into promiscuous mode, e.g do not filter any incoming
|
|
||||||
* frame.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int mrf24j40_setpromisc(FAR struct mrf24j40_radio_s *dev,
|
|
||||||
bool promisc)
|
|
||||||
{
|
|
||||||
return mrf24j40_setrxmode(dev, promisc ? MRF24J40_RXMODE_PROMISC :
|
|
||||||
MRF24J40_RXMODE_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mrf24j40_getpromisc
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the device receive mode.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int mrf24j40_getpromisc(FAR struct mrf24j40_radio_s *dev,
|
|
||||||
FAR bool *promisc)
|
|
||||||
{
|
|
||||||
*promisc = (dev->rxmode == MRF24J40_RXMODE_PROMISC);
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -927,17 +961,17 @@ static int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev,
|
|||||||
|
|
||||||
reg = mrf24j40_getreg(dev->spi, MRF24J40_RXMCR);
|
reg = mrf24j40_getreg(dev->spi, MRF24J40_RXMCR);
|
||||||
|
|
||||||
if (mode == IEEE802154_MODE_PANCOORD)
|
if (mode == MRF24J40_MODE_PANCOORD)
|
||||||
{
|
{
|
||||||
reg |= MRF24J40_RXMCR_PANCOORD;
|
reg |= MRF24J40_RXMCR_PANCOORD;
|
||||||
reg &= ~MRF24J40_RXMCR_COORD;
|
reg &= ~MRF24J40_RXMCR_COORD;
|
||||||
}
|
}
|
||||||
else if (mode == IEEE802154_MODE_COORD)
|
else if (mode == MRF24J40_MODE_COORD)
|
||||||
{
|
{
|
||||||
reg |= MRF24J40_RXMCR_COORD;
|
reg |= MRF24J40_RXMCR_COORD;
|
||||||
reg &= ~MRF24J40_RXMCR_PANCOORD;
|
reg &= ~MRF24J40_RXMCR_PANCOORD;
|
||||||
}
|
}
|
||||||
else if (mode == IEEE802154_MODE_DEVICE)
|
else if (mode == MRF24J40_MODE_DEVICE)
|
||||||
{
|
{
|
||||||
reg &= ~MRF24J40_RXMCR_PANCOORD;
|
reg &= ~MRF24J40_RXMCR_PANCOORD;
|
||||||
reg &= ~MRF24J40_RXMCR_COORD;
|
reg &= ~MRF24J40_RXMCR_COORD;
|
||||||
@@ -1175,106 +1209,6 @@ static int mrf24j40_regdump(FAR struct mrf24j40_radio_s *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mrf24j40_ioctl
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Misc/unofficial device controls.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int mrf24j40_ioctl(FAR struct ieee802154_radio_s *radio, int cmd,
|
|
||||||
unsigned long arg)
|
|
||||||
{
|
|
||||||
FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio;
|
|
||||||
FAR union ieee802154_radioarg_u *u =
|
|
||||||
(FAR union ieee802154_radioarg_u *)((uintptr_t)arg);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
switch(cmd)
|
|
||||||
{
|
|
||||||
case PHY802154IOC_SET_CHAN:
|
|
||||||
ret = mrf24j40_setchannel(dev, u->channel);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_CHAN:
|
|
||||||
ret = mrf24j40_getchannel(dev, &u->channel);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_PANID:
|
|
||||||
ret = mrf24j40_setpanid(dev, u->panid);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_PANID:
|
|
||||||
ret = mrf24j40_getpanid(dev, &u->panid);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_SADDR:
|
|
||||||
ret = mrf24j40_setsaddr(dev, u->saddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_SADDR:
|
|
||||||
ret = mrf24j40_getsaddr(dev, &u->saddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_EADDR:
|
|
||||||
ret = mrf24j40_seteaddr(dev, u->eaddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_EADDR:
|
|
||||||
ret = mrf24j40_geteaddr(dev, u->eaddr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_PROMISC:
|
|
||||||
ret = mrf24j40_setpromisc(dev, u->promisc);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_PROMISC:
|
|
||||||
ret = mrf24j40_getpromisc(dev, &u->promisc);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_DEVMODE:
|
|
||||||
ret = mrf24j40_setdevmode(dev, u->devmode);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_DEVMODE:
|
|
||||||
ret = mrf24j40_getdevmode(dev, &u->devmode);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_TXPWR:
|
|
||||||
ret = mrf24j40_settxpower(dev, u->txpwr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_TXPWR:
|
|
||||||
ret = mrf24j40_gettxpower(dev, &u->txpwr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_SET_CCA:
|
|
||||||
ret = mrf24j40_setcca(dev, &u->cca);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_GET_CCA:
|
|
||||||
ret = mrf24j40_getcca(dev, &u->cca);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PHY802154IOC_ENERGYDETECT:
|
|
||||||
ret = mrf24j40_energydetect(dev, &u->energy);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1000:
|
|
||||||
return mrf24j40_regdump(dev);
|
|
||||||
|
|
||||||
case 1001: dev->paenabled = (uint8_t)arg;
|
|
||||||
wlinfo("PA %sabled\n", arg ? "en" : "dis");
|
|
||||||
return OK;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return -ENOTTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mrf24j40_energydetect
|
* Name: mrf24j40_energydetect
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -89,7 +89,6 @@
|
|||||||
#define _CLIOCBASE (0x2400) /* Contactless modules ioctl commands */
|
#define _CLIOCBASE (0x2400) /* Contactless modules ioctl commands */
|
||||||
#define _USBCBASE (0x2500) /* USB-C controller ioctl commands */
|
#define _USBCBASE (0x2500) /* USB-C controller ioctl commands */
|
||||||
#define _MAC802154BASE (0x2600) /* 802.15.4 MAC ioctl commands */
|
#define _MAC802154BASE (0x2600) /* 802.15.4 MAC ioctl commands */
|
||||||
#define _PHY802154BASE (0x2700) /* 802.15.4 Radio ioctl commands */
|
|
||||||
|
|
||||||
/* boardctl() commands share the same number space */
|
/* boardctl() commands share the same number space */
|
||||||
|
|
||||||
@@ -429,12 +428,6 @@
|
|||||||
#define _MAC802154IOCVALID(c) (_IOC_TYPE(c)==_MAC802154BASE)
|
#define _MAC802154IOCVALID(c) (_IOC_TYPE(c)==_MAC802154BASE)
|
||||||
#define _MAC802154IOC(nr) _IOC(_MAC802154BASE,nr)
|
#define _MAC802154IOC(nr) _IOC(_MAC802154BASE,nr)
|
||||||
|
|
||||||
/* 802.15.4 Radio driver ioctl definitions **********************************/
|
|
||||||
/* (see nuttx/ieee802154/wireless/ieee802154_radio.h */
|
|
||||||
|
|
||||||
#define _PHY802154IOCVALID(c) (_IOC_TYPE(c)==_PHY802154BASE)
|
|
||||||
#define _PHY802154IOC(nr) _IOC(_PHY802154BASE,nr)
|
|
||||||
|
|
||||||
/* boardctl() command definitions *******************************************/
|
/* boardctl() command definitions *******************************************/
|
||||||
|
|
||||||
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)
|
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)
|
||||||
|
|||||||
@@ -55,8 +55,6 @@
|
|||||||
# include <net/if.h>
|
# include <net/if.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
|
||||||
|
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -331,6 +329,8 @@ enum ieee802154_pib_attr_e
|
|||||||
IEEE802154_PIB_MAC_PANCOORD_SHORT_ADDR,
|
IEEE802154_PIB_MAC_PANCOORD_SHORT_ADDR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define IEEE802154_EADDR_LEN 8
|
||||||
|
|
||||||
/* IEEE 802.15.4 Device address
|
/* IEEE 802.15.4 Device address
|
||||||
* The addresses in ieee802154 have several formats:
|
* The addresses in ieee802154 have several formats:
|
||||||
* No address : [none]
|
* No address : [none]
|
||||||
@@ -351,9 +351,10 @@ struct ieee802154_addr_s
|
|||||||
|
|
||||||
enum ieee802154_addr_mode_e mode;
|
enum ieee802154_addr_mode_e mode;
|
||||||
|
|
||||||
uint16_t panid; /* PAN identifier, can be IEEE802154_PAN_UNSPEC */
|
uint16_t panid; /* PAN identifier, can be
|
||||||
uint16_t saddr; /* short address */
|
* IEEE802154_PAN_UNSPEC */
|
||||||
uint8_t eaddr[8]; /* extended address */
|
uint16_t saddr; /* short address */
|
||||||
|
uint8_t eaddr[IEEE802154_EADDR_LEN]; /* extended address */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IEEE802154_ADDRSTRLEN 22 /* (2*2+1+8*2, PPPP/EEEEEEEEEEEEEEEE) */
|
#define IEEE802154_ADDRSTRLEN 22 /* (2*2+1+8*2, PPPP/EEEEEEEEEEEEEEEE) */
|
||||||
@@ -454,15 +455,54 @@ struct ieee802154_pend_addr_s
|
|||||||
struct ieee802154_addr_s addr[7]; /* Array of at most 7 addresses */
|
struct ieee802154_addr_s addr[7]; /* Array of at most 7 addresses */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_IEEE802154_RANGING
|
||||||
|
#define IEEE802154_TXDESC_FIELDS \
|
||||||
|
uint8_t handle; \
|
||||||
|
uint32_t timestamp; \
|
||||||
|
uint8_t status;
|
||||||
|
#else
|
||||||
|
#define IEEE802154_TXDESC_FIELDS \
|
||||||
|
uint8_t handle; \
|
||||||
|
uint32_t timestamp; \
|
||||||
|
uint8_t status;
|
||||||
|
bool rng_rcvd; \
|
||||||
|
uint32_t rng_counter_start; \
|
||||||
|
uint32_t rng_counter_stop; \
|
||||||
|
uint32_t rng_tracking_interval; \
|
||||||
|
uint32_t rng_offset;\
|
||||||
|
uint8_t rng_fom;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct ieee802154_txdesc_s
|
||||||
|
{
|
||||||
|
IEEE802154_TXDESC_FIELDS
|
||||||
|
|
||||||
|
/* TODO: Add slotting information for GTS transactions */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ieee802154_rxdesc_s
|
||||||
|
{
|
||||||
|
uint8_t lqi;
|
||||||
|
uint8_t rssi;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ieee802154_cca_s
|
||||||
|
{
|
||||||
|
uint8_t use_ed : 1; /* CCA using ED */
|
||||||
|
uint8_t use_cs : 1; /* CCA using carrier sense */
|
||||||
|
uint8_t edth; /* Energy detection threshold for CCA */
|
||||||
|
uint8_t csth; /* Carrier sense threshold for CCA */
|
||||||
|
};
|
||||||
|
|
||||||
/* Primitive Support Types ***************************************************/
|
/* Primitive Support Types ***************************************************/
|
||||||
|
|
||||||
union ieee802154_attr_val_u
|
union ieee802154_macattr_u
|
||||||
{
|
{
|
||||||
uint8_t eaddr[8];
|
uint8_t eaddr[IEEE802154_EADDR_LEN];
|
||||||
uint16_t saddr;
|
uint16_t saddr;
|
||||||
uint16_t pan_id;
|
uint16_t panid;
|
||||||
|
|
||||||
uint8_t coord_eaddr[8];
|
uint8_t coord_eaddr[IEEE802154_EADDR_LEN];
|
||||||
uint16_t coord_saddr;
|
uint16_t coord_saddr;
|
||||||
|
|
||||||
bool is_assoc;
|
bool is_assoc;
|
||||||
@@ -503,6 +543,25 @@ union ieee802154_attr_val_u
|
|||||||
uint8_t dsn;
|
uint8_t dsn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
union ieee802154_phyattr_u
|
||||||
|
{
|
||||||
|
uint8_t channel;
|
||||||
|
int32_t txpwr
|
||||||
|
/* TODO: Fill this out as we implement supported get/set commands */
|
||||||
|
};
|
||||||
|
|
||||||
|
union ieee802154_secattr_u
|
||||||
|
{
|
||||||
|
/* TODO: Fill this out as we implement supported get/set commands */
|
||||||
|
};
|
||||||
|
|
||||||
|
union ieee802154_attr_val_u
|
||||||
|
{
|
||||||
|
union ieee802154_macattr_u mac;
|
||||||
|
union ieee802154_phyattr_u phy;
|
||||||
|
union ieee802154_secattr_u sec;
|
||||||
|
};
|
||||||
|
|
||||||
struct ieee802154_gts_info_s
|
struct ieee802154_gts_info_s
|
||||||
{
|
{
|
||||||
uint8_t length : 4; /* Number of SF slots for GTS */
|
uint8_t length : 4; /* Number of SF slots for GTS */
|
||||||
@@ -884,20 +943,6 @@ struct ieee802154_commstatus_ind_s
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* Primitive: MLME-GET.request
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Requests information about a given PIB attribute.
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
struct ieee802154_get_req_s
|
|
||||||
{
|
|
||||||
enum ieee802154_pib_attr_e pib_attr;
|
|
||||||
FAR union ieee802154_attr_val_u *attr_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Primitive: MLME-GTS.request
|
* Primitive: MLME-GTS.request
|
||||||
*
|
*
|
||||||
@@ -1092,6 +1137,20 @@ struct ieee802154_scan_conf_s
|
|||||||
#warning Figure out how to handle missing primitive semantics. See standard.
|
#warning Figure out how to handle missing primitive semantics. See standard.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Primitive: MLME-GET.request
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Requests information about a given PIB attribute.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
struct ieee802154_get_req_s
|
||||||
|
{
|
||||||
|
enum ieee802154_pib_attr_e pib_attr;
|
||||||
|
union ieee802154_attr_val_u attr_value;
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Primitive: MLME-SET.request
|
* Primitive: MLME-SET.request
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -48,150 +48,18 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#ifdef CONFIG_NET_6LOWPAN
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
# include <net/if.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <nuttx/fs/ioctl.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-Processor Definitions
|
* Pre-Processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Configuration ************************************************************/
|
|
||||||
|
|
||||||
/* IEEE 802.15.4 Radio Interface **********************************************/
|
|
||||||
|
|
||||||
/* This layer only knows radio frames. There are no 802.15.4 specific bits
|
|
||||||
* at this layer. */
|
|
||||||
|
|
||||||
/* Device modes */
|
|
||||||
|
|
||||||
#define IEEE802154_MODE_DEVICE 0x00
|
|
||||||
#define IEEE802154_MODE_COORD 0x01 /* avail in mrf24j40, but why? */
|
|
||||||
#define IEEE802154_MODE_PANCOORD 0x02
|
|
||||||
|
|
||||||
/* IEEE 802.15.4 Radio Character Driver IOCTL ********************************/
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_CHAN _PHY802154IOC(0x0001)
|
|
||||||
#define PHY802154IOC_GET_CHAN _PHY802154IOC(0x0002)
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_PANID _PHY802154IOC(0x0003)
|
|
||||||
#define PHY802154IOC_GET_PANID _PHY802154IOC(0x0004)
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_SADDR _PHY802154IOC(0x0005)
|
|
||||||
#define PHY802154IOC_GET_SADDR _PHY802154IOC(0x0006)
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_EADDR _PHY802154IOC(0x0007)
|
|
||||||
#define PHY802154IOC_GET_EADDR _PHY802154IOC(0x0008)
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_PROMISC _PHY802154IOC(0x0009)
|
|
||||||
#define PHY802154IOC_GET_PROMISC _PHY802154IOC(0x000A)
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_DEVMODE _PHY802154IOC(0x000B)
|
|
||||||
#define PHY802154IOC_GET_DEVMODE _PHY802154IOC(0x000C)
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_TXPWR _PHY802154IOC(0x000D)
|
|
||||||
#define PHY802154IOC_GET_TXPWR _PHY802154IOC(0x000E)
|
|
||||||
|
|
||||||
#define PHY802154IOC_SET_CCA _PHY802154IOC(0x000F)
|
|
||||||
#define PHY802154IOC_GET_CCA _PHY802154IOC(0x0010)
|
|
||||||
|
|
||||||
#define PHY802154IOC_ENERGYDETECT _PHY802154IOC(0x0011)
|
|
||||||
|
|
||||||
#define EADDR_SIZE 8 /* Extended address size */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Structures used with IEEE802.15.4 radio interface operations *************/
|
|
||||||
|
|
||||||
struct ieee802154_cca_s
|
|
||||||
{
|
|
||||||
uint8_t use_ed : 1; /* CCA using ED */
|
|
||||||
uint8_t use_cs : 1; /* CCA using carrier sense */
|
|
||||||
uint8_t edth; /* Energy detection threshold for CCA */
|
|
||||||
uint8_t csth; /* Carrier sense threshold for CCA */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ieee802154_packet_s
|
|
||||||
{
|
|
||||||
uint8_t len;
|
|
||||||
uint8_t data[127];
|
|
||||||
uint8_t lqi;
|
|
||||||
uint8_t rssi;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* IOCTL command data argument **********************************************/
|
|
||||||
|
|
||||||
/* A pointer to this structure is passed as the argument of each IOCTL
|
|
||||||
* command.
|
|
||||||
*/
|
|
||||||
|
|
||||||
union ieee802154_radioarg_u
|
|
||||||
{
|
|
||||||
uint8_t channel; /* PHY802154IOC_GET/SET_CHAN */
|
|
||||||
uint16_t panid; /* PHY802154IOC_GET/SET_PANID */
|
|
||||||
uint16_t saddr; /* PHY802154IOC_GET/SET_SADDR */
|
|
||||||
uint8_t eaddr[EADDR_SIZE]; /* PHY802154IOC_GET/SET_EADDR */
|
|
||||||
bool promisc; /* PHY802154IOC_GET/SET_EADDR */
|
|
||||||
uint8_t devmode; /* PHY802154IOC_GET/SET_DEVMODE */
|
|
||||||
int32_t txpwr; /* PHY802154IOC_GET/SET_TXPWR */
|
|
||||||
bool energy; /* PHY802154IOC_ENERGYDETECT */
|
|
||||||
struct ieee802154_cca_s cca; /* PHY802154IOC_GET/SET_CCA */
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_6LOWPAN
|
|
||||||
/* For the case of network IOCTLs, the network IOCTL to the MAC network
|
|
||||||
* driver will include a device name like "wpan0" as the destination of
|
|
||||||
* the IOCTL command. The MAC layer will forward only the payload union
|
|
||||||
* to the radio IOCTL method.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct ieee802154_netradio_s
|
|
||||||
{
|
|
||||||
char ifr_name[IFNAMSIZ]; /* Interface name, e.g. "wpan0" */
|
|
||||||
union ieee802154_radioarg_u u; /* Data payload */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* IEEE802.15.4 Radio Interface Operations **********************************/
|
/* IEEE802.15.4 Radio Interface Operations **********************************/
|
||||||
|
|
||||||
/* This is a work-around to allow the MAC upper layer have a struct with
|
|
||||||
* identical members but with a different name. */
|
|
||||||
|
|
||||||
#ifdef CONFIG_IEEE802154_RANGING
|
|
||||||
#define IEEE802154_TXDESC_FIELDS \
|
|
||||||
uint8_t handle; \
|
|
||||||
uint32_t timestamp; \
|
|
||||||
uint8_t status;
|
|
||||||
#else
|
|
||||||
#define IEEE802154_TXDESC_FIELDS \
|
|
||||||
uint8_t handle; \
|
|
||||||
uint32_t timestamp; \
|
|
||||||
uint8_t status;
|
|
||||||
bool rng_rcvd; \
|
|
||||||
uint32_t rng_counter_start; \
|
|
||||||
uint32_t rng_counter_stop; \
|
|
||||||
uint32_t rng_tracking_interval; \
|
|
||||||
uint32_t rng_offset;\
|
|
||||||
uint8_t rng_fom;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ieee802154_txdesc_s
|
|
||||||
{
|
|
||||||
IEEE802154_TXDESC_FIELDS
|
|
||||||
|
|
||||||
/* TODO: Add slotting information for GTS transactions */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ieee802154_rxdesc_s
|
|
||||||
{
|
|
||||||
uint8_t lqi;
|
|
||||||
uint8_t rssi;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ieee802154_radiocb_s
|
struct ieee802154_radiocb_s
|
||||||
{
|
{
|
||||||
CODE int (*poll_csma) (FAR const struct ieee802154_radiocb_s *radiocb,
|
CODE int (*poll_csma) (FAR const struct ieee802154_radiocb_s *radiocb,
|
||||||
@@ -213,11 +81,14 @@ struct ieee802154_radioops_s
|
|||||||
{
|
{
|
||||||
CODE int (*bind) (FAR struct ieee802154_radio_s *radio,
|
CODE int (*bind) (FAR struct ieee802154_radio_s *radio,
|
||||||
FAR struct ieee802154_radiocb_s *radiocb);
|
FAR struct ieee802154_radiocb_s *radiocb);
|
||||||
CODE int (*ioctl)(FAR struct ieee802154_radio_s *radio, int cmd,
|
|
||||||
unsigned long arg);
|
|
||||||
CODE int (*rxenable)(FAR struct ieee802154_radio_s *radio, bool enable);
|
|
||||||
CODE int (*txnotify_csma)(FAR struct ieee802154_radio_s *radio);
|
CODE int (*txnotify_csma)(FAR struct ieee802154_radio_s *radio);
|
||||||
CODE int (*txnotify_gts)(FAR struct ieee802154_radio_s *radio);
|
CODE int (*txnotify_gts)(FAR struct ieee802154_radio_s *radio);
|
||||||
|
CODE int (*get_attr) (FAR struct ieee802154_radio_s *radio,
|
||||||
|
enum ieee802154_pib_attr_e pib_attr,
|
||||||
|
FAR union ieee802154_attr_val_u *attr_value);
|
||||||
|
CODE int (*set_attr) (FAR struct ieee802154_radio_s *radio,
|
||||||
|
enum ieee802154_pib_attr_e pib_attr,
|
||||||
|
FAR const union ieee802154_attr_val_u *attr_value);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ieee802154_radio_s
|
struct ieee802154_radio_s
|
||||||
@@ -237,28 +108,6 @@ extern "C"
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: radio802154dev_register
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register a character driver to access the IEEE 802.15.4 radio from
|
|
||||||
* user-space
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* radio - Pointer to the radio struct to be registerd.
|
|
||||||
* devname - The name of the IEEE 802.15.4 radio to be registered.
|
|
||||||
*
|
|
||||||
* Returned Values:
|
|
||||||
* Zero (OK) is returned on success. Otherwise a negated errno value is
|
|
||||||
* returned to indicate the nature of the failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_IEEE802154_DEV
|
|
||||||
int radio802154dev_register(FAR struct ieee802154_radio_s *radio,
|
|
||||||
FAR char *devname);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,11 +65,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||||
#ifdef CONFIG_IEEE802154_DEV
|
|
||||||
/* Include ieee802.15.4 radio IOCTL definitions */
|
|
||||||
|
|
||||||
# include <nuttx/wireless/ieee802154/ ieee802154_radio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_IEEE802154_MAC
|
#ifdef CONFIG_IEEE802154_MAC
|
||||||
/* Include ieee802.15.4 MAC IOCTL definitions */
|
/* Include ieee802.15.4 MAC IOCTL definitions */
|
||||||
|
|||||||
@@ -74,7 +74,6 @@
|
|||||||
|
|
||||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN)
|
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN)
|
||||||
# include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
# include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
# include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "arp/arp.h"
|
#include "arp/arp.h"
|
||||||
@@ -353,22 +352,7 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
|||||||
|
|
||||||
if (arg != 0ul)
|
if (arg != 0ul)
|
||||||
{
|
{
|
||||||
/* Verify that this is either a valid IEEE802.15.4 radio IOCTL command
|
if (_MAC802154IOCVALID(cmd))
|
||||||
* or a valid IEEE802.15.4 MAC IOCTL command.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (_PHY802154IOCVALID(cmd))
|
|
||||||
{
|
|
||||||
/* Get the IEEE802.15.4 network device to receive the radio IOCTL
|
|
||||||
* commdand
|
|
||||||
*/
|
|
||||||
|
|
||||||
FAR struct ieee802154_netradio_s *radio =
|
|
||||||
(FAR struct ieee802154_netradio_s *)((uintptr_t)arg);
|
|
||||||
|
|
||||||
ifname = radio->ifr_name;
|
|
||||||
}
|
|
||||||
else if (_MAC802154IOCVALID(cmd))
|
|
||||||
{
|
{
|
||||||
/* Get the IEEE802.15.4 MAC device to receive the radio IOCTL
|
/* Get the IEEE802.15.4 MAC device to receive the radio IOCTL
|
||||||
* commdand
|
* commdand
|
||||||
|
|||||||
@@ -57,7 +57,6 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/net/sixlowpan.h>
|
#include <nuttx/net/sixlowpan.h>
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
|
||||||
|
|
||||||
#include "sixlowpan/sixlowpan_internal.h"
|
#include "sixlowpan/sixlowpan_internal.h"
|
||||||
|
|
||||||
@@ -165,7 +164,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
|||||||
* Name: sixlowpan_src_panid
|
* Name: sixlowpan_src_panid
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Get the source PAN ID from the IEEE802.15.4 radio.
|
* Get the source PAN ID from the IEEE802.15.4 MAC layer.
|
||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
||||||
@@ -181,18 +180,20 @@ int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
|
|||||||
FAR uint16_t *panid)
|
FAR uint16_t *panid)
|
||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev = &ieee->i_dev;
|
FAR struct net_driver_s *dev = &ieee->i_dev;
|
||||||
struct ieee802154_netradio_s arg;
|
struct ieee802154_netmac_s arg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memcpy(arg.ifr_name, ieee->i_dev.d_ifname, IFNAMSIZ);
|
memcpy(arg.ifr_name, ieee->i_dev.d_ifname, IFNAMSIZ);
|
||||||
ret = dev->d_ioctl(dev, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
|
arg.u.getreq.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
|
||||||
|
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
|
||||||
|
(unsigned long)((uintptr_t)&arg));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
wlerr("ERROR: PHY802154IOC_GET_PANID failed: %d\n", ret);
|
wlerr("ERROR: MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*panid = arg.u.panid;
|
*panid = arg.u.getreq.attr_value->panid;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,14 +60,6 @@ config IEEE802154_NTXDESC
|
|||||||
|
|
||||||
endif # IEEE802154_MAC
|
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
|
config IEEE802154_NETDEV
|
||||||
bool "IEEE802154 6loWPAN Network Device"
|
bool "IEEE802154 6loWPAN Network Device"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ ifeq ($(CONFIG_WIRELESS_IEEE802154),y)
|
|||||||
|
|
||||||
# Include IEEE 802.15.4 support
|
# Include IEEE 802.15.4 support
|
||||||
|
|
||||||
CSRCS = radio802154_ioctl.c
|
|
||||||
|
|
||||||
# Include wireless devices build support
|
# Include wireless devices build support
|
||||||
|
|
||||||
ifeq ($(CONFIG_IEEE802154_MAC),y)
|
ifeq ($(CONFIG_IEEE802154_MAC),y)
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
* wireless/ieee802154/mac802154.c
|
* wireless/ieee802154/mac802154.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Sebastien Lorquet. All rights reserved.
|
* Copyright (C) 2016 Sebastien Lorquet. All rights reserved.
|
||||||
|
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||||
|
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -51,6 +53,7 @@
|
|||||||
#include <nuttx/drivers/iob.h>
|
#include <nuttx/drivers/iob.h>
|
||||||
|
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
|
||||||
#include "mac802154.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.mode = IEEE802154_ADDRMODE_NONE;
|
||||||
priv->coord_addr.saddr = IEEE802154_SADDR_UNSPEC;
|
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 */
|
/* Reset the device's address */
|
||||||
|
|
||||||
priv->addr.mode = IEEE802154_ADDRMODE_NONE;
|
priv->addr.mode = IEEE802154_ADDRMODE_NONE;
|
||||||
priv->addr.panid = IEEE802154_PAN_UNSPEC;
|
priv->addr.panid = IEEE802154_PAN_UNSPEC;
|
||||||
priv->addr.saddr = IEEE802154_SADDR_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
|
/* 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:
|
case MAC802154IOC_MLME_ASSOC_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_associate(mac, &macarg->assocreq);
|
ret = mac802154_req_associate(mac, &macarg->assocreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_ASSOC_RESPONSE:
|
case MAC802154IOC_MLME_ASSOC_RESPONSE:
|
||||||
{
|
{
|
||||||
mac802154_resp_associate(mac, &macarg->assocresp);
|
ret = mac802154_resp_associate(mac, &macarg->assocresp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_DISASSOC_REQUEST:
|
case MAC802154IOC_MLME_DISASSOC_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_disassociate(mac, &macarg->disassocreq);
|
ret = mac802154_req_disassociate(mac, &macarg->disassocreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_GET_REQUEST:
|
case MAC802154IOC_MLME_GET_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_get(mac, macarg->getreq.pib_attr,
|
ret = mac802154_req_get(mac, macarg->getreq.pib_attr,
|
||||||
macarg->getreq.attr_value);
|
&macarg->getreq.attr_value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_GTS_REQUEST:
|
case MAC802154IOC_MLME_GTS_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_gts(mac, &macarg->gtsreq);
|
ret = mac802154_req_gts(mac, &macarg->gtsreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_ORPHAN_RESPONSE:
|
case MAC802154IOC_MLME_ORPHAN_RESPONSE:
|
||||||
{
|
{
|
||||||
mac802154_resp_orphan(mac, &macarg->orphanresp);
|
ret = mac802154_resp_orphan(mac, &macarg->orphanresp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_RESET_REQUEST:
|
case MAC802154IOC_MLME_RESET_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_reset(mac, macarg->resetreq.rst_pibattr);
|
ret = mac802154_req_reset(mac, macarg->resetreq.rst_pibattr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_RXENABLE_REQUEST:
|
case MAC802154IOC_MLME_RXENABLE_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_rxenable(mac, &macarg->rxenabreq);
|
ret = mac802154_req_rxenable(mac, &macarg->rxenabreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_SCAN_REQUEST:
|
case MAC802154IOC_MLME_SCAN_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_scan(mac, &macarg->scanreq);
|
ret = mac802154_req_scan(mac, &macarg->scanreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_SET_REQUEST:
|
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;
|
break;
|
||||||
case MAC802154IOC_MLME_START_REQUEST:
|
case MAC802154IOC_MLME_START_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_start(mac, &macarg->startreq);
|
ret = mac802154_req_start(mac, &macarg->startreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_SYNC_REQUEST:
|
case MAC802154IOC_MLME_SYNC_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_sync(mac, &macarg->syncreq);
|
ret = mac802154_req_sync(mac, &macarg->syncreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAC802154IOC_MLME_POLL_REQUEST:
|
case MAC802154IOC_MLME_POLL_REQUEST:
|
||||||
{
|
{
|
||||||
mac802154_req_poll(mac, &macarg->pollreq);
|
ret = mac802154_req_poll(mac, &macarg->pollreq);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
wlerr("ERROR: Unrecognized cmd: %d\n", cmd);
|
||||||
|
ret = -ENOTTY;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
/* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1109,8 +1106,10 @@ int mac802154_req_data(MACHANDLE mac,
|
|||||||
}
|
}
|
||||||
else if (meta->dest_addr.mode == IEEE802154_ADDRMODE_EXTENDED)
|
else if (meta->dest_addr.mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||||
{
|
{
|
||||||
memcpy(&frame->io_data[mhr_len], &meta->dest_addr.eaddr, 8);
|
memcpy(&frame->io_data[mhr_len], &meta->dest_addr.eaddr,
|
||||||
mhr_len += 8;
|
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)
|
else if (meta->src_addr_mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||||
{
|
{
|
||||||
memcpy(&frame->io_data[mhr_len], &priv->addr.eaddr, 8);
|
memcpy(&frame->io_data[mhr_len], &priv->addr.eaddr,
|
||||||
mhr_len += 8;
|
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 *priv =
|
||||||
(FAR struct ieee802154_privmac_s *)mac;
|
(FAR struct ieee802154_privmac_s *)mac;
|
||||||
union ieee802154_radioarg_u radio_arg;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
switch (req->pib_attr)
|
switch (pib_attr)
|
||||||
{
|
{
|
||||||
case IEEE802154_PIB_MAC_EXTENDED_ADDR:
|
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);
|
memcpy(&priv->addr.eaddr[0], &attr_value->mac.eaddr[0],
|
||||||
ret = priv->radio->ops->ioctl(priv->radio, PHY802154IOC_SET_EADDR,
|
IEEE802154_EADDR_LEN);
|
||||||
(unsigned long)&radio_arg);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
return -IEEE802154_STATUS_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
ret = IEEE802154_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Name: mac802154_req_start
|
||||||
|
|||||||
@@ -54,7 +54,6 @@
|
|||||||
#include <nuttx/net/net.h>
|
#include <nuttx/net/net.h>
|
||||||
#include <nuttx/net/ip.h>
|
#include <nuttx/net/ip.h>
|
||||||
#include <nuttx/net/sixlowpan.h>
|
#include <nuttx/net/sixlowpan.h>
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
|
||||||
|
|
||||||
#include "mac802154.h"
|
#include "mac802154.h"
|
||||||
@@ -594,32 +593,6 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
|||||||
|
|
||||||
else
|
else
|
||||||
#endif
|
#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;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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
|
/* Okay, we have no idea what this command is.. just give to the
|
||||||
* IEEE802.15.4 MAC layer without modification.
|
* IEEE802.15.4 MAC layer without modification.
|
||||||
*/
|
*/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -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 */
|
|
||||||
Reference in New Issue
Block a user