wireless/ieee802154: Completes all radio character driver IO command wrappers
This commit is contained in:
parent
9297d4e377
commit
575242ae13
@ -50,7 +50,8 @@
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* libradio */
|
||||
/* libradio *****************************************************************/
|
||||
/* Character driver IOCTL helpers */
|
||||
|
||||
int ieee802154_setchan(int fd, uint8_t chan);
|
||||
int ieee802154_getchan(int fd, FAR uint8_t *chan);
|
||||
@ -68,11 +69,59 @@ int ieee802154_setpromisc(int fd, bool promisc);
|
||||
int ieee802154_getpromisc(int fd, FAR bool *promisc);
|
||||
|
||||
int ieee802154_setdevmode(int fd, uint8_t devmode);
|
||||
int ieee802154_getdevmode(int fd, FAR uint8_t *devmode);
|
||||
|
||||
int ieee802154_settxpwr(int fd, int32_t txpwr);
|
||||
int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr);
|
||||
|
||||
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca);
|
||||
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca);
|
||||
|
||||
/* libutils */
|
||||
int ieee802154_energydetect(int fd, FAR bool *energy);
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
/* Netork driver IOCTL helpers */
|
||||
|
||||
int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan);
|
||||
int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan);
|
||||
|
||||
int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid);
|
||||
int sixlowpan_getpanid(int sock, FAR const char *ifname,
|
||||
FAR uint16_t *panid);
|
||||
|
||||
int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr);
|
||||
int sixlowpan_getsaddr(int sock, FAR const char *ifname,
|
||||
FAR uint16_t *saddr);
|
||||
|
||||
int sixlowpan_seteaddr(int sock, FAR const char *ifname,
|
||||
FAR const uint8_t *eaddr);
|
||||
int sixlowpan_geteaddr(int sock, FAR const char *ifname,
|
||||
FAR uint8_t *eaddr);
|
||||
|
||||
int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc);
|
||||
int sixlowpan_getpromisc(int sock, FAR const char *ifname,
|
||||
FAR bool *promisc);
|
||||
|
||||
int sixlowpan_setdevmode(int sock, FAR const char *ifname, uint8_t devmode);
|
||||
int sixlowpan_getdevmode(int sock, FAR const char *ifname,
|
||||
FAR uint8_t *devmode);
|
||||
|
||||
int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr);
|
||||
int sixlowpan_gettxpwr(int sock, FAR const char *ifname,
|
||||
FAR int32_t *txpwr);
|
||||
|
||||
int sixlowpan_setcca(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_cca_s *cca);
|
||||
int sixlowpan_getcca(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_cca_s *cca);
|
||||
|
||||
int sixlowpan_energydetect(int sock, FAR const char *ifname,
|
||||
FAR bool *energy);
|
||||
#endif
|
||||
|
||||
/* libmac *******************************************************************/
|
||||
|
||||
/* libutils *****************************************************************/
|
||||
|
||||
int ieee802154_addrparse(FAR struct ieee802154_packet_s *inpacket,
|
||||
FAR struct ieee802154_addr_s *dest,
|
||||
|
@ -35,7 +35,6 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@ -44,7 +43,6 @@
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@ -57,12 +55,10 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototyppes
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -45,8 +45,10 @@ CSRCS += ieee802154_setpanid.c ieee802154_getpanid.c
|
||||
CSRCS += ieee802154_setsaddr.c ieee802154_getsaddr.c
|
||||
CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c
|
||||
CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c
|
||||
CSRCS += ieee802154_setdevmode.c
|
||||
CSRCS += ieee802154_setdevmode.c ieee802154_getdevmode.c
|
||||
CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c
|
||||
CSRCS += ieee802154_setcca.c ieee802154_getcca.c
|
||||
CSRCS += ieee802154_energydetect.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
70
wireless/ieee802154/libradio/ieee802154_energydetect.c
Normal file
70
wireless/ieee802154/libradio/ieee802154_energydetect.c
Normal file
@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_energydetect.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 <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_energydetect(int fd, FAR bool *energy)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
|
||||
int ret = ioctl(fd, PHY802154IOC_ENERGYDETECT,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
printf("PHY802154IOC_ENERGYDETECT failed: %d\n", errcode);
|
||||
}
|
||||
|
||||
*energy = arg.energy;
|
||||
return ret;
|
||||
}
|
70
wireless/ieee802154/libradio/ieee802154_getdevmode.c
Normal file
70
wireless/ieee802154/libradio/ieee802154_getdevmode.c
Normal file
@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_getdevmode.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 <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getdevmode(int fd, FAR uint8_t *devmode)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
|
||||
int ret = ioctl(fd, PHY802154IOC_GET_DEVMODE,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
printf("PHY802154IOC_GET_DEVMODE failed: %d\n", errcode);
|
||||
}
|
||||
|
||||
*devmode = arg.devmode;
|
||||
return ret;
|
||||
}
|
70
wireless/ieee802154/libradio/ieee802154_gettxpwr.c
Normal file
70
wireless/ieee802154/libradio/ieee802154_gettxpwr.c
Normal file
@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_gettxpwr.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 <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
|
||||
int ret = ioctl(fd, PHY802154IOC_GET_TXPWR,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
printf("PHY802154IOC_GET_TXPWR failed: %d\n", errcode);
|
||||
}
|
||||
|
||||
*txpwr = arg.txpwr;
|
||||
return ret;
|
||||
}
|
71
wireless/ieee802154/libradio/ieee802154_settxpwr.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_settxpwr.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_settxpwr.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 <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_settxpwr(int fd, int32_t txpwr)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
|
||||
arg.txpwr = txpwr;
|
||||
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_TXPWR,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
printf("PHY802154IOC_SET_TXPWR failed: %d\n", errcode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
@ -4,23 +4,17 @@
|
||||
#
|
||||
|
||||
menuconfig WIRELESS_IWPAN
|
||||
bool "IEEE802.15.4 Configuration Library"
|
||||
bool "IEEE 802.15.4 Command Line Tool"
|
||||
default n
|
||||
depends on NET && DRIVERS_WIRELESS && EXPERIMENTAL
|
||||
depends on NET && DRIVERS_WIRELESS
|
||||
select IEEE802154_LIBRADIO
|
||||
select IEEE802154_LIBUTILS
|
||||
---help---
|
||||
IWPAN is a tool similar to wapi and inspired by iwpan on Linux that can
|
||||
be used to manage 802.15.4 PAN.
|
||||
|
||||
if WIRELESS_IWPAN
|
||||
|
||||
config WIRELESS_IWPAN_CMDTOOL
|
||||
bool "IEEE802.15.4 Command Line Tool"
|
||||
default n
|
||||
---help---
|
||||
By default, iWPAN is build as only a library. If this option is
|
||||
selected than a simple command line tool that can be ran from NSH
|
||||
will also be generated.
|
||||
|
||||
config WIRELESS_IWPAN_PROGNAME
|
||||
string "Program Name"
|
||||
default "iwpan"
|
||||
|
@ -38,28 +38,25 @@
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
#include "wireless/iwpan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user