From b87e6c81cf07586db624e7d352db2df86cae91e0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 21 Apr 2017 10:24:31 -0600 Subject: [PATCH] wireless/ieee802154/libradio: Add network versions of IOCTL helpers. --- wireless/ieee802154/libradio/Makefile | 12 +++ .../libradio/ieee802154_energydetect.c | 4 +- .../ieee802154/libradio/ieee802154_getcca.c | 4 +- .../ieee802154/libradio/ieee802154_getchan.c | 4 +- .../libradio/ieee802154_getdevmode.c | 4 +- .../ieee802154/libradio/ieee802154_geteaddr.c | 4 +- .../ieee802154/libradio/ieee802154_getpanid.c | 4 +- .../libradio/ieee802154_getpromisc.c | 4 +- .../ieee802154/libradio/ieee802154_getsaddr.c | 4 +- .../ieee802154/libradio/ieee802154_gettxpwr.c | 4 +- .../ieee802154/libradio/ieee802154_setcca.c | 4 +- .../ieee802154/libradio/ieee802154_setchan.c | 4 +- .../libradio/ieee802154_setdevmode.c | 9 ++- .../ieee802154/libradio/ieee802154_seteaddr.c | 4 +- .../ieee802154/libradio/ieee802154_setpanid.c | 13 +++- .../libradio/ieee802154_setpromisc.c | 9 ++- .../ieee802154/libradio/ieee802154_setsaddr.c | 13 +++- .../ieee802154/libradio/ieee802154_settxpwr.c | 4 +- .../libradio/sixlowpan_energydetect.c | 73 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_getcca.c | 74 +++++++++++++++++++ .../ieee802154/libradio/sixlowpan_getchan.c | 73 ++++++++++++++++++ .../libradio/sixlowpan_getdevmode.c | 72 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_geteaddr.c | 73 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_getpanid.c | 73 ++++++++++++++++++ .../libradio/sixlowpan_getpromisc.c | 72 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_getsaddr.c | 72 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_gettxpwr.c | 73 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_setcca.c | 73 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_setchan.c | 73 ++++++++++++++++++ .../libradio/sixlowpan_setdevmode.c | 73 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_seteaddr.c | 73 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_setpanid.c | 73 ++++++++++++++++++ .../libradio/sixlowpan_setpromisc.c | 74 +++++++++++++++++++ .../ieee802154/libradio/sixlowpan_setsaddr.c | 73 ++++++++++++++++++ .../ieee802154/libradio/sixlowpan_settxpwr.c | 73 ++++++++++++++++++ 35 files changed, 1309 insertions(+), 39 deletions(-) create mode 100644 wireless/ieee802154/libradio/sixlowpan_energydetect.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_getcca.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_getchan.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_getdevmode.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_geteaddr.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_getpanid.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_getpromisc.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_getsaddr.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_gettxpwr.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_setcca.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_setchan.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_setdevmode.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_seteaddr.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_setpanid.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_setpromisc.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_setsaddr.c create mode 100644 wireless/ieee802154/libradio/sixlowpan_settxpwr.c diff --git a/wireless/ieee802154/libradio/Makefile b/wireless/ieee802154/libradio/Makefile index 263f17d35..4791f5825 100644 --- a/wireless/ieee802154/libradio/Makefile +++ b/wireless/ieee802154/libradio/Makefile @@ -50,6 +50,18 @@ CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c CSRCS += ieee802154_setcca.c ieee802154_getcca.c CSRCS += ieee802154_energydetect.c +ifeq ($(CONFIG_NET_6LOWPAN),y) +CSRCS = sixlowpan_setchan.c sixlowpan_getchan.c +CSRCS += sixlowpan_setpanid.c sixlowpan_getpanid.c +CSRCS += sixlowpan_setsaddr.c sixlowpan_getsaddr.c +CSRCS += sixlowpan_seteaddr.c sixlowpan_geteaddr.c +CSRCS += sixlowpan_setpromisc.c sixlowpan_getpromisc.c +CSRCS += sixlowpan_setdevmode.c sixlowpan_getdevmode.c +CSRCS += sixlowpan_settxpwr.c sixlowpan_gettxpwr.c +CSRCS += sixlowpan_setcca.c sixlowpan_getcca.c +CSRCS += sixlowpan_energydetect.c +endif + AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/wireless/ieee802154/libradio/ieee802154_energydetect.c b/wireless/ieee802154/libradio/ieee802154_energydetect.c index d2fc3fee5..7af672431 100644 --- a/wireless/ieee802154/libradio/ieee802154_energydetect.c +++ b/wireless/ieee802154/libradio/ieee802154_energydetect.c @@ -56,9 +56,9 @@ int ieee802154_energydetect(int fd, FAR bool *energy) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_ENERGYDETECT, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_ENERGYDETECT, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/ieee802154_getcca.c b/wireless/ieee802154/libradio/ieee802154_getcca.c index 6636f5d4c..260470f5e 100644 --- a/wireless/ieee802154/libradio/ieee802154_getcca.c +++ b/wireless/ieee802154/libradio/ieee802154_getcca.c @@ -57,9 +57,9 @@ int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_CCA, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_CCA, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_GET_CCA failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_getchan.c b/wireless/ieee802154/libradio/ieee802154_getchan.c index fc11bd386..94641b8b9 100644 --- a/wireless/ieee802154/libradio/ieee802154_getchan.c +++ b/wireless/ieee802154/libradio/ieee802154_getchan.c @@ -54,9 +54,9 @@ int ieee802154_getchan(int fd, FAR uint8_t *chan) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_CHAN, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_CHAN, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_GET_CHAN failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_getdevmode.c b/wireless/ieee802154/libradio/ieee802154_getdevmode.c index 3d19b0710..b82feec5e 100644 --- a/wireless/ieee802154/libradio/ieee802154_getdevmode.c +++ b/wireless/ieee802154/libradio/ieee802154_getdevmode.c @@ -56,9 +56,9 @@ int ieee802154_getdevmode(int fd, FAR uint8_t *devmode) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_DEVMODE, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_DEVMODE, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/ieee802154_geteaddr.c b/wireless/ieee802154/libradio/ieee802154_geteaddr.c index c0e8585ed..589b80e29 100644 --- a/wireless/ieee802154/libradio/ieee802154_geteaddr.c +++ b/wireless/ieee802154/libradio/ieee802154_geteaddr.c @@ -57,9 +57,9 @@ int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_EADDR, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/ieee802154_getpanid.c b/wireless/ieee802154/libradio/ieee802154_getpanid.c index 7618dbef5..7a5991d75 100644 --- a/wireless/ieee802154/libradio/ieee802154_getpanid.c +++ b/wireless/ieee802154/libradio/ieee802154_getpanid.c @@ -56,9 +56,9 @@ int ieee802154_getpanid(int fd, FAR uint16_t *panid) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_PANID, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/ieee802154_getpromisc.c b/wireless/ieee802154/libradio/ieee802154_getpromisc.c index 9d9a8b0e6..3a0b8c614 100644 --- a/wireless/ieee802154/libradio/ieee802154_getpromisc.c +++ b/wireless/ieee802154/libradio/ieee802154_getpromisc.c @@ -56,9 +56,9 @@ int ieee802154_getpromisc(int fd, FAR bool *promisc) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_PROMISC, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/ieee802154_getsaddr.c b/wireless/ieee802154/libradio/ieee802154_getsaddr.c index 95326945e..90d58c7bf 100644 --- a/wireless/ieee802154/libradio/ieee802154_getsaddr.c +++ b/wireless/ieee802154/libradio/ieee802154_getsaddr.c @@ -56,9 +56,9 @@ int ieee802154_getsaddr(int fd, FAR uint16_t *saddr) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_SADDR, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/ieee802154_gettxpwr.c b/wireless/ieee802154/libradio/ieee802154_gettxpwr.c index 6e6770d61..12ff275fd 100644 --- a/wireless/ieee802154/libradio/ieee802154_gettxpwr.c +++ b/wireless/ieee802154/libradio/ieee802154_gettxpwr.c @@ -56,9 +56,9 @@ int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr) { union ieee802154_radioarg_u arg; + int ret; - int ret = ioctl(fd, PHY802154IOC_GET_TXPWR, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_GET_TXPWR, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/ieee802154_setcca.c b/wireless/ieee802154/libradio/ieee802154_setcca.c index aef66044c..a916473c0 100644 --- a/wireless/ieee802154/libradio/ieee802154_setcca.c +++ b/wireless/ieee802154/libradio/ieee802154_setcca.c @@ -57,11 +57,11 @@ int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca) { union ieee802154_radioarg_u arg; + int ret; memcpy(&arg.cca, cca, sizeof(struct ieee802154_cca_s)); - int ret = ioctl(fd, PHY802154IOC_SET_CCA, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_CCA, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_SET_CCA failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_setchan.c b/wireless/ieee802154/libradio/ieee802154_setchan.c index c54ade1c4..ea47c2e14 100644 --- a/wireless/ieee802154/libradio/ieee802154_setchan.c +++ b/wireless/ieee802154/libradio/ieee802154_setchan.c @@ -53,11 +53,11 @@ int ieee802154_setchan(int fd, uint8_t chan) { union ieee802154_radioarg_u arg; + int ret; arg.channel = chan; - int ret = ioctl(fd, PHY802154IOC_SET_CHAN, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_CHAN, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_SET_CHAN failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_setdevmode.c b/wireless/ieee802154/libradio/ieee802154_setdevmode.c index 2d6d66506..3f9f4d076 100644 --- a/wireless/ieee802154/libradio/ieee802154_setdevmode.c +++ b/wireless/ieee802154/libradio/ieee802154_setdevmode.c @@ -39,11 +39,14 @@ ****************************************************************************/ #include + +#include #include #include -#include + #include #include + #include "wireless/ieee802154.h" /**************************************************************************** @@ -53,11 +56,11 @@ int ieee802154_setdevmode(int fd, uint8_t devmode) { union ieee802154_radioarg_u arg; + int ret; arg.devmode = devmode; - int ret = ioctl(fd, PHY802154IOC_SET_DEVMODE, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_DEVMODE, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_SET_DEVMODE failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_seteaddr.c b/wireless/ieee802154/libradio/ieee802154_seteaddr.c index a0139309c..297ebccfa 100644 --- a/wireless/ieee802154/libradio/ieee802154_seteaddr.c +++ b/wireless/ieee802154/libradio/ieee802154_seteaddr.c @@ -57,11 +57,11 @@ int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr) { union ieee802154_radioarg_u arg; + int ret; memcpy(arg.eaddr, eaddr, EADDR_SIZE); - int ret = ioctl(fd, PHY802154IOC_SET_EADDR, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_EADDR, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_SET_EADDR failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_setpanid.c b/wireless/ieee802154/libradio/ieee802154_setpanid.c index f5880c18d..064f4f67d 100644 --- a/wireless/ieee802154/libradio/ieee802154_setpanid.c +++ b/wireless/ieee802154/libradio/ieee802154_setpanid.c @@ -39,21 +39,28 @@ ****************************************************************************/ #include + +#include #include #include -#include + #include #include + #include "wireless/ieee802154.h" +/**************************************************************************** + * Public Functions + ****************************************************************************/ + int ieee802154_setpanid(int fd, uint16_t panid) { union ieee802154_radioarg_u arg; + int ret; arg.panid = panid; - int ret = ioctl(fd, PHY802154IOC_SET_PANID, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_PANID, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_SET_PANID failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_setpromisc.c b/wireless/ieee802154/libradio/ieee802154_setpromisc.c index 7f1581e2d..7eb196b65 100644 --- a/wireless/ieee802154/libradio/ieee802154_setpromisc.c +++ b/wireless/ieee802154/libradio/ieee802154_setpromisc.c @@ -39,12 +39,15 @@ ****************************************************************************/ #include + +#include #include #include #include -#include + #include #include + #include "wireless/ieee802154.h" /**************************************************************************** @@ -54,11 +57,11 @@ int ieee802154_setpromisc(int fd, bool promisc) { union ieee802154_radioarg_u arg; + int ret; arg.promisc = promisc; - int ret = ioctl(fd, PHY802154IOC_SET_PROMISC, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_PROMISC, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { printf("PHY802154IOC_SET_PROMISC failed\n"); diff --git a/wireless/ieee802154/libradio/ieee802154_setsaddr.c b/wireless/ieee802154/libradio/ieee802154_setsaddr.c index 4ef7c4d7c..b27d577ce 100644 --- a/wireless/ieee802154/libradio/ieee802154_setsaddr.c +++ b/wireless/ieee802154/libradio/ieee802154_setsaddr.c @@ -39,11 +39,15 @@ ****************************************************************************/ #include + +#include #include #include -#include +#include + #include #include + #include "wireless/ieee802154.h" /**************************************************************************** @@ -53,14 +57,15 @@ int ieee802154_setsaddr(int fd, uint16_t saddr) { union ieee802154_radioarg_u arg; + int ret; arg.saddr = saddr; - int ret = ioctl(fd, PHY802154IOC_SET_SADDR, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_SADDR, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { - printf("PHY802154IOC_SET_SADDR failed\n"); + errcode = errno; + printf("PHY802154IOC_SET_SADDR failed: %d\n", errcode); } return ret; diff --git a/wireless/ieee802154/libradio/ieee802154_settxpwr.c b/wireless/ieee802154/libradio/ieee802154_settxpwr.c index 373b5d049..0143a8d8c 100644 --- a/wireless/ieee802154/libradio/ieee802154_settxpwr.c +++ b/wireless/ieee802154/libradio/ieee802154_settxpwr.c @@ -56,11 +56,11 @@ int ieee802154_settxpwr(int fd, int32_t txpwr) { union ieee802154_radioarg_u arg; + int ret; arg.txpwr = txpwr; - int ret = ioctl(fd, PHY802154IOC_SET_TXPWR, - (unsigned long)((uintptr_t)&arg)); + ret = ioctl(fd, PHY802154IOC_SET_TXPWR, (unsigned long)((uintptr_t)&arg)); if (ret < 0) { int errcode = errno; diff --git a/wireless/ieee802154/libradio/sixlowpan_energydetect.c b/wireless/ieee802154/libradio/sixlowpan_energydetect.c new file mode 100644 index 000000000..83fdf3742 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_energydetect.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_energydetect(int sock, FAR const char *ifname, FAR bool *energy) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_ENERGYDETECT, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_ENERGYDETECT failed: %d\n", errcode); + } + + *energy = arg.u.energy; + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_getcca.c b/wireless/ieee802154/libradio/sixlowpan_getcca.c new file mode 100644 index 000000000..62a282502 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_getcca.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_getcca.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_getcca(int sock, FAR const char *ifname, + FAR struct ieee802154_cca_s *cca) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_GET_CCA, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_CCA failed: %d\n", errcode); + } + + memcpy(cca, &arg.u.cca, sizeof(struct ieee802154_cca_s)); + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_getchan.c b/wireless/ieee802154/libradio/sixlowpan_getchan.c new file mode 100644 index 000000000..24b53c293 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_getchan.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_getchan.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_GET_CHAN, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_CHAN failed: %d\n", errcode); + } + + *chan = arg.u.channel; + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_getdevmode.c b/wireless/ieee802154/libradio/sixlowpan_getdevmode.c new file mode 100644 index 000000000..4e5c9d50c --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_getdevmode.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_getdevmode(int sock, FAR const char *ifname, + FAR uint8_t *devmode) +{ + struct ieee802154_netradio_s arg; + int ret; + + ret = ioctl(sock, PHY802154IOC_GET_DEVMODE, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_DEVMODE failed: %d\n", errcode); + } + + *devmode = arg.u.devmode; + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_geteaddr.c b/wireless/ieee802154/libradio/sixlowpan_geteaddr.c new file mode 100644 index 000000000..2fa9d3069 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_geteaddr.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_geteaddr.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_EADDR failed: %d\n", errcode); + } + + memcpy(eaddr, arg.u.eaddr, EADDR_SIZE); + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_getpanid.c b/wireless/ieee802154/libradio/sixlowpan_getpanid.c new file mode 100644 index 000000000..79b455744 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_getpanid.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_getpanid.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_PANID failed: %d\n", errcode); + } + + *panid = arg.u.panid; + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_getpromisc.c b/wireless/ieee802154/libradio/sixlowpan_getpromisc.c new file mode 100644 index 000000000..234460076 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_getpromisc.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_getpromisc.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 sixlowpan_getpromisc(int sock, FAR const char *ifname, FAR bool *promisc) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_PROMISC failed: %d\n", errcode); + } + + *promisc = arg.u.promisc; + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_getsaddr.c b/wireless/ieee802154/libradio/sixlowpan_getsaddr.c new file mode 100644 index 000000000..69fa8d01d --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_getsaddr.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_getsaddr.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 sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_SADDR failed: %d\n", errcode); + } + + *saddr = arg.u.saddr; + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_gettxpwr.c b/wireless/ieee802154/libradio/sixlowpan_gettxpwr.c new file mode 100644 index 000000000..5c450c0e3 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_gettxpwr.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + + ret = ioctl(sock, PHY802154IOC_GET_TXPWR, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_GET_TXPWR failed: %d\n", errcode); + } + + *txpwr = arg.u.txpwr; + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_setcca.c b/wireless/ieee802154/libradio/sixlowpan_setcca.c new file mode 100644 index 000000000..c257ddb77 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_setcca.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_setchan.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 +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_setcca(int sock, FAR const char *ifname, FAR struct ieee802154_cca_s *cca) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + memcpy(&arg.u.cca, cca, sizeof(struct ieee802154_cca_s)); + + ret = ioctl(sock, PHY802154IOC_SET_CCA, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_CCA failed: %d\n", errcode); + } + + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_setchan.c b/wireless/ieee802154/libradio/sixlowpan_setchan.c new file mode 100644 index 000000000..0def2f6be --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_setchan.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_setchan.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.channel = chan; + + ret = ioctl(sock, PHY802154IOC_SET_CHAN, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_CHAN failed: %d\n", errcode); + } + + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_setdevmode.c b/wireless/ieee802154/libradio/sixlowpan_setdevmode.c new file mode 100644 index 000000000..7c784571d --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_setdevmode.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_setdevmode.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_setdevmode(int sock, FAR const char *ifname, uint8_t devmode) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.devmode = devmode; + + ret = ioctl(sock, PHY802154IOC_SET_DEVMODE, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_DEVMODE failed: %d\n", errcode); + } + + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_seteaddr.c b/wireless/ieee802154/libradio/sixlowpan_seteaddr.c new file mode 100644 index 000000000..32cf3d7a4 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_seteaddr.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_seteaddr.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eaddr) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + memcpy(arg.u.eaddr, eaddr, EADDR_SIZE); + + ret = ioctl(sock, PHY802154IOC_SET_EADDR, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_EADDR failed: %d\n", errcode); + } + + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_setpanid.c b/wireless/ieee802154/libradio/sixlowpan_setpanid.c new file mode 100644 index 000000000..abf3f54ac --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_setpanid.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_setpanid.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.panid = panid; + + ret = ioctl(sock, PHY802154IOC_SET_PANID, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_PANID failed: %d\n", errcode); + } + + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_setpromisc.c b/wireless/ieee802154/libradio/sixlowpan_setpromisc.c new file mode 100644 index 000000000..b2bcc9b7d --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_setpromisc.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_setpromisc.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 +#include + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.promisc = promisc; + + ret = ioctl(sock, PHY802154IOC_SET_PROMISC, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_PROMISC failed: %d\n", errcode); + } + + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_setsaddr.c b/wireless/ieee802154/libradio/sixlowpan_setsaddr.c new file mode 100644 index 000000000..7f628de5a --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_setsaddr.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_setsaddr.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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.saddr = saddr; + + ret = ioctl(sock, PHY802154IOC_SET_SADDR, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_SADDR failed: %d\n", errcode); + } + + return ret; +} diff --git a/wireless/ieee802154/libradio/sixlowpan_settxpwr.c b/wireless/ieee802154/libradio/sixlowpan_settxpwr.c new file mode 100644 index 000000000..189235713 --- /dev/null +++ b/wireless/ieee802154/libradio/sixlowpan_settxpwr.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * apps/wireless/ieee802154/libradio/sixlowpan_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 + +#include "wireless/ieee802154.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr) +{ + struct ieee802154_netradio_s arg; + int ret; + + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.txpwr = txpwr; + + ret = ioctl(sock, PHY802154IOC_SET_TXPWR, (unsigned long)((uintptr_t)&arg)); + if (ret < 0) + { + int errcode = errno; + printf("PHY802154IOC_SET_TXPWR failed: %d\n", errcode); + } + + return ret; +}