diff --git a/include/wireless/ieee802154.h b/include/wireless/ieee802154.h index d82c5ef0b..dec34c6c8 100644 --- a/include/wireless/ieee802154.h +++ b/include/wireless/ieee802154.h @@ -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, diff --git a/include/wireless/iwpan.h b/include/wireless/iwpan.h index e9d6234d0..b56f06a9f 100644 --- a/include/wireless/iwpan.h +++ b/include/wireless/iwpan.h @@ -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 } diff --git a/wireless/ieee802154/libradio/Makefile b/wireless/ieee802154/libradio/Makefile index 0853ba19d..263f17d35 100644 --- a/wireless/ieee802154/libradio/Makefile +++ b/wireless/ieee802154/libradio/Makefile @@ -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)) diff --git a/wireless/ieee802154/libradio/ieee802154_energydetect.c b/wireless/ieee802154/libradio/ieee802154_energydetect.c new file mode 100644 index 000000000..d2fc3fee5 --- /dev/null +++ b/wireless/ieee802154/libradio/ieee802154_energydetect.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/ieee802154_energydetect.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include +#include + +#include +#include + +#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; +} diff --git a/wireless/ieee802154/libradio/ieee802154_getdevmode.c b/wireless/ieee802154/libradio/ieee802154_getdevmode.c new file mode 100644 index 000000000..3d19b0710 --- /dev/null +++ b/wireless/ieee802154/libradio/ieee802154_getdevmode.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/ieee802154_getdevmode.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include +#include + +#include +#include + +#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; +} diff --git a/wireless/ieee802154/libradio/ieee802154_gettxpwr.c b/wireless/ieee802154/libradio/ieee802154_gettxpwr.c new file mode 100644 index 000000000..6e6770d61 --- /dev/null +++ b/wireless/ieee802154/libradio/ieee802154_gettxpwr.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/ieee802154_gettxpwr.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include +#include + +#include +#include + +#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; +} diff --git a/wireless/ieee802154/libradio/ieee802154_settxpwr.c b/wireless/ieee802154/libradio/ieee802154_settxpwr.c new file mode 100644 index 000000000..373b5d049 --- /dev/null +++ b/wireless/ieee802154/libradio/ieee802154_settxpwr.c @@ -0,0 +1,71 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/ieee802154_settxpwr.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include +#include + +#include +#include + +#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; +} diff --git a/wireless/iwpan/Kconfig b/wireless/iwpan/Kconfig index 3e45da873..8a9425ca9 100644 --- a/wireless/iwpan/Kconfig +++ b/wireless/iwpan/Kconfig @@ -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" diff --git a/wireless/iwpan/src/iwpan.c b/wireless/iwpan/src/iwpan.c index 6aa8535f4..da0c6c4b7 100644 --- a/wireless/iwpan/src/iwpan.c +++ b/wireless/iwpan/src/iwpan.c @@ -38,28 +38,25 @@ #include #include +#include "wireless/ieee802154.h" #include "wireless/iwpan.h" /**************************************************************************** * Private Types ****************************************************************************/ - /**************************************************************************** * Private Function Prototypes ****************************************************************************/ - /**************************************************************************** * Private Data ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/wireless/wapi/Kconfig b/wireless/wapi/Kconfig index 249a1593d..bb76675a9 100644 --- a/wireless/wapi/Kconfig +++ b/wireless/wapi/Kconfig @@ -4,7 +4,7 @@ # menuconfig WIRELESS_WAPI - bool "IEEE802.11 Configuration Library" + bool "IEEE 802.11 Configuration Library" default n depends on NET && DRIVERS_WIRELESS && EXPERIMENTAL ---help--- @@ -14,7 +14,7 @@ menuconfig WIRELESS_WAPI if WIRELESS_WAPI config WIRELESS_WAPI_CMDTOOL - bool "IEEE802.11 Command Line Tool" + bool "IEEE 802.11 Command Line Tool" default n ---help--- By default, Wapi is build as only a library. If this option is