Merge branch 'ieee802154'
This commit is contained in:
commit
8029b81548
2
.gitignore
vendored
2
.gitignore
vendored
@ -19,3 +19,5 @@ cscope.out
|
||||
/*.lib
|
||||
/romfs.img
|
||||
/boot_romfsimg.h
|
||||
/*/*/.built
|
||||
|
||||
|
189
include/wireless/ieee802154.h
Normal file
189
include/wireless/ieee802154.h
Normal file
@ -0,0 +1,189 @@
|
||||
/****************************************************************************
|
||||
* apps/include/wireless/ieee802154.h
|
||||
*
|
||||
* Copyright(C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_WIRELESS_IEEE802154_H
|
||||
#define __APPS_INCLUDE_WIRELESS_IEEE802154_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* libmac *******************************************************************/
|
||||
/* Character driver IOCTL helpers */
|
||||
|
||||
#if 0
|
||||
int ieee802154_mcps_register(int fd,
|
||||
FAR struct ieee802154_mcps_register_s *info);
|
||||
int ieee802154_mlme_register(int fd,
|
||||
FAR struct ieee802154_mlme_register_s *info);
|
||||
#endif
|
||||
int ieee802154_assoc_req(int fd, FAR struct ieee802154_assoc_req_s *req);
|
||||
int ieee802154_assoc_resp(int fd, FAR struct ieee802154_assoc_resp_s *resp);
|
||||
int ieee802154_disassoc_req(int fd,
|
||||
FAR struct ieee802154_disassoc_req_s *req);
|
||||
int ieee802154_get_req(int fd, FAR struct ieee802154_get_req_s *req);
|
||||
int ieee802154_gts_req(int fd, FAR struct ieee802154_gts_req_s *req);
|
||||
int ieee802154_orphan_resp(int fd,
|
||||
FAR struct ieee802154_orphan_resp_s *resp);
|
||||
int ieee802154_rxenable_req(int fd,
|
||||
FAR struct ieee802154_rxenable_req_s *req);
|
||||
int ieee802154_scan_req(int fd, FAR struct ieee802154_scan_req_s *req);
|
||||
int ieee802154_set_req(int fd, FAR struct ieee802154_set_req_s *req);
|
||||
int ieee802154_start_req(int fd, FAR struct ieee802154_start_req_s *req);
|
||||
int ieee802154_sync_req(int fd, FAR struct ieee802154_sync_req_s *req);
|
||||
int ieee802154_poll_req(int fd, FAR struct ieee802154_poll_req_s *req);
|
||||
#if 0
|
||||
int ieee802154_dps_req(int fd, FAR struct ieee802154_dps_req_s *req);
|
||||
int ieee802154_sounding_req(int fd,
|
||||
FAR struct ieee802154_sounding_req_s *req);
|
||||
int ieee802154_calibrate_req(int fd,
|
||||
FAR struct ieee802154_calibrate_req_s *req);
|
||||
#endif
|
||||
|
||||
/* Get/Set Attribute helpers */
|
||||
|
||||
int ieee802154_setchan(int fd, uint8_t chan);
|
||||
int ieee802154_getchan(int fd, FAR uint8_t *chan);
|
||||
|
||||
int ieee802154_setpanid(int fd, uint16_t panid);
|
||||
int ieee802154_getpanid(int fd, FAR uint16_t *panid);
|
||||
|
||||
int ieee802154_setsaddr(int fd, uint16_t saddr);
|
||||
int ieee802154_getsaddr(int fd, FAR uint16_t *saddr);
|
||||
|
||||
int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr);
|
||||
int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr);
|
||||
|
||||
int ieee802154_setpromisc(int fd, bool promisc);
|
||||
int ieee802154_getpromisc(int fd, FAR bool *promisc);
|
||||
|
||||
int ieee802154_setrxonidle(int fd, bool rxonidle);
|
||||
int ieee802154_getrxonidle(int fd, FAR bool *rxonidle);
|
||||
|
||||
int ieee802154_settxpwr(int fd, int32_t txpwr);
|
||||
int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr);
|
||||
|
||||
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca);
|
||||
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca);
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
/* Netork driver IOCTL helpers */
|
||||
|
||||
#if 0
|
||||
int sixlowpan_mcps_register(int fd, FAR const char *ifname,
|
||||
FAR const struct ieee802154_mcps_register_s *info);
|
||||
int sixlowpan_mlme_register(int fd, FAR const char *ifname,
|
||||
FAR const struct ieee802154_mlme_register_s *info);
|
||||
#endif
|
||||
int sixlowpan_assoc_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_assoc_req_s *req);
|
||||
int sixlowpan_assoc_resp(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_assoc_resp_s *resp);
|
||||
int sixlowpan_disassoc_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_disassoc_req_s *req);
|
||||
int sixlowpan_get_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_get_req_s *req);
|
||||
int sixlowpan_gts_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_gts_req_s *req);
|
||||
int sixlowpan_orphan_resp(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_orphan_resp_s *resp);
|
||||
int sixlowpan_rxenable_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_rxenable_req_s *req);
|
||||
int sixlowpan_scan_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_scan_req_s *req);
|
||||
int sixlowpan_set_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_set_req_s *req);
|
||||
int sixlowpan_start_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_start_req_s *req);
|
||||
int sixlowpan_sync_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_sync_req_s *req);
|
||||
int sixlowpan_poll_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_poll_req_s *req);
|
||||
#if 0
|
||||
int sixlowpan_dps_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_dps_req_s *req);
|
||||
int sixlowpan_sounding_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_sounding_req_s *req);
|
||||
int sixlowpan_calibrate_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_calibrate_req_s *req);
|
||||
#endif
|
||||
|
||||
int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan);
|
||||
int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan);
|
||||
|
||||
int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid);
|
||||
int sixlowpan_getpanid(int sock, FAR const char *ifname,
|
||||
FAR uint16_t *panid);
|
||||
|
||||
int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr);
|
||||
int sixlowpan_getsaddr(int sock, FAR const char *ifname,
|
||||
FAR uint16_t *saddr);
|
||||
|
||||
int sixlowpan_seteaddr(int sock, FAR const char *ifname,
|
||||
FAR const uint8_t *eaddr);
|
||||
int sixlowpan_geteaddr(int sock, FAR const char *ifname,
|
||||
FAR uint8_t *eaddr);
|
||||
|
||||
int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc);
|
||||
int sixlowpan_getpromisc(int sock, FAR const char *ifname,
|
||||
FAR bool *promisc);
|
||||
|
||||
int sixlowpan_setrxonidle(int sock, FAR const char *ifname, bool rxonidle);
|
||||
int sixlowpan_getrxonidle(int sock, FAR const char *ifname,
|
||||
FAR bool *rxonidle);
|
||||
|
||||
int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr);
|
||||
int sixlowpan_gettxpwr(int sock, FAR const char *ifname,
|
||||
FAR int32_t *txpwr);
|
||||
|
||||
#endif /* CONFIG_NET_6LOWPAN*/
|
||||
|
||||
/* libutils *****************************************************************/
|
||||
|
||||
int ieee802154_addrtostr(FAR char *buf, int len,
|
||||
FAR struct ieee802154_addr_s *addr);
|
||||
|
||||
#endif /*__APPS_INCLUDE_WIRELESS_IEEE802154_H */
|
68
include/wireless/iwpan.h
Normal file
68
include/wireless/iwpan.h
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/include/wireless/iwpan.h
|
||||
*
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_WIRELESS_IWPAN_H
|
||||
#define __APPS_INCLUDE_WIRELESS_IWPAN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototyppes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_WIRELESS_IWPAN_H */
|
||||
|
@ -7,6 +7,7 @@ config NETUTILS_NETLIB
|
||||
bool "Network support library"
|
||||
default n
|
||||
depends on NET
|
||||
select IEEE802154_LIBMAC if WIRELESS_IEEE802154
|
||||
---help---
|
||||
Enable support for the network support library.
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
#include "netutils/netlib.h"
|
||||
|
||||
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
@ -80,13 +81,10 @@ int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid)
|
||||
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
/* Put the driver name into the request */
|
||||
#warning Missing logic
|
||||
/* Perform the ioctl to get the current PAN ID */
|
||||
/* Use the helper provided in libmac */
|
||||
|
||||
ret = sixlowpan_getpanid(sockfd, ifname, panid);
|
||||
close(sockfd);
|
||||
|
||||
/* Reuturn the current PAN ID */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,14 +62,14 @@ bool netlib_nodeaddrconv(FAR const char *hwstr, FAR uint8_t *hw)
|
||||
|
||||
/* Form xx:xx or xx:xx:xx:xx:xx:xx:xx:xx for extended Rime address */
|
||||
|
||||
if (strlen(hwstr) != 3 * NET_6LOWPAN_RIMEADDR_SIZE - 1)
|
||||
if (strlen(hwstr) != 3 * NET_6LOWPAN_ADDRSIZE - 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tmp = 0;
|
||||
|
||||
for (i = 0; i < NET_6LOWPAN_RIMEADDR_SIZE; ++i)
|
||||
for (i = 0; i < NET_6LOWPAN_ADDRSIZE; ++i)
|
||||
{
|
||||
j = 0;
|
||||
do
|
||||
|
@ -67,7 +67,7 @@
|
||||
*
|
||||
* Parameters:
|
||||
* ifname The name of the interface to use
|
||||
* nodeaddr Node address to set, size must be NET_6LOWPAN_RIMEADDR_SIZE
|
||||
* nodeaddr Node address to set, size must be NET_6LOWPAN_ADDRSIZE
|
||||
*
|
||||
* Return:
|
||||
* 0 on success; -1 on failure
|
||||
@ -94,7 +94,7 @@ int netlib_setnodeaddr(FAR const char *ifname, FAR const uint8_t *nodeaddr)
|
||||
/* Put the new MAC address into the request */
|
||||
|
||||
req.ifr_hwaddr.sa_family = AF_INET6;
|
||||
memcpy(&req.ifr_hwaddr.sa_data, nodeaddr, NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
memcpy(&req.ifr_hwaddr.sa_data, nodeaddr, NET_6LOWPAN_ADDRSIZE);
|
||||
|
||||
/* Perform the ioctl to set the node address */
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
#include "netutils/netlib.h"
|
||||
|
||||
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
@ -80,12 +81,9 @@ int netlib_setpanid(FAR const char *ifname, uint16_t panid)
|
||||
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
/* Put the driver name into the request */
|
||||
# warning Missing Logic
|
||||
/* Put the new PAN ID into the request */
|
||||
|
||||
/* Perform the ioctl to set the new PAN ID */
|
||||
/* Use the helper provided in libmac */
|
||||
|
||||
ret = sixlowpan_setpanid(sockfd, ifname, panid);
|
||||
close(sockfd);
|
||||
}
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
uint8_t mac[IFHWADDRLEN];
|
||||
#endif
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
uint8_t nodeaddr[NET_6LOWPAN_RIMEADDR_SIZE];
|
||||
uint8_t nodeaddr[NET_6LOWPAN_ADDRSIZE];
|
||||
#endif
|
||||
#if defined(CONFIG_NSH_DHCPC)
|
||||
FAR void *handle;
|
||||
|
@ -256,7 +256,7 @@ static void nsh_netinit_configure(void)
|
||||
#if defined(CONFIG_NET_ETHERNET)
|
||||
uint8_t mac[IFHWADDRLEN];
|
||||
#elif defined(CONFIG_NET_6LOWPAN)
|
||||
uint8_t nodeaddr[NET_6LOWPAN_RIMEADDR_SIZE];
|
||||
uint8_t nodeaddr[NET_6LOWPAN_ADDRSIZE];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
12
wireless/ieee802154/Kconfig
Normal file
12
wireless/ieee802154/Kconfig
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
menu "IEEE 802.15.4 applications"
|
||||
|
||||
source "$APPSDIR/wireless/ieee802154/libmac/Kconfig"
|
||||
source "$APPSDIR/wireless/ieee802154/libutils/Kconfig"
|
||||
source "$APPSDIR/wireless/ieee802154/i8sak/Kconfig"
|
||||
|
||||
endmenu #ieee 802.15.4 apps
|
37
wireless/ieee802154/Make.defs
Normal file
37
wireless/ieee802154/Make.defs
Normal file
@ -0,0 +1,37 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2012, 2015 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 $(wildcard wireless/ieee802154/*/Make.defs)
|
71
wireless/ieee802154/Makefile
Normal file
71
wireless/ieee802154/Makefile
Normal file
@ -0,0 +1,71 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/Makefile
|
||||
#
|
||||
# Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
#
|
||||
# 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 $(TOPDIR)/.config # Current configuration
|
||||
|
||||
# Sub-directories
|
||||
|
||||
SUBDIRS = $(dir $(wildcard */Makefile))
|
||||
|
||||
all: nothing
|
||||
|
||||
.PHONY: nothing context depend clean distclean
|
||||
|
||||
define SDIR_template
|
||||
$(1)_$(2):
|
||||
$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||
endef
|
||||
|
||||
$(foreach SDIR, $(CNTXTDIRS), $(eval $(call SDIR_template,$(SDIR),context)))
|
||||
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),depend)))
|
||||
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
|
||||
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
|
||||
|
||||
nothing:
|
||||
|
||||
install:
|
||||
|
||||
context: $(foreach SDIR, $(CNTXTDIRS), $(SDIR)_context)
|
||||
|
||||
depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend)
|
||||
|
||||
clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean)
|
||||
|
||||
distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
.PHONY: preconfig
|
||||
preconfig:
|
11
wireless/ieee802154/i8sak/.gitignore
vendored
Normal file
11
wireless/ieee802154/i8sak/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/*.asm
|
||||
/*.obj
|
||||
/*.rel
|
||||
/*.lst
|
||||
/*.sym
|
||||
/*.adb
|
||||
/*.lib
|
||||
/*.src
|
32
wireless/ieee802154/i8sak/Kconfig
Normal file
32
wireless/ieee802154/i8sak/Kconfig
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config IEEE802154_I8SAK
|
||||
bool "IEEE 802.15.4 Swiss Army Knife"
|
||||
default n
|
||||
select IEEE802154_LIBUTILS
|
||||
---help---
|
||||
Enable the IEEE 802.15.4 Swiss Army Knife
|
||||
|
||||
if IEEE802154_I8SAK
|
||||
|
||||
config IEEE802154_I8SAK_PROGNAME
|
||||
string "Program name"
|
||||
default "i8"
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the name of the program that will be use when the NSH ELF
|
||||
program is installed.
|
||||
|
||||
config IEEE802154_I8SAK_PRIORITY
|
||||
int "i8sak task priority"
|
||||
default 100
|
||||
|
||||
config IEEE802154_I8SAK_STACKSIZE
|
||||
int "i8sak stack size"
|
||||
default 2048
|
||||
|
||||
endif
|
||||
|
39
wireless/ieee802154/i8sak/Make.defs
Normal file
39
wireless/ieee802154/i8sak/Make.defs
Normal file
@ -0,0 +1,39 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/i8sak/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2015 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_I8SAK),y)
|
||||
CONFIGURED_APPS += wireless/ieee802154/i8sak
|
||||
endif
|
138
wireless/ieee802154/i8sak/Makefile
Normal file
138
wireless/ieee802154/i8sak/Makefile
Normal file
@ -0,0 +1,138 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/i8sak/Makefile
|
||||
#
|
||||
# Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2014-2015 Sebastien Lorquet. All rights reserved.
|
||||
# Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
#
|
||||
# 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 $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# IEEE 802.15.4 SAK (swiss army knife )
|
||||
|
||||
APPNAME = i8
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 4096
|
||||
|
||||
# IEEE 802.15.4 SAK (Swiss Army Knife)
|
||||
|
||||
ASRCS =
|
||||
CSRCS =
|
||||
MAINSRC = i8sak_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
OBJS += $(MAINOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
|
||||
else
|
||||
INSTALL_DIR = $(BIN_DIR)
|
||||
endif
|
||||
|
||||
CONFIG_EXAMPLES_IEEEDUMP_PROGNAME ?= ieeedump$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_EXAMPLES_IEEEDUMP_PROGNAME)
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
|
||||
@echo "LD: $(PROGNAME)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
|
||||
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
|
||||
|
||||
else
|
||||
install:
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
364
wireless/ieee802154/i8sak/i8sak_main.c
Normal file
364
wireless/ieee802154/i8sak/i8sak_main.c
Normal file
@ -0,0 +1,364 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/i8sak/i8sak_main.c
|
||||
* IEEE 802.15.4 Swiss Army Knife
|
||||
*
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* This app can be used to control an IEEE 802.15.4 device from command line.
|
||||
* Example valid ieee802154 packets:
|
||||
*
|
||||
* Beacon request, seq number 01:
|
||||
* xx xx 01
|
||||
*
|
||||
* Simple data packet
|
||||
* from long address xx to long address yy, pan id pp for src and dest
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int tx(FAR const char *devname, FAR const char *str, int verbose);
|
||||
static int start_sniffer_daemon(FAR const char *devname);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t g_handle = 0;
|
||||
uint8_t g_txframe[IEEE802154_MAX_MAC_PAYLOAD_SIZE];
|
||||
static int sniffer_daemon(int argc, FAR char *argv[]);
|
||||
|
||||
bool g_sniffer_daemon_started = false;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name : start_sniff
|
||||
*
|
||||
* Description :
|
||||
* Starts a thread to run the sniffer in the background
|
||||
****************************************************************************/
|
||||
|
||||
static int start_sniffer_daemon(FAR const char *devname)
|
||||
{
|
||||
int ret;
|
||||
FAR const char *sniffer_argv[2];
|
||||
|
||||
printf("i8sak: Starting sniffer_daemon\n");
|
||||
|
||||
if (g_sniffer_daemon_started)
|
||||
{
|
||||
printf("i8sak: sniffer_daemon already running\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
sniffer_argv[0] = devname;
|
||||
sniffer_argv[1] = NULL;
|
||||
|
||||
ret = task_create("sniffer_daemon", CONFIG_IEEE802154_I8SAK_PRIORITY,
|
||||
CONFIG_IEEE802154_I8SAK_STACKSIZE, sniffer_daemon,
|
||||
(FAR char * const *)sniffer_argv);
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
printf("i8sak: ERROR: Failed to start sniffer_daemon: %d\n",
|
||||
errcode);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
g_sniffer_daemon_started = true;
|
||||
printf("i8sak: sniffer_daemon started\n");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name : sniffer_daemon
|
||||
*
|
||||
* Description :
|
||||
* Sniff for frames (Promiscuous mode)
|
||||
****************************************************************************/
|
||||
|
||||
static int sniffer_daemon(int argc, FAR char *argv[])
|
||||
{
|
||||
int ret, fd, i;
|
||||
struct mac802154dev_rxframe_s rx;
|
||||
|
||||
fd = open(argv[1], O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("cannot open %s, errno=%d\n", argv[1], errno);
|
||||
ret = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
printf("Listening...\n");
|
||||
|
||||
/* Enable promiscuous mode */
|
||||
|
||||
ret = ieee802154_setpromisc(fd, true);
|
||||
|
||||
/* Make sure receiver is always on while idle */
|
||||
|
||||
ret = ieee802154_setrxonidle(fd, true);
|
||||
|
||||
while(1)
|
||||
{
|
||||
ret = read(fd, &rx, sizeof(struct mac802154dev_rxframe_s));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("sniffer_daemon: read failed: %d\n", errno);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
printf("Frame Received:\n");
|
||||
|
||||
for (i = 0; i < rx.length; i++)
|
||||
{
|
||||
printf("%02X", rx.payload[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
errout:
|
||||
/* Turn receiver off when idle */
|
||||
|
||||
ret = ieee802154_setrxonidle(fd, false);
|
||||
|
||||
/* Disable promiscuous mode */
|
||||
|
||||
ret = ieee802154_setpromisc(fd, false);
|
||||
|
||||
printf("sniffer_daemon: closing");
|
||||
close(fd);
|
||||
g_sniffer_daemon_started = false;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name : tx
|
||||
*
|
||||
* Description :
|
||||
* Transmit a data frame.
|
||||
****************************************************************************/
|
||||
|
||||
static int tx(FAR const char *devname, FAR const char *str, int verbose)
|
||||
{
|
||||
struct mac802154dev_txframe_s tx;
|
||||
int ret, str_len, fd;
|
||||
int i = 0;
|
||||
|
||||
/* Open device */
|
||||
|
||||
fd = open(devname, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("cannot open %s, errno=%d\n", devname, errno);
|
||||
ret = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Set an application defined handle */
|
||||
|
||||
tx.meta.msdu_handle = g_handle++;
|
||||
|
||||
/* This is a normal transaction, no special handling */
|
||||
|
||||
tx.meta.msdu_flags.ack_tx = 0;
|
||||
tx.meta.msdu_flags.gts_tx = 0;
|
||||
tx.meta.msdu_flags.indirect_tx = 0;
|
||||
|
||||
tx.meta.ranging = IEEE802154_NON_RANGING;
|
||||
|
||||
tx.meta.src_addr_mode = IEEE802154_ADDRMODE_EXTENDED;
|
||||
tx.meta.dest_addr.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
tx.meta.dest_addr.saddr = 0xFADE;
|
||||
|
||||
str_len = strlen(str);
|
||||
|
||||
/* Each byte is represented by 2 chars */
|
||||
|
||||
tx.length = str_len >> 1;
|
||||
|
||||
/* Check if the number of chars is a multiple of 2 and that the number of
|
||||
* bytes does not exceed the max MAC frame payload supported */
|
||||
|
||||
if ((str_len & 1) || (tx.length > IEEE802154_MAX_MAC_PAYLOAD_SIZE))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Decode hex packet */
|
||||
|
||||
while (str_len > 0)
|
||||
{
|
||||
int dat;
|
||||
if (sscanf(str, "%2x", &dat) == 1)
|
||||
{
|
||||
g_txframe[i++] = dat;
|
||||
str += 2;
|
||||
str_len -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
for (i = 0; i < tx.length; i++)
|
||||
{
|
||||
printf("%02X", g_txframe[i]);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
tx.payload = &g_txframe[0];
|
||||
|
||||
ret = write(fd, &tx, sizeof(struct mac802154dev_txframe_s));
|
||||
if (ret == OK)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
printf(" OK\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" write: errno=%d\n",errno);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return ret;
|
||||
|
||||
error:
|
||||
printf("data error\n");
|
||||
close(fd);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* usage
|
||||
****************************************************************************/
|
||||
|
||||
int usage(void)
|
||||
{
|
||||
printf("i8 <devname> <op> [<args>]\n"
|
||||
" sniffer Listen for packets\n"
|
||||
" tx <hexpacket> Transmit a data frame\n"
|
||||
);
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* i8_main
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int i8_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
FAR const char *devname;
|
||||
FAR const char *cmdname;
|
||||
int ret = OK;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
printf("ERROR: Missing argument\n");
|
||||
return usage();
|
||||
}
|
||||
|
||||
devname = argv[1];
|
||||
cmdname = argv[2];
|
||||
|
||||
/* Get mode */
|
||||
|
||||
if (!strcmp(cmdname, "tx"))
|
||||
{
|
||||
ret = tx(devname, argv[3], TRUE);
|
||||
}
|
||||
else if(!strcmp(argv[2], "sniffer"))
|
||||
{
|
||||
ret = start_sniffer_daemon(devname);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = usage();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
11
wireless/ieee802154/libmac/.gitignore
vendored
Normal file
11
wireless/ieee802154/libmac/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/*.asm
|
||||
/*.obj
|
||||
/*.rel
|
||||
/*.lst
|
||||
/*.sym
|
||||
/*.adb
|
||||
/*.lib
|
||||
/*.src
|
11
wireless/ieee802154/libmac/Kconfig
Normal file
11
wireless/ieee802154/libmac/Kconfig
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# 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
|
||||
|
40
wireless/ieee802154/libmac/Make.defs
Normal file
40
wireless/ieee802154/libmac/Make.defs
Normal file
@ -0,0 +1,40 @@
|
||||
############################################################################
|
||||
# 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 += wireless/ieee802154/libmac
|
||||
endif
|
||||
|
128
wireless/ieee802154/libmac/Makefile
Normal file
128
wireless/ieee802154/libmac/Makefile
Normal file
@ -0,0 +1,128 @@
|
||||
############################################################################
|
||||
# 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 $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# libmac source files
|
||||
|
||||
ASRCS =
|
||||
# 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
|
||||
# Add Get/Set Attribute helpers
|
||||
CSRCS += ieee802154_setchan.c ieee802154_getchan.c
|
||||
CSRCS += ieee802154_setpanid.c ieee802154_getpanid.c
|
||||
CSRCS += ieee802154_setsaddr.c ieee802154_getsaddr.c
|
||||
CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c
|
||||
CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c
|
||||
CSRCS += ieee802154_setrxonidle.c ieee802154_getrxonidle.c
|
||||
CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c
|
||||
|
||||
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
||||
# Add Get/Set Attribute 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
|
||||
# Add IOCTL helpers
|
||||
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_setrxonidle.c sixlowpan_getrxonidle.c
|
||||
CSRCS += sixlowpan_settxpwr.c sixlowpan_gettxpwr.c
|
||||
endif
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
VPATH =
|
||||
|
||||
# Build targets
|
||||
|
||||
all: .built
|
||||
.PHONY: context .depend depend clean distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
install:
|
||||
|
||||
context:
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
68
wireless/ieee802154/libmac/ieee802154_assocreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_assocreq.c
Normal file
@ -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;
|
||||
}
|
72
wireless/ieee802154/libmac/ieee802154_assocresp.c
Normal file
72
wireless/ieee802154/libmac/ieee802154_assocresp.c
Normal file
@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
union ieee802154_macarg_u arg;
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, 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.assocresp, sizeof(struct ieee802154_assoc_resp_s));
|
||||
return OK;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_disassocreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_disassocreq.c
Normal file
@ -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;
|
||||
}
|
67
wireless/ieee802154/libmac/ieee802154_getchan.c
Normal file
67
wireless/ieee802154/libmac/ieee802154_getchan.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_getchan.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getchan(int fd, FAR uint8_t *chan)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*chan = req.attr_value.phy.channel;
|
||||
|
||||
return ret;
|
||||
}
|
67
wireless/ieee802154/libmac/ieee802154_geteaddr.c
Normal file
67
wireless/ieee802154/libmac/ieee802154_geteaddr.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
memcpy(eaddr, &req.attr_value.mac.eaddr[0], 8);
|
||||
|
||||
return ret;
|
||||
}
|
66
wireless/ieee802154/libmac/ieee802154_getpanid.c
Normal file
66
wireless/ieee802154/libmac/ieee802154_getpanid.c
Normal file
@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_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 <errno.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getpanid(int fd, FAR uint16_t *panid)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*panid = req.attr_value.mac.panid;
|
||||
|
||||
return ret;
|
||||
}
|
66
wireless/ieee802154/libmac/ieee802154_getpromisc.c
Normal file
66
wireless/ieee802154/libmac/ieee802154_getpromisc.c
Normal file
@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getpromisc(int fd, FAR bool *promisc)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*promisc = req.attr_value.mac.promisc_mode;
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_getreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_getreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
67
wireless/ieee802154/libmac/ieee802154_getrxonidle.c
Normal file
67
wireless/ieee802154/libmac/ieee802154_getrxonidle.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_getrxonidle.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
*
|
||||
* 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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getrxonidle(int fd, FAR bool *rxonidle)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_RX_ON_WHEN_IDLE;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*rxonidle = req.attr_value.mac.rxonidle;
|
||||
|
||||
return ret;
|
||||
}
|
66
wireless/ieee802154/libmac/ieee802154_getsaddr.c
Normal file
66
wireless/ieee802154/libmac/ieee802154_getsaddr.c
Normal file
@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getsaddr(int fd, FAR uint16_t *saddr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*saddr = req.attr_value.mac.saddr;
|
||||
|
||||
return ret;
|
||||
}
|
66
wireless/ieee802154/libmac/ieee802154_gettxpwr.c
Normal file
66
wireless/ieee802154/libmac/ieee802154_gettxpwr.c
Normal file
@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_gettxpwr.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*txpwr = req.attr_value.phy.txpwr;
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_gtsreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_gtsreq.c
Normal file
@ -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;
|
||||
}
|
72
wireless/ieee802154/libmac/ieee802154_orphanresp.c
Normal file
72
wireless/ieee802154/libmac/ieee802154_orphanresp.c
Normal file
@ -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;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_pollreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_pollreq.c
Normal file
@ -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;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_resetreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_resetreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* 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, FAR struct ieee802154_reset_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
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;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_rxenabreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_rxenabreq.c
Normal file
@ -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;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_scanreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_scanreq.c
Normal file
@ -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;
|
||||
}
|
64
wireless/ieee802154/libmac/ieee802154_setchan.c
Normal file
64
wireless/ieee802154/libmac/ieee802154_setchan.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_setchan.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setchan(int fd, uint8_t chan)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
|
||||
req.attr_value.phy.channel = chan;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
65
wireless/ieee802154/libmac/ieee802154_seteaddr.c
Normal file
65
wireless/ieee802154/libmac/ieee802154_seteaddr.c
Normal file
@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_eaddr.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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 ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
|
||||
memcpy(&req.attr_value.mac.eaddr[0], eaddr, 8);
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
64
wireless/ieee802154/libmac/ieee802154_setpanid.c
Normal file
64
wireless/ieee802154/libmac/ieee802154_setpanid.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_setpanid.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setpanid(int fd, uint16_t panid)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
|
||||
req.attr_value.mac.panid = panid;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
65
wireless/ieee802154/libmac/ieee802154_setpromisc.c
Normal file
65
wireless/ieee802154/libmac/ieee802154_setpromisc.c
Normal file
@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_setpromisc.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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 <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setpromisc(int fd, bool promisc)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
|
||||
req.attr_value.mac.promisc_mode = promisc;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_setreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_setreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
65
wireless/ieee802154/libmac/ieee802154_setrxonidle.c
Normal file
65
wireless/ieee802154/libmac/ieee802154_setrxonidle.c
Normal file
@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_setrxonidle.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
*
|
||||
* 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 <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setrxonidle(int fd, bool rxonidle)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_RX_ON_WHEN_IDLE;
|
||||
req.attr_value.mac.rxonidle = rxonidle;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
64
wireless/ieee802154/libmac/ieee802154_setsaddr.c
Normal file
64
wireless/ieee802154/libmac/ieee802154_setsaddr.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_setsaddr.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setsaddr(int fd, uint16_t saddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
|
||||
req.attr_value.mac.saddr = saddr;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
63
wireless/ieee802154/libmac/ieee802154_settxpwr.c
Normal file
63
wireless/ieee802154/libmac/ieee802154_settxpwr.c
Normal file
@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_settxpwr.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_settxpwr(int fd, int32_t txpwr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
|
||||
req.attr_value.phy.txpwr = txpwr;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_startreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_startreq.c
Normal file
@ -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;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_syncreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_syncreq.c
Normal file
@ -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;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_assocreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_assocreq.c
Normal file
@ -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;
|
||||
}
|
76
wireless/ieee802154/libmac/sixlowpan_assocresp.c
Normal file
76
wireless/ieee802154/libmac/sixlowpan_assocresp.c
Normal file
@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
* 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);
|
||||
|
||||
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;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_disassocreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_disassocreq.c
Normal file
@ -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;
|
||||
}
|
67
wireless/ieee802154/libmac/sixlowpan_getchan.c
Normal file
67
wireless/ieee802154/libmac/sixlowpan_getchan.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*chan = req.attr_value.phy.channel;
|
||||
|
||||
return ret;
|
||||
}
|
67
wireless/ieee802154/libmac/sixlowpan_geteaddr.c
Normal file
67
wireless/ieee802154/libmac/sixlowpan_geteaddr.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
memcpy(eaddr, &req.attr_value.mac.eaddr[0], 8);
|
||||
|
||||
return ret;
|
||||
}
|
67
wireless/ieee802154/libmac/sixlowpan_getpanid.c
Normal file
67
wireless/ieee802154/libmac/sixlowpan_getpanid.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*panid = req.attr_value.mac.panid;
|
||||
|
||||
return ret;
|
||||
}
|
67
wireless/ieee802154/libmac/sixlowpan_getpromisc.c
Normal file
67
wireless/ieee802154/libmac/sixlowpan_getpromisc.c
Normal file
@ -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.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*promisc = req.attr_value.mac.promisc_mode;
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_getreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_getreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* 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);
|
||||
memcpy(&arg.u.getreq, req, sizeof(struct ieee802154_get_req_s));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
67
wireless/ieee802154/libmac/sixlowpan_getrxonidle.c
Normal file
67
wireless/ieee802154/libmac/sixlowpan_getrxonidle.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_getrxonidle.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_getrxonidle(int sock, FAR const char *ifname, FAR bool *rxonidle)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_RX_ON_WHEN_IDLE;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*rxonidle = req.attr_value.mac.rxonidle;
|
||||
|
||||
return ret;
|
||||
}
|
67
wireless/ieee802154/libmac/sixlowpan_getsaddr.c
Normal file
67
wireless/ieee802154/libmac/sixlowpan_getsaddr.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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 <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*saddr = req.attr_value.mac.saddr;
|
||||
|
||||
return ret;
|
||||
}
|
67
wireless/ieee802154/libmac/sixlowpan_gettxpwr.c
Normal file
67
wireless/ieee802154/libmac/sixlowpan_gettxpwr.c
Normal file
@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*txpwr = req.attr_value.phy.txpwr;
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_gtsreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_gtsreq.c
Normal file
@ -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;
|
||||
}
|
76
wireless/ieee802154/libmac/sixlowpan_orphanresp.c
Normal file
76
wireless/ieee802154/libmac/sixlowpan_orphanresp.c
Normal file
@ -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;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_pollreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_pollreq.c
Normal file
@ -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;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_resetreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_resetreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* 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,
|
||||
FAR const struct ieee802154_reset_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.resetreq, req, sizeof(struct ieee802154_reset_req_s));
|
||||
|
||||
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;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_rxenabreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_rxenabreq.c
Normal file
@ -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;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_scanreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_scanreq.c
Normal file
@ -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;
|
||||
}
|
64
wireless/ieee802154/libmac/sixlowpan_setchan.c
Normal file
64
wireless/ieee802154/libmac/sixlowpan_setchan.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
|
||||
req.attr_value.phy.channel = chan;
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
64
wireless/ieee802154/libmac/sixlowpan_seteaddr.c
Normal file
64
wireless/ieee802154/libmac/sixlowpan_seteaddr.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
|
||||
memcpy(&req.attr_value.mac.eaddr[0], eaddr, 8);
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
64
wireless/ieee802154/libmac/sixlowpan_setpanid.c
Normal file
64
wireless/ieee802154/libmac/sixlowpan_setpanid.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
|
||||
req.attr_value.mac.panid = panid;
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
65
wireless/ieee802154/libmac/sixlowpan_setpromisc.c
Normal file
65
wireless/ieee802154/libmac/sixlowpan_setpromisc.c
Normal file
@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
|
||||
req.attr_value.mac.promisc_mode = promisc;
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_setreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_setreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
65
wireless/ieee802154/libmac/sixlowpan_setrxonidle.c
Normal file
65
wireless/ieee802154/libmac/sixlowpan_setrxonidle.c
Normal file
@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_setrxonidle.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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_setrxonidle(int sock, FAR const char *ifname, bool rxonidle)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_RX_ON_WHEN_IDLE;
|
||||
req.attr_value.mac.rxonidle = rxonidle;
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
64
wireless/ieee802154/libmac/sixlowpan_setsaddr.c
Normal file
64
wireless/ieee802154/libmac/sixlowpan_setsaddr.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
|
||||
req.attr_value.mac.saddr = saddr;
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
64
wireless/ieee802154/libmac/sixlowpan_settxpwr.c
Normal file
64
wireless/ieee802154/libmac/sixlowpan_settxpwr.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/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/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
|
||||
req.attr_value.phy.txpwr = txpwr;
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_startreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_startreq.c
Normal file
@ -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;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_syncreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_syncreq.c
Normal file
@ -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;
|
||||
}
|
11
wireless/ieee802154/libutils/.gitignore
vendored
Normal file
11
wireless/ieee802154/libutils/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/*.asm
|
||||
/*.obj
|
||||
/*.rel
|
||||
/*.lst
|
||||
/*.sym
|
||||
/*.adb
|
||||
/*.lib
|
||||
/*.src
|
11
wireless/ieee802154/libutils/Kconfig
Normal file
11
wireless/ieee802154/libutils/Kconfig
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config IEEE802154_LIBUTILS
|
||||
bool "Common IEEE 802.15.4 library routines"
|
||||
default n
|
||||
---help---
|
||||
Some common library routines for ieee 802.15.4 apps
|
||||
|
40
wireless/ieee802154/libutils/Make.defs
Normal file
40
wireless/ieee802154/libutils/Make.defs
Normal file
@ -0,0 +1,40 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/libutils/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2016-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_IEEE802154_LIBUTILS),y)
|
||||
CONFIGURED_APPS += wireless/ieee802154/libutils
|
||||
endif
|
||||
|
98
wireless/ieee802154/libutils/Makefile
Normal file
98
wireless/ieee802154/libutils/Makefile
Normal file
@ -0,0 +1,98 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/libmac/Makefile
|
||||
#
|
||||
# Copyright (C) 2016-2-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# libutils source files
|
||||
|
||||
ASRCS =
|
||||
CSRCS += ieee802154_addrtostr.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
VPATH =
|
||||
|
||||
# Build targets
|
||||
|
||||
all: .built
|
||||
.PHONY: context .depend depend clean distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
install:
|
||||
|
||||
context:
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
91
wireless/ieee802154/libutils/ieee802154_addrtostr.c
Normal file
91
wireless/ieee802154/libutils/ieee802154_addrtostr.c
Normal file
@ -0,0 +1,91 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libutils/ieee802154_addrtostr.c
|
||||
*
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_addrtostr(FAR char *buf, int len,
|
||||
FAR struct ieee802154_addr_s *addr)
|
||||
{
|
||||
#ifndef CONFIG_BIG_ENDIAN
|
||||
uint16_t panid = ((addr->panid & 0xff) << 8) | ((addr->panid >> 8) & 0xff);
|
||||
#else
|
||||
uint16_t panid = addr->panid;
|
||||
#endif
|
||||
|
||||
if (addr->mode == IEEE802154_ADDRMODE_NONE)
|
||||
{
|
||||
return snprintf(buf, len, "none");
|
||||
}
|
||||
else if (addr->mode == IEEE802154_ADDRMODE_SHORT)
|
||||
{
|
||||
#ifndef CONFIG_BIG_ENDIAN
|
||||
uint16_t saddr = ((addr->saddr & 0xff) << 8) | ((addr->saddr >> 8) & 0xff);
|
||||
#else
|
||||
uint16_t saddr = addr->saddr;
|
||||
#endif
|
||||
return snprintf(buf, len, "%04X/%04X", panid, saddr);
|
||||
}
|
||||
else if (addr->mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||
{
|
||||
int i;
|
||||
int off = snprintf(buf, len, "%04X/", panid);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
off += snprintf(buf + off, len -off, "%02X", addr->eaddr[i]);
|
||||
}
|
||||
|
||||
return off;
|
||||
}
|
||||
else
|
||||
{
|
||||
return snprintf(buf,len,"<INVAL>");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
34
wireless/iwpan/Kconfig
Normal file
34
wireless/iwpan/Kconfig
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
menuconfig WIRELESS_IWPAN
|
||||
bool "IEEE 802.15.4 Command Line Tool"
|
||||
default n
|
||||
depends on NET && DRIVERS_WIRELESS
|
||||
select IEEE802154_LIBMAC
|
||||
select IEEE802154_LIBUTILS
|
||||
---help---
|
||||
IWPAN is a tool similar to wapi and inspired by iwpan on Linux that can
|
||||
be used to manage 802.15.4 PAN.
|
||||
|
||||
if WIRELESS_IWPAN
|
||||
|
||||
config WIRELESS_IWPAN_PROGNAME
|
||||
string "Program Name"
|
||||
default "iwpan"
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the name of the program that will be use when the NSH ELF
|
||||
program is installed.
|
||||
|
||||
config WIRELESS_IWPAN_STACKSIZE
|
||||
int "Stack Size (bytes)"
|
||||
default 2048
|
||||
|
||||
config WIRELESS_IWPAN_PRIORITY
|
||||
int "Command Priority"
|
||||
default 100
|
||||
|
||||
endif
|
41
wireless/iwpan/Make.defs
Normal file
41
wireless/iwpan/Make.defs
Normal file
@ -0,0 +1,41 @@
|
||||
############################################################################
|
||||
# apps/wireless/iwpan/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
# Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
#
|
||||
# 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_WIRELESS_IWPAN),y)
|
||||
CONFIGURED_APPS += wireless/iwpan
|
||||
endif
|
||||
|
150
wireless/iwpan/Makefile
Normal file
150
wireless/iwpan/Makefile
Normal file
@ -0,0 +1,150 @@
|
||||
############################################################################
|
||||
# apps/wireless/iwpan/Makefile
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
# Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# TODO, this makefile should run make under the app dirs, instead of
|
||||
# sourcing the Make.defs!
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# IEEE802.11 Wapi Application
|
||||
|
||||
CONFIG_WIRELESS_IWPAN_PRIORITY ?= 100
|
||||
CONFIG_WIRELESS_IWPAN_STACKSIZE ?= 2048
|
||||
|
||||
APPNAME = iwpan
|
||||
PRIORITY = $(CONFIG_WIRELESS_IWPAN_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_WIRELESS_IWPAN_STACKSIZE)
|
||||
|
||||
ASRCS =
|
||||
CSRCS =
|
||||
MAINSRC =
|
||||
|
||||
VPATH = .
|
||||
|
||||
include $(APPDIR)/wireless/iwpan/src/Make.defs
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
OBJS += $(MAINOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
|
||||
else
|
||||
INSTALL_DIR = $(BIN_DIR)
|
||||
endif
|
||||
|
||||
CONFIG_IWPAN_PROGNAME ?= iwpan$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_IWPAN_PROGNAME)
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Common build
|
||||
|
||||
all: .built
|
||||
.PHONY: context depend clean distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
$(Q) touch .built
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
|
||||
@echo "LD: $(PROGNAME)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
|
||||
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
|
||||
|
||||
else
|
||||
install:
|
||||
|
||||
endif
|
||||
|
||||
# Register application
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
# Create dependencies
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
.PHONY: preconfig
|
||||
preconfig:
|
47
wireless/iwpan/src/Make.defs
Normal file
47
wireless/iwpan/src/Make.defs
Normal file
@ -0,0 +1,47 @@
|
||||
############################################################################
|
||||
# apps/wireless/iwpan/src/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
# Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
#
|
||||
# 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_WIRELESS_IWPAN),y)
|
||||
|
||||
CSRCS =
|
||||
MAINSRC = iwpan.c
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/wireless/iwpan/src}
|
||||
|
||||
endif
|
||||
|
774
wireless/iwpan/src/iwpan.c
Normal file
774
wireless/iwpan/src/iwpan.c
Normal file
@ -0,0 +1,774 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/iwpan/src/iwpan.c
|
||||
*
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - 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.
|
||||
*
|
||||
* 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 <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
#include "wireless/iwpan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The address family that we used to create the socket really does not
|
||||
* matter. It should, however, be valid in the current configuration.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NET_IPv4)
|
||||
# define PF_INETX PF_INET
|
||||
#elif defined(CONFIG_NET_IPv6)
|
||||
# define PF_INETX PF_INET6
|
||||
#endif
|
||||
|
||||
/* SOCK_DGRAM is the preferred socket type to use when we just want a
|
||||
* socket for performing driver ioctls. However, we can't use SOCK_DRAM
|
||||
* if UDP is disabled.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
# define SOCK_IWPAN SOCK_DGRAM
|
||||
#else
|
||||
# define SOCK_IWPAN SOCK_STREAM
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Describes one command */
|
||||
|
||||
struct iwpan_command_s
|
||||
{
|
||||
FAR const char *name;
|
||||
uint8_t noptions;
|
||||
CODE void *handler;
|
||||
};
|
||||
|
||||
/* Generic form of a command handler */
|
||||
|
||||
typedef void (*cmd1_t)(int sock, FAR const char *arg1);
|
||||
typedef void (*cmd2_t)(int sock, FAR const char *arg1,
|
||||
FAR const char *arg2);
|
||||
typedef void (*cmd3_t)(int sock, FAR const char *arg1,
|
||||
FAR const char *arg2, FAR const char *arg3);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_show_cmd(int sock, FAR const char *ifname);
|
||||
static void iwpan_cca_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *ccastr);
|
||||
static void iwpan_chan_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *chanstr);
|
||||
static void iwpan_devmode_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *modstr);
|
||||
static void iwpan_eaddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr);
|
||||
static void iwpan_panid_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *panstr);
|
||||
static void iwpan_promisc_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *boolstr);
|
||||
static void iwpan_saddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr);
|
||||
static void iwpan_txpwr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *pwrstr);
|
||||
|
||||
static void iwpan_showusage(FAR const char *progname, int exitcode);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct iwpan_command_s g_iwpan_commands[] =
|
||||
{
|
||||
{"help", 0, (CODE void *)NULL},
|
||||
{"show", 1, (CODE void *)iwpan_show_cmd},
|
||||
{"cca", 2, (CODE void *)iwpan_cca_cmd},
|
||||
{"chan", 2, (CODE void *)iwpan_chan_cmd},
|
||||
{"devmode", 2, (CODE void *)iwpan_devmode_cmd},
|
||||
{"eaddr", 2, (CODE void *)iwpan_eaddr_cmd},
|
||||
{"panid", 2, (CODE void *)iwpan_panid_cmd},
|
||||
{"promisc", 2, (CODE void *)iwpan_promisc_cmd},
|
||||
{"saddr", 2, (CODE void *)iwpan_saddr_cmd},
|
||||
{"txpwr", 2, (CODE void *)iwpan_txpwr_cmd},
|
||||
};
|
||||
|
||||
#define NCOMMANDS (sizeof(g_iwpan_commands) / sizeof(struct iwpan_command_s))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2long
|
||||
*
|
||||
* Description:
|
||||
* Convert a string to an integer value
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static long iwpan_str2long(FAR const char *str)
|
||||
{
|
||||
FAR char *endptr;
|
||||
long value;
|
||||
|
||||
value = strtol(str, &endptr, 0);
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Garbage after numeric argument\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (value > INT_MAX || value < INT_MIN)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Integer value out of range\n");
|
||||
return LONG_MAX;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2luint8
|
||||
*
|
||||
* Description:
|
||||
* Convert a string to an integer value
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t iwpan_str2luint8(FAR const char *str)
|
||||
{
|
||||
long value = iwpan_str2long(str);
|
||||
if (value < 0 || value > UINT8_MAX)
|
||||
{
|
||||
fprintf(stderr, "ERROR: 8-bit value out of range\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return (uint8_t)value;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2luint16
|
||||
*
|
||||
* Description:
|
||||
* Convert a string to an integer value
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint16_t iwpan_str2luint16(FAR const char *str)
|
||||
{
|
||||
long value = iwpan_str2long(str);
|
||||
if (value < 0 || value > UINT16_MAX)
|
||||
{
|
||||
fprintf(stderr, "ERROR: 16-bit value out of range\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return (uint8_t)value;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_char2nibble
|
||||
*
|
||||
* Description:
|
||||
* Convert an hexadecimal character to a 4-bit nibble.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t iwpan_char2nibble(char ch)
|
||||
{
|
||||
if (ch >= '0' && ch <= '9')
|
||||
{
|
||||
return ch - '0';
|
||||
}
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
{
|
||||
return ch - 'a' + 10;
|
||||
}
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
{
|
||||
return ch - 'A' + 10;
|
||||
}
|
||||
else if (ch == '\0')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unexpected end hex\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unexpected character in hex value: %02x\n", ch);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2eaddr
|
||||
*
|
||||
* Description:
|
||||
* Convert a string 8-byte EADAR array.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_str2eaddr(FAR const char *str, FAR uint8_t *eaddr)
|
||||
{
|
||||
FAR const char *src = str;
|
||||
uint8_t bvalue;
|
||||
char ch;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
bvalue = iwpan_char2nibble(ch) << 4;
|
||||
|
||||
ch = (char)*src++;
|
||||
bvalue |= iwpan_char2nibble(ch);
|
||||
|
||||
*eaddr++ = bvalue;
|
||||
|
||||
if (i < 7)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
if (ch != ':')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing colon separator: %s\n", str);
|
||||
fprintf(stderr, " Expected xx:xx:xx:xx:xx:xx:xx:xx\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2bool
|
||||
*
|
||||
* Description:
|
||||
* Convert a boolean name to a boolean value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static bool iwpan_str2bool(FAR const char *str)
|
||||
{
|
||||
if (strcasecmp(str, "true") == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (strcasecmp(str, "false") == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Invalid boolean name: %s\n", str);
|
||||
fprintf(stderr, " Expected true or false\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_show_cmd
|
||||
*
|
||||
* Description:
|
||||
* Show all radio device settings
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_show_cmd(int sock, FAR const char *ifname)
|
||||
{
|
||||
uint8_t eaddr[IEEE802154_EADDR_LEN] =
|
||||
{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
struct ieee802154_cca_s cca;
|
||||
uint8_t b;
|
||||
} u;
|
||||
|
||||
int32_t txpwr = INT32_MAX;
|
||||
uint16_t saddr = UINT16_MAX;
|
||||
uint16_t panid = UINT16_MAX;
|
||||
uint8_t chan = UINT8_MAX;
|
||||
uint8_t devmode = UINT8_MAX;
|
||||
bool promisc = false;
|
||||
bool energy = false;
|
||||
int ret;
|
||||
|
||||
u.b = 0xff;
|
||||
|
||||
/* Read all parameters from the radio */
|
||||
|
||||
ret = sixlowpan_getchan(sock, ifname, &chan);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getchan() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getpanid(sock, ifname, &panid);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getpanid() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getsaddr(sock, ifname, &saddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getsaddr() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_geteaddr(sock, ifname, eaddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_geteaddr() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getpromisc(sock, ifname, &promisc);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getpromisc() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getdevmode(sock, ifname, &devmode);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getdevmode() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_gettxpwr(sock, ifname, &txpwr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_gettxpwr() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getcca(sock, ifname, &u.cca);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getcca() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_energydetect(sock, ifname, &energy);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_energydetect() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
/* And generate the output */
|
||||
|
||||
fprintf(stderr, "\nRadio Settings (%s):\n", ifname);
|
||||
fprintf(stderr, " chan: %u\n", chan);
|
||||
fprintf(stderr, " saddr: %04x\n", saddr);
|
||||
fprintf(stderr, " eaddr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5],
|
||||
eaddr[6], eaddr[7]);
|
||||
fprintf(stderr, " panid: %04x\n", panid);
|
||||
fprintf(stderr, " devmode: %u\n", devmode);
|
||||
fprintf(stderr, " promisc: %s\n", promisc ? "true" : "false");
|
||||
fprintf(stderr, " cca: %02x\n", u.b);
|
||||
fprintf(stderr, " txpwr: %ld\n", (long)txpwr);
|
||||
fprintf(stderr, " ernergy: %s\n", energy ? "true" : "false");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_cca_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device Clear Channel Assessment (CCA) thresholds.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_cca_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *ccastr)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct ieee802154_cca_s cca;
|
||||
uint8_t b;
|
||||
} u;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
u.b = iwpan_str2luint8(ccastr);
|
||||
|
||||
/* Set the CCA */
|
||||
|
||||
ret = sixlowpan_setcca(sock, ifname, &u.cca);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setcca() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_chan_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device channel
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_chan_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *chanstr)
|
||||
{
|
||||
uint8_t chan;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
chan = iwpan_str2luint8(chanstr);
|
||||
|
||||
/* Set the channel */
|
||||
|
||||
ret = sixlowpan_setchan(sock, ifname, chan);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setchan() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_devmode_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device mode
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_devmode_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *modestr)
|
||||
{
|
||||
uint8_t devmode;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
devmode = iwpan_str2luint8(modestr);
|
||||
|
||||
/* Set the devmode */
|
||||
|
||||
ret = sixlowpan_setdevmode(sock, ifname, devmode);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR:int sixlowpan_setdevmode() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_eaddr_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device extended address
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_eaddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr)
|
||||
{
|
||||
uint8_t eaddr[IEEE802154_EADDR_LEN];
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
iwpan_str2eaddr(addrstr, eaddr);
|
||||
|
||||
/* Set the extended address */
|
||||
|
||||
ret = sixlowpan_seteaddr(sock, ifname, eaddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_seteaddr() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_panid_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device PAN ID.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_panid_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *panstr)
|
||||
{
|
||||
uint16_t panid;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
panid = iwpan_str2luint16(panstr);
|
||||
|
||||
/* Set the PAN ID */
|
||||
|
||||
ret = sixlowpan_setpanid(sock, ifname, panid);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setpanid() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_promisc_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device PAN ID.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_promisc_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *boolstr)
|
||||
{
|
||||
bool promisc;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
promisc = iwpan_str2bool(boolstr);
|
||||
|
||||
/* Set the promisc */
|
||||
|
||||
ret = sixlowpan_setpromisc(sock, ifname, promisc);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setpromisc() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_saddr_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device short address
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_saddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr)
|
||||
{
|
||||
uint16_t saddr;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
saddr = iwpan_str2luint16(addrstr);
|
||||
|
||||
/* Set the short address */
|
||||
|
||||
ret = sixlowpan_setsaddr(sock, ifname, saddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setsaddr() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_txpwr_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device TX power
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_txpwr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *pwrstr)
|
||||
{
|
||||
long txpwr;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
txpwr = iwpan_str2long(pwrstr);
|
||||
|
||||
/* Set the TX power */
|
||||
|
||||
ret = sixlowpan_settxpwr(sock, ifname, (int32_t)txpwr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_settxpwr() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_showusage
|
||||
*
|
||||
* Description:
|
||||
* Show program usage.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_showusage(FAR const char *progname, int exitcode)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n", progname);
|
||||
fprintf(stderr, "\t%s <command> <ifname> [OPTIONS]\n", progname);
|
||||
fprintf(stderr, "\nWhere supported commands an [OPTIONS] appear below\n");
|
||||
fprintf(stderr, "\nRadio Query:\n");
|
||||
fprintf(stderr, "\t%s show <ifname>\n", progname);
|
||||
fprintf(stderr, "\nRadio Settings:\n");
|
||||
fprintf(stderr, "\t%s cca <ifname> <hex cca>\n", progname);
|
||||
fprintf(stderr, "\t%s chan <ifname> <channel>\n", progname);
|
||||
fprintf(stderr, "\t%s devmode <ifname> <devmode>\n", progname);
|
||||
fprintf(stderr, "\t%s eaddr <ifname> <eaddr>\n", progname);
|
||||
fprintf(stderr, "\t%s panid <ifname> <panid>\n", progname);
|
||||
fprintf(stderr, "\t%s promisc <ifname> <true|false>\n", progname);
|
||||
fprintf(stderr, "\t%s saddr <ifname> <saddr>\n", progname);
|
||||
fprintf(stderr, "\t%s txpwr <ifname> <txpwr>\n", progname);
|
||||
fprintf(stderr, "\nMAC Commands:\n");
|
||||
fprintf(stderr, "\t%s assoc <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s disassoc <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s get <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s gts <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s poll <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s rxenab <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s scan <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s set <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s start <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s sync <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\nWhere:\n");
|
||||
fprintf(stderr, "\t<eaddr> must be entered as xx:xx:xx:xx:xx:xx:xx\n");
|
||||
exit(exitcode);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int iwpan_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
FAR const char *cmdname;
|
||||
FAR const struct iwpan_command_s *iwpancmd;
|
||||
int sock;
|
||||
int i;
|
||||
|
||||
/* Get the command */
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing command\n");
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cmdname = argv[1];
|
||||
|
||||
/* Find the command in the g_iwpan_command[] list */
|
||||
|
||||
iwpancmd = NULL;
|
||||
for (i = 0; i < NCOMMANDS; i++)
|
||||
{
|
||||
FAR const struct iwpan_command_s *cmd = &g_iwpan_commands[i];
|
||||
if (strcmp(cmdname, cmd->name) == 0)
|
||||
{
|
||||
iwpancmd = cmd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (iwpancmd == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unsupported command: %s\n", cmdname);
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (iwpancmd->noptions + 2 < argc)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Garbage at end of command ignored\n");
|
||||
}
|
||||
else if (iwpancmd->noptions + 2 > argc)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing required command options: %s\n",
|
||||
cmdname);
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Special case the help command which has no arguments, no handler,
|
||||
* and does not need a socket.
|
||||
*/
|
||||
|
||||
if (iwpancmd->handler == NULL)
|
||||
{
|
||||
iwpan_showusage(argv[0], EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Create a communication socket */
|
||||
|
||||
sock = socket(PF_INETX, SOCK_IWPAN, 0);
|
||||
if (sock < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: iwpan_make_socket() failed: %d\n", sock);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Dispatch the command handling */
|
||||
|
||||
switch (iwpancmd->noptions)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
fprintf(stderr, "ERROR: Internal craziness\n");
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
|
||||
case 1:
|
||||
((cmd1_t)iwpancmd->handler)(sock, argv[2]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
((cmd2_t)iwpancmd->handler)(sock, argv[2], argv[3]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
((cmd3_t)iwpancmd->handler)(sock, argv[2], argv[3], argv[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Close communication socket */
|
||||
|
||||
close(sock);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
|
||||
menuconfig WIRELESS_WAPI
|
||||
bool "IEEE802.11 Configuration Library"
|
||||
bool "IEEE 802.11 Configuration Library"
|
||||
default n
|
||||
depends on NET && DRIVERS_WIRELESS && EXPERIMENTAL
|
||||
---help---
|
||||
@ -14,7 +14,7 @@ menuconfig WIRELESS_WAPI
|
||||
if WIRELESS_WAPI
|
||||
|
||||
config WIRELESS_WAPI_CMDTOOL
|
||||
bool "IEEE802.11 Command Line Tool"
|
||||
bool "IEEE 802.11 Command Line Tool"
|
||||
default n
|
||||
---help---
|
||||
By default, Wapi is build as only a library. If this option is
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/wapi/examples/network.c
|
||||
*
|
||||
* Copyright (C) 2011, 2017Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Adapted for Nuttx from WAPI:
|
||||
|
@ -62,7 +62,7 @@ struct wapi_command_s
|
||||
CODE void *handler;
|
||||
};
|
||||
|
||||
/* Generic form of a commnd handler */
|
||||
/* Generic form of a command handler */
|
||||
|
||||
typedef void (*cmd1_t)(int sock, FAR const char *arg1);
|
||||
typedef void (*cmd2_t)(int sock, FAR const char *arg1,
|
||||
|
Loading…
Reference in New Issue
Block a user