Add nuttx to the system framework, which is 10.1.0

This commit is contained in:
TangYiwen123
2021-06-09 14:33:15 +08:00
parent 06c351e27c
commit 804bd57aa0
5000 changed files with 1488544 additions and 0 deletions
@@ -0,0 +1,10 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config IEEE802154_LIBMAC
bool "IEEE 802.15.4 MAC library routines"
default n
---help---
Some MAC library routines for ieee 802.15.4 apps
@@ -0,0 +1,39 @@
############################################################################
# apps/wireless/ieee802154/libmac/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2016-17 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.
#
############################################################################
ifeq ($(CONFIG_IEEE802154_LIBMAC),y)
CONFIGURED_APPS += $(APPDIR)/wireless/ieee802154/libmac
endif
@@ -0,0 +1,57 @@
############################################################################
# apps/wireless/ieee802154/libmac/Makefile
#
# 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.
#
############################################################################
include $(APPDIR)/Make.defs
# libmac source files
# Add IOCTL helpers
CSRCS = ieee802154_assocreq.c ieee802154_assocresp.c ieee802154_disassocreq.c
CSRCS += ieee802154_getreq.c ieee802154_gtsreq.c ieee802154_orphanresp.c
CSRCS += ieee802154_resetreq.c ieee802154_rxenabreq.c ieee802154_scanreq.c
CSRCS += ieee802154_setreq.c ieee802154_startreq.c ieee802154_syncreq.c
CSRCS += ieee802154_pollreq.c
ifeq ($(CONFIG_NET_6LOWPAN),y)
# Add IOCTL helpers
CSRCS += sixlowpan_assocreq.c sixlowpan_assocresp.c sixlowpan_disassocreq.c
CSRCS += sixlowpan_getreq.c sixlowpan_gtsreq.c sixlowpan_orphanresp.c
CSRCS += sixlowpan_resetreq.c sixlowpan_rxenabreq.c sixlowpan_scanreq.c
CSRCS += sixlowpan_setreq.c sixlowpan_startreq.c sixlowpan_syncreq.c
CSRCS += sixlowpan_pollreq.c
endif
include $(APPDIR)/Application.mk
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_assocreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_assoc_req(int fd, FAR struct ieee802154_assoc_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_ASSOC_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,70 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_assocresp.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_assoc_resp(int fd, FAR struct ieee802154_assoc_resp_s *resp)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_ASSOC_RESPONSE, (unsigned long)((uintptr_t)resp));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_RESPONSE failed: %d\n", ret);
return ret;
}
return OK;
}
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_assocreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_disassoc_req(int fd, FAR struct ieee802154_disassoc_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_DISASSOC_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_DISASSOC_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,223 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_getreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_get_req(int fd, FAR struct ieee802154_get_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_GET_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
}
return ret;
}
/* Wrappers around get_req to make it even easier to get common attributes */
int ieee802154_getchan(int fd, FAR uint8_t *chan)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_PHY_CHAN;
ret = ieee802154_get_req(fd, &req);
*chan = req.attrval.phy.chan;
return ret;
}
int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_EADDR;
ret = ieee802154_get_req(fd, &req);
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
return ret;
}
int ieee802154_getsaddr(int fd, FAR uint8_t *saddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_SADDR;
ret = ieee802154_get_req(fd, &req);
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
return ret;
}
int ieee802154_getpanid(int fd, FAR uint8_t *panid)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_PANID;
ret = ieee802154_get_req(fd, &req);
IEEE802154_PANIDCOPY(panid, req.attrval.mac.panid);
return ret;
}
int ieee802154_getcoordeaddr(int fd, FAR uint8_t *eaddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_COORD_EADDR;
ret = ieee802154_get_req(fd, &req);
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
return ret;
}
int ieee802154_getcoordsaddr(int fd, FAR uint8_t *saddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_COORD_SADDR;
ret = ieee802154_get_req(fd, &req);
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
return ret;
}
int ieee802154_getrxonidle(int fd, FAR bool *rxonidle)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_RX_ON_WHEN_IDLE;
ret = ieee802154_get_req(fd, &req);
*rxonidle = req.attrval.mac.rxonidle;
return ret;
}
int ieee802154_getdevmode(int fd, FAR enum ieee802154_devmode_e *devmode)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_DEVMODE;
ret = ieee802154_get_req(fd, &req);
*devmode = req.attrval.mac.devmode;
return ret;
}
int ieee802154_getpromisc(int fd, FAR bool *promisc)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_PROMISCUOUS_MODE;
ret = ieee802154_get_req(fd, &req);
*promisc = req.attrval.mac.promisc_mode;
return ret;
}
int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_PHY_TX_POWER;
ret = ieee802154_get_req(fd, &req);
*txpwr = req.attrval.phy.txpwr;
return ret;
}
int ieee802154_getmaxretries(int fd, FAR uint8_t *retries)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES;
ret = ieee802154_get_req(fd, &req);
*retries = req.attrval.mac.max_retries;
return ret;
}
int ieee802154_getfcslen(int fd, FAR uint8_t *fcslen)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_PHY_FCS_LEN;
ret = ieee802154_get_req(fd, &req);
*fcslen = req.attrval.phy.fcslen;
return ret;
}
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_gtsreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_gts_req(int fd, FAR struct ieee802154_gts_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_GTS_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_GTS_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,72 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_orphanresp.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_orphan_resp(int fd, FAR struct ieee802154_orphan_resp_s *resp)
{
union ieee802154_macarg_u arg;
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_ORPHAN_RESPONSE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_ORPHAN_RESPONSE failed: %d\n", ret);
return ret;
}
memcpy(resp, &arg.orphanresp, sizeof(struct ieee802154_orphan_resp_s));
return OK;
}
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_pollreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_poll_req(int fd, FAR struct ieee802154_poll_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_POLL_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_POLL_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,71 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_resetreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_reset_req(int fd, bool resetattr)
{
FAR struct ieee802154_reset_req_s req;
int ret;
req.resetattr = resetattr;
ret = ioctl(fd, MAC802154IOC_MLME_RESET_REQUEST, (unsigned long)((uintptr_t)&req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_RESET_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_rxenabreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_rxenable_req(int fd, FAR struct ieee802154_rxenable_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_RXENABLE_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_RXENABLE_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_scanreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_scan_req(int fd, FAR struct ieee802154_scan_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_SCAN_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_SCAN_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,170 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_setreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_set_req(int fd, FAR struct ieee802154_set_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_SET_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_SET_REQUEST failed: %d\n", ret);
}
return ret;
}
/* Wrappers around set_req to make it even easier to set common attributes */
int ieee802154_setchan(int fd, uint8_t chan)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_PHY_CHAN;
req.attrval.phy.chan = chan;
return ieee802154_set_req(fd, &req);
}
int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_EADDR;
IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr);
return ieee802154_set_req(fd, &req);
}
int ieee802154_setsaddr(int fd, FAR const uint8_t *saddr)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_SADDR;
IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr);
return ieee802154_set_req(fd, &req);
}
int ieee802154_setpanid(int fd, FAR const uint8_t *panid)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_PANID;
IEEE802154_PANIDCOPY(req.attrval.mac.panid, panid);
return ieee802154_set_req(fd, &req);
}
int ieee802154_setrxonidle(int fd, bool rxonidle)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_RX_ON_WHEN_IDLE;
req.attrval.mac.rxonidle = rxonidle;
return ieee802154_set_req(fd, &req);
}
int ieee802154_setpromisc(int fd, bool promisc)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_PROMISCUOUS_MODE;
req.attrval.mac.promisc_mode = promisc;
return ieee802154_set_req(fd, &req);
}
int ieee802154_setassocpermit(int fd, bool assocpermit)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT;
req.attrval.mac.assocpermit = assocpermit;
return ieee802154_set_req(fd, &req);
}
int ieee802154_settxpwr(int fd, int32_t txpwr)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_PHY_TX_POWER;
req.attrval.phy.txpwr = txpwr;
return ieee802154_set_req(fd, &req);
}
int ieee802154_setmaxretries(int fd, uint8_t retries)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES;
req.attrval.mac.max_retries = retries;
return ieee802154_set_req(fd, &req);
}
int ieee802154_setfcslen(int fd, uint8_t fcslen)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_PHY_FCS_LEN;
req.attrval.phy.fcslen = fcslen;
return ieee802154_set_req(fd, &req);
}
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_startreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_start_req(int fd, FAR struct ieee802154_start_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_START_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_START_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,68 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_syncreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_sync_req(int fd, FAR struct ieee802154_sync_req_s *req)
{
int ret;
ret = ioctl(fd, MAC802154IOC_MLME_SYNC_REQUEST, (unsigned long)((uintptr_t)req));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_SYNC_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_assocreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_assoc_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_assoc_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.assocreq, req, sizeof(struct ieee802154_assoc_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,77 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_assocresp.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_assoc_resp(int sock, FAR const char *ifname,
FAR struct ieee802154_assoc_resp_s *resp)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.assocresp, resp, sizeof(struct ieee802154_assoc_resp_s));
ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_RESPONSE,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_RESPONSE failed: %d\n", ret);
return ret;
}
memcpy(resp, &arg.u.assocresp, sizeof(struct ieee802154_assoc_resp_s));
return OK;
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_disassocreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_desassoc_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_disassoc_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.disassocreq, req, sizeof(struct ieee802154_disassoc_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_DISASSOC_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_DISASSOC_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,67 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/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 <string.h>
#include <errno.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_getpromisc(int sock, FAR const char *ifname, FAR bool *promisc)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_PROMISCUOUS_MODE;
ret = sixlowpan_get_req(sock, ifname, &req);
*promisc = req.attrval.mac.promisc_mode;
return ret;
}
@@ -0,0 +1,241 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_getreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_get_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_get_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
/* We must use a shadow arg to perform the operation as we must add the
* network interface name to the front of the argument.
*/
arg.u.getreq.attr = req->attr;
ret = ioctl(sock, MAC802154IOC_MLME_GET_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
}
memcpy((void *)req, &arg.u.getreq, sizeof(struct ieee802154_get_req_s));
return ret;
}
/* Wrappers around get_req to make it even easier to get common attributes */
int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_PHY_CHAN;
ret = sixlowpan_get_req(sock, ifname, &req);
*chan = req.attrval.phy.chan;
return ret;
}
int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_EADDR;
ret = sixlowpan_get_req(sock, ifname, &req);
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
return ret;
}
int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint8_t *saddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_SADDR;
ret = sixlowpan_get_req(sock, ifname, &req);
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
return ret;
}
int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint8_t *panid)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_PANID;
ret = sixlowpan_get_req(sock, ifname, &req);
IEEE802154_PANIDCOPY(panid, req.attrval.mac.panid);
return ret;
}
int sixlowpan_getcoordeaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_COORD_EADDR;
ret = sixlowpan_get_req(sock, ifname, &req);
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
return ret;
}
int sixlowpan_getcoordsaddr(int sock, FAR const char *ifname, FAR uint8_t *saddr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_COORD_SADDR;
ret = sixlowpan_get_req(sock, ifname, &req);
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
return ret;
}
int sixlowpan_getrxonidle(int sock, FAR const char *ifname, FAR bool *rxonidle)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_RX_ON_WHEN_IDLE;
ret = sixlowpan_get_req(sock, ifname, &req);
*rxonidle = req.attrval.mac.rxonidle;
return ret;
}
int sixlowpan_getdevmode(int sock, FAR const char *ifname,
FAR enum ieee802154_devmode_e *devmode)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_DEVMODE;
ret = sixlowpan_get_req(sock, ifname, &req);
*devmode = req.attrval.mac.devmode;
return ret;
}
int sixlowpan_getpromisc(int sock, FAR const char *ifname, FAR bool *promisc)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_PROMISCUOUS_MODE;
ret = sixlowpan_get_req(sock, ifname, &req);
*promisc = req.attrval.mac.promisc_mode;
return ret;
}
int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_PHY_TX_POWER;
ret = sixlowpan_get_req(sock, ifname, &req);
*txpwr = req.attrval.phy.txpwr;
return ret;
}
int sixlowpan_getmaxretries(int sock, FAR const char *ifname, FAR uint8_t *retries)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES;
ret = sixlowpan_get_req(sock, ifname, &req);
*retries = req.attrval.mac.max_retries;
return ret;
}
int sixlowpan_getfcslen(int sock, FAR const char *ifname, FAR uint8_t *fcslen)
{
struct ieee802154_get_req_s req;
int ret;
req.attr = IEEE802154_ATTR_PHY_FCS_LEN;
ret = sixlowpan_get_req(sock, ifname, &req);
*fcslen = req.attrval.phy.fcslen;
return ret;
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_gtsreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_gts_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_gts_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.gtsreq, req, sizeof(struct ieee802154_gts_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_GTS_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_GTS_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,76 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_orphanresp.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_orphan_resp(int sock, FAR const char *ifname,
FAR struct ieee802154_orphan_resp_s *resp)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
ret = ioctl(sock, MAC802154IOC_MLME_ORPHAN_RESPONSE,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_ORPHAN_RESPONSE failed: %d\n", ret);
return ret;
}
memcpy(resp, &arg.u.orphanresp, sizeof(struct ieee802154_orphan_resp_s));
return OK;
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_pollreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_poll_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_poll_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.pollreq, req, sizeof(struct ieee802154_poll_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_POLL_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_POLL_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,74 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_resetreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_reset_req(int sock, FAR const char *ifname, bool resetattr)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.resetreq.resetattr = resetattr;
ret = ioctl(sock, MAC802154IOC_MLME_RESET_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_RESET_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_rxenabreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_rxenable_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_rxenable_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.rxenabreq, req, sizeof(struct ieee802154_rxenable_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_RXENABLE_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_RXENABLE_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_scanreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_scan_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_scan_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.scanreq, req, sizeof(struct ieee802154_scan_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_SCAN_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_SCAN_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,177 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_setreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_set_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_set_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.setreq, req, sizeof(struct ieee802154_set_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_SET_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_SET_REQUEST failed: %d\n", ret);
}
return ret;
}
/* Wrappers around set_req to make it even easier to set common attributes */
int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_PHY_CHAN;
req.attrval.phy.chan = chan;
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eaddr)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_EADDR;
IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr);
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_setsaddr(int sock, FAR const char *ifname, FAR const uint8_t *saddr)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_SADDR;
IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr);
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_setpanid(int sock, FAR const char *ifname, FAR const uint8_t *panid)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_PANID;
IEEE802154_PANIDCOPY(req.attrval.mac.panid, panid);
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_setrxonidle(int sock, FAR const char *ifname, bool rxonidle)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_RX_ON_WHEN_IDLE;
req.attrval.mac.rxonidle = rxonidle;
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_PROMISCUOUS_MODE;
req.attrval.mac.promisc_mode = promisc;
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_setassocpermit(int sock, FAR const char *ifname, bool assocpermit)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT;
req.attrval.mac.assocpermit = assocpermit;
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_PHY_TX_POWER;
req.attrval.phy.txpwr = txpwr;
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_setmaxretries(int sock, FAR const char *ifname, uint8_t retries)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_MAX_FRAME_RETRIES;
req.attrval.mac.max_retries = retries;
return sixlowpan_set_req(sock, ifname, &req);
}
int sixlowpan_setfcslen(int sock, FAR const char *ifname, uint8_t fcslen)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_PHY_FCS_LEN;
req.attrval.phy.fcslen = fcslen;
return sixlowpan_set_req(sock, ifname, &req);
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_startreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_start_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_start_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.startreq, req, sizeof(struct ieee802154_start_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_START_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_START_REQUEST failed: %d\n", ret);
}
return ret;
}
@@ -0,0 +1,75 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/sixlowpan_syncreq.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_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_sync_req(int sock, FAR const char *ifname,
FAR const struct ieee802154_sync_req_s *req)
{
struct ieee802154_netmac_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.syncreq, req, sizeof(struct ieee802154_sync_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_SYNC_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "MAC802154IOC_MLME_SYNC_REQUEST failed: %d\n", ret);
}
return ret;
}