wireless/ieee802154/libradio: Add network versions of IOCTL helpers.

This commit is contained in:
Gregory Nutt 2017-04-21 10:24:31 -06:00
parent 575242ae13
commit b87e6c81cf
35 changed files with 1309 additions and 39 deletions

View File

@ -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))

View File

@ -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;

View File

@ -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");

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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");

View File

@ -39,11 +39,14 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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");

View File

@ -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");

View File

@ -39,21 +39,28 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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");

View File

@ -39,12 +39,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/ioctl.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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");

View File

@ -39,11 +39,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;

View File

@ -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;

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,74 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getcca.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getchan.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,72 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_geteaddr.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getpanid.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,72 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getpromisc.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 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;
}

View File

@ -0,0 +1,72 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getsaddr.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 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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setchan.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setchan.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setdevmode.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_seteaddr.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setpanid.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,74 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setpromisc.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 <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setsaddr.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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#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;
}