Merged in merlin17/apps/ieee802154 (pull request #76)

wireless/ieee802154:  Removes libradio to coincide with removal of ioctl with radio

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Anthony Merlino 2017-05-05 15:26:56 +00:00 committed by Gregory Nutt
commit 782c55fbb5
58 changed files with 328 additions and 2854 deletions

View File

@ -43,82 +43,14 @@
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/config.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* libradio *****************************************************************/
/* Character driver IOCTL 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_setdevmode(int fd, uint8_t devmode);
int ieee802154_getdevmode(int fd, FAR uint8_t *devmode);
int ieee802154_settxpwr(int fd, int32_t txpwr);
int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr);
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca);
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca);
int ieee802154_energydetect(int fd, FAR bool *energy);
#ifdef CONFIG_NET_6LOWPAN
/* Netork driver IOCTL helpers */
int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan);
int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan);
int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid);
int sixlowpan_getpanid(int sock, FAR const char *ifname,
FAR uint16_t *panid);
int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr);
int sixlowpan_getsaddr(int sock, FAR const char *ifname,
FAR uint16_t *saddr);
int sixlowpan_seteaddr(int sock, FAR const char *ifname,
FAR const uint8_t *eaddr);
int sixlowpan_geteaddr(int sock, FAR const char *ifname,
FAR uint8_t *eaddr);
int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc);
int sixlowpan_getpromisc(int sock, FAR const char *ifname,
FAR bool *promisc);
int sixlowpan_setdevmode(int sock, FAR const char *ifname, uint8_t devmode);
int sixlowpan_getdevmode(int sock, FAR const char *ifname,
FAR uint8_t *devmode);
int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr);
int sixlowpan_gettxpwr(int sock, FAR const char *ifname,
FAR int32_t *txpwr);
int sixlowpan_setcca(int sock, FAR const char *ifname,
FAR struct ieee802154_cca_s *cca);
int sixlowpan_getcca(int sock, FAR const char *ifname,
FAR struct ieee802154_cca_s *cca);
int sixlowpan_energydetect(int sock, FAR const char *ifname,
FAR bool *energy);
#endif /* CONFIG_NET_6LOWPAN*/
/* libmac *******************************************************************/
/* Character driver IOCTL helpers */
@ -151,6 +83,29 @@ 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_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 */
@ -192,16 +147,47 @@ int sixlowpan_sounding_req(int sock, FAR const char *ifname,
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_setdevmode(int sock, FAR const char *ifname, uint8_t devmode);
int sixlowpan_getdevmode(int sock, FAR const char *ifname,
FAR uint8_t *devmode);
int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr);
int sixlowpan_gettxpwr(int sock, FAR const char *ifname,
FAR int32_t *txpwr);
int sixlowpan_setcca(int sock, FAR const char *ifname,
FAR struct ieee802154_cca_s *cca);
int sixlowpan_getcca(int sock, FAR const char *ifname,
FAR struct ieee802154_cca_s *cca);
int sixlowpan_energydetect(int sock, FAR const char *ifname,
FAR bool *energy);
#endif /* CONFIG_NET_6LOWPAN*/
/* libutils *****************************************************************/
int ieee802154_addrparse(FAR struct ieee802154_packet_s *inpacket,
FAR struct ieee802154_addr_s *dest,
FAR struct ieee802154_addr_s *src);
int ieee802154_addrstore(FAR struct ieee802154_packet_s *inpacket,
FAR struct ieee802154_addr_s *dest,
FAR struct ieee802154_addr_s *src);
int ieee802154_addrtostr(FAR char *buf, int len,
FAR struct ieee802154_addr_s *addr);

View File

@ -7,7 +7,6 @@ config NETUTILS_NETLIB
bool "Network support library"
default n
depends on NET
select IEEE802154_LIBRADIO if DRIVERS_IEEE802154
select IEEE802154_LIBMAC if WIRELESS_IEEE802154
---help---
Enable support for the network support library.

View File

@ -81,7 +81,7 @@ int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid)
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
/* Use the helper provided in libradio */
/* Use the helper provided in libmac */
ret = sixlowpan_getpanid(sockfd, ifname, panid);
close(sockfd);

View File

@ -81,7 +81,7 @@ int netlib_setpanid(FAR const char *ifname, uint16_t panid)
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
/* Use the helper provided in libradio */
/* Use the helper provided in libmac */
ret = sixlowpan_setpanid(sockfd, ifname, panid);
close(sockfd);

View File

@ -5,10 +5,8 @@
menu "IEEE 802.15.4 applications"
source "$APPSDIR/wireless/ieee802154/libradio/Kconfig"
source "$APPSDIR/wireless/ieee802154/libmac/Kconfig"
source "$APPSDIR/wireless/ieee802154/libutils/Kconfig"
source "$APPSDIR/wireless/ieee802154/coord/Kconfig"
source "$APPSDIR/wireless/ieee802154/i8sak/Kconfig"
endmenu #ieee 802.15.4 apps

View File

@ -1,5 +1,5 @@
############################################################################
# apps/wireless/ieee802154/libradio/Make.defs
# apps/wireless/ieee802154/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.

View File

@ -1,11 +0,0 @@
/Make.dep
/.depend
/.built
/*.asm
/*.obj
/*.rel
/*.lst
/*.sym
/*.adb
/*.lib
/*.src

View File

@ -1,24 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config IEEE802154_COORD
bool "Generic IEEE 802.15.4 coordinator"
default n
select IEEE802154_LIBRADIO
select IEEE802154_LIBUTILS
---help---
Enable the IEEE 802.15.4 generic coordinator
if IEEE802154_COORD
config IEEE802154_COORD_PROGNAME
string "Program name"
default "coord"
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
endif

View File

@ -1,39 +0,0 @@
############################################################################
# apps/wireless/ieee802154/coord/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_COORD),y)
CONFIGURED_APPS += wireless/ieee802154/coord
endif

View File

@ -1,138 +0,0 @@
############################################################################
# apps/wireless/ieee802154/coord/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
# Built-in application info
APPNAME = coord
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Generic Coordinator
ASRCS =
CSRCS =
MAINSRC = coord_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_IEEE802154_COORD_PROGNAME ?= coord$(EXEEXT)
PROGNAME = $(CONFIG_IEEE802154_COORD_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

View File

@ -1,505 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/coord/coord_main.c
*
* 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.
*
****************************************************************************/
/* Application description
*
* The coordinator is a central node in any IEEE 802.15.4 wireless network.
* It listens for clients and dispatches short addresses. It stores data from
* source clients and makes it available to destination clients.
* Also, in beacon enabled networks, it broadcasts beacons frames and
* manages guaranteed time slots.
* On non-beacon enabled networks, it sends a beacon only when a beacon
* request is received.
*
* This coordinator is generic. It does not interpret the contents of data
* frames. It only interprets command frames to manage client associations
* and data dispatch.
*
* There is no support for mesh networking (coord/coord traffic and packet
* forwarding).
*
* There is no support either for data security (yet).
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_IEEE802154_COORD_MAXCLIENTS
# define CONFIG_IEEE802154_COORD_MAXCLIENTS 8
#endif
#define ACTION_STOP 1
#define ACTION_PANID 2
/****************************************************************************
* Private Types
****************************************************************************/
struct ieee_client_s
{
uint8_t eaddr[8]; /* client extended address */
uint8_t saddr[2]; /* client short address */
struct ieee802154_packet_s pending; /* pending packet for device */
};
struct ieee_frame_s
{
struct ieee802154_packet_s packet;
struct ieee802154_addr_s dest;
struct ieee802154_addr_s src;
uint8_t seq;
uint8_t plen;
uint8_t *payload;
};
struct ieee_coord_s
{
int fd; /* Device handle */
uint8_t chan; /* PAN channel */
struct ieee802154_addr_s addr; /* coord own address */
uint8_t nclients; /* Number of coordinated clients */
struct ieee_frame_s rxbuf; /* General rx buffer */
struct ieee_frame_s txbuf; /* General tx buffer */
struct ieee_client_s clients[CONFIG_IEEE802154_COORD_MAXCLIENTS];
uint8_t macBSN;
};
struct message
{
int action;
unsigned long param;
};
/****************************************************************************
* Private Data
****************************************************************************/
static struct ieee_coord_s g_coord;
struct message g_message;
static volatile int g_run;
static pthread_t g_daemon_pid;
/****************************************************************************
* coord_beacon
****************************************************************************/
static int coord_beacon(FAR struct ieee_coord_s *coord)
{
printf("Beacon!\n");
return 0;
}
/****************************************************************************
* coord_data
****************************************************************************/
static int coord_data(FAR struct ieee_coord_s *coord)
{
printf("Data!\n");
return 0;
}
/****************************************************************************
* coord_ack
****************************************************************************/
static int coord_ack(FAR struct ieee_coord_s *coord)
{
printf("Ack!\n");
return 0;
}
/****************************************************************************
* coord_command_beacon_req
****************************************************************************/
static int coord_command_beacon_req(FAR struct ieee_coord_s *coord)
{
FAR struct ieee802154_packet_s *tx = &coord->txbuf.packet;
int i;
printf("Beacon request\n");
/* Check command */
/* Build response */
tx->len = 0;
/* Frame control */
tx->data[tx->len++] = 0x00; /* beacon, no ack */
tx->data[tx->len++] = 0x00; /* updated later */
/* seq */
tx->data[tx->len++] = coord->macBSN;
coord->macBSN++;
/* Adressing */
tx->len = ieee802154_addrstore(tx, NULL, &coord->addr);
/* Superframe spec */
tx->data[tx->len++] = 0xff;
tx->data[tx->len++] = 0xcf;
/* GTS fields */
tx->data[tx->len++] = 0x00;
/* Pending addresses */
tx->data[tx->len++] = 0x00;
/* Payload */
tx->data[tx->len++] = 'F';
tx->data[tx->len++] = '4';
tx->data[tx->len++] = 'G';
tx->data[tx->len++] = 'R';
tx->data[tx->len++] = 'X';
tx->data[tx->len++] = '/';
tx->data[tx->len++] = '0';
printf("Beacon: ");
for (i = 0; i < tx->len; i++)
{
printf("%02X", tx->data[i]);
}
printf("\n");
return write(coord->fd, tx, sizeof(struct ieee802154_packet_s));
}
/****************************************************************************
* coord_command
****************************************************************************/
static int coord_command(FAR struct ieee_coord_s *coord)
{
FAR struct ieee_frame_s *rx = &coord->rxbuf;
uint8_t cmd = rx->payload[0];
printf("Command %02X!\n",cmd);
switch (cmd)
{
case IEEE802154_CMD_ASSOC_REQ:
break;
case IEEE802154_CMD_ASSOC_RESP:
break;
case IEEE802154_CMD_DISASSOC_NOT:
break;
case IEEE802154_CMD_DATA_REQ:
break;
case IEEE802154_CMD_PANID_CONF_NOT:
break;
case IEEE802154_CMD_ORPHAN_NOT:
break;
case IEEE802154_CMD_BEACON_REQ:
return coord_command_beacon_req(coord);
case IEEE802154_CMD_COORD_REALIGN:
break;
case IEEE802154_CMD_GTS_REQ:
break;
}
return 0;
}
/****************************************************************************
* coord_manage
****************************************************************************/
static int coord_manage(FAR struct ieee_coord_s *coord)
{
/* Decode frame type */
uint16_t frame_ctrl;
uint8_t ftype;
int hlen;
char buf[IEEE802154_ADDRSTRLEN+1];
FAR struct ieee_frame_s *rx = &coord->rxbuf;
int i;
frame_ctrl = rx->packet.data[0];
frame_ctrl |= rx->packet.data[1] << 8;
rx->seq = rx->packet.data[2];
hlen = ieee802154_addrparse(&rx->packet, &rx->dest, &rx->src);
if (hlen < 0)
{
printf("invalid packet\n");
return 1;
}
rx->payload = rx->packet.data + hlen;
rx->plen = rx->packet.len - hlen;
ftype = frame_ctrl & IEEE802154_FRAMECTRL_FTYPE;
ieee802154_addrtostr(buf,sizeof(buf),&rx->src);
printf("[%s -> ", buf);
ieee802154_addrtostr(buf,sizeof(buf),&rx->dest);
printf("%s] ", buf);
for (i = 0; i < rx->plen; i++)
{
printf("%02X", rx->payload[i]);
}
printf("\n");
switch (ftype)
{
case IEEE802154_FRAME_BEACON:
coord_beacon(coord);
break;
case IEEE802154_FRAME_DATA:
coord_data(coord);
break;
case IEEE802154_FRAME_ACK:
coord_ack(coord);
break;
case IEEE802154_FRAME_COMMAND:
coord_command(coord);
break;
default:
fprintf(stderr, "unknown frame type!");
break;
}
return 0;
}
/****************************************************************************
* coord_loop
****************************************************************************/
void task_signal(int sig)
{
g_run = 0;
}
/****************************************************************************
* coord_initialize
****************************************************************************/
static void coord_initialize(FAR struct ieee_coord_s *coord, FAR char *dev,
FAR char *chan, FAR char *panid)
{
int i;
coord->nclients = 0;
for (i = 0; i < CONFIG_IEEE802154_COORD_MAXCLIENTS; i++)
{
coord->clients[i].pending.len = 0;
}
coord->chan = strtol(chan , NULL, 0);
coord->addr.mode = IEEE802154_ADDRMODE_SHORT;
coord->addr.panid = strtol(panid, NULL, 0);
coord->addr.saddr = 0x0001;
coord->fd = open(dev, O_RDWR);
}
/****************************************************************************
* coord_task
****************************************************************************/
int coord_task(int s_argc, char **s_argv)
{
FAR struct ieee_frame_s *rx = &g_coord.rxbuf;
int ret;
coord_initialize(&g_coord, s_argv[3], s_argv[4], s_argv[5]);
printf("IEEE 802.15.4 Coordinator started, chan %d, panid %04X, argc %d\n",
g_coord.chan, g_coord.addr.panid, s_argc);
ieee802154_setchan (g_coord.fd , g_coord.chan );
ieee802154_setsaddr(g_coord.fd , g_coord.addr.saddr);
ieee802154_setpanid(g_coord.fd , g_coord.addr.panid);
ieee802154_setdevmode(g_coord.fd, IEEE802154_MODE_PANCOORD);
if (g_coord.fd < 0)
{
fprintf(stderr, "cannot open %s, errno=%d\n", s_argv[3], errno);
exit(ERROR);
}
g_run = 1;
while(g_run)
{
ret = read(g_coord.fd, &rx->packet, sizeof(struct ieee802154_packet_s));
if (ret > 0)
{
coord_manage(&g_coord);
}
if (ret < 0)
{
if (errno == EINTR)
{
switch (g_message.action)
{
case ACTION_STOP:
g_run = 0;
break;
case ACTION_PANID:
g_coord.addr.panid = (uint16_t)g_message.param;
ieee802154_setpanid(g_coord.fd, g_coord.addr.panid);
break;
default:
printf("Received unknown message\n");
break;
}
}
}
}
printf("IEEE 802.15.4 Coordinator stopped\n");
return 0;
}
/****************************************************************************
* coord_main
11 ****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int coord_main(int argc, FAR char *argv[])
#endif
{
if (argc < 2)
{
printf("coord start | stop | panid\n");
exit(1);
}
if (!strcmp(argv[1], "start"))
{
if (argc != 5)
{
printf("coord start <dev> <chan> <panid>\n");
exit(EXIT_FAILURE);
}
if (g_run)
{
printf("Already started.\n");
exit(EXIT_FAILURE);
}
printf("IEEE 802.15.4 Coordinator starting...\n");
g_daemon_pid = task_create("coord", SCHED_PRIORITY_DEFAULT,
1024, coord_task, argv);
}
else if (!strcmp(argv[1], "stop"))
{
if (!g_run)
{
norun:
printf("Not started.\n");
exit(EXIT_FAILURE);
}
printf("IEEE 802.15.4 Coordinator stopping...\n");
g_message.action = ACTION_STOP;
kill(g_daemon_pid, SIGUSR1);
}
else if (!strcmp(argv[1], "status"))
{
printf("IEEE 802.15.4 Coordinator %s.\n", g_run?"started":"stopped");
}
else if (!strcmp(argv[1], "panid"))
{
if (argc != 3)
{
printf("coord panid <panid>\n");
exit(EXIT_FAILURE);
}
if (!g_run)
{
goto norun;
}
g_message.action = ACTION_PANID;
g_message.param = strtol(argv[2], NULL, 0);
kill(g_daemon_pid, SIGUSR1);
}
return EXIT_SUCCESS;
}

View File

@ -6,7 +6,6 @@
config IEEE802154_I8SAK
bool "IEEE 802.15.4 Swiss Army Knife"
default n
select IEEE802154_LIBRADIO
select IEEE802154_LIBUTILS
---help---
Enable the IEEE 802.15.4 Swiss Army Knife

View File

@ -60,7 +60,7 @@
#include <sys/ioctl.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -68,315 +68,99 @@
* Private Types
****************************************************************************/
struct sniffargs
{
int fd;
int verbose;
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int tx(int fd, FAR const char *str, int verbose);
/****************************************************************************
* Private Data
****************************************************************************/
static struct ieee802154_packet_s g_rxpacket;
static struct ieee802154_packet_s g_txpacket;
uint8_t g_handle = 0;
uint8_t g_txframe[IEEE802154_MAX_MAC_PAYLOAD_SIZE];
/****************************************************************************
* Public Data
****************************************************************************/
uint8_t g_levels[16];
uint8_t g_disp[16];
/****************************************************************************
* Public Functions
* Private Functions
****************************************************************************/
int energy_scan(int fd)
{
union ieee802154_radioarg_u arg;
uint8_t chan;
uint8_t energy;
int ret = OK;
printf("\n");
/* Do scan */
memset(g_disp,0,16);
while (1)
{
for (chan = 0; chan < 16; chan++)
{
ret = ieee802154_setchan(fd, chan+11);
if (ret < 0)
{
printf("Device is not an IEEE 802.15.4 interface!\n");
return ret;
}
ret = ioctl(fd, PHY802154IOC_ENERGYDETECT,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("Device is not an IEEE 802.15.4 interface!\n");
return ret;
}
g_levels[chan] = arg.energy;
}
/* Compute max with decay */
for (chan = 0; chan < 16; chan++)
{
if (g_levels[chan] > g_disp[chan])
{
g_disp[chan] = g_levels[chan];
}
else
{
if (g_disp[chan] > 0)
{
g_disp[chan] -= 1;
}
}
}
for (chan = 0; chan < 16; chan++)
{
printf("%2d : [%3d] ",chan+11, g_disp[chan]);
energy = g_disp[chan] >> 3;
while (energy-- > 0)
{
printf("#");
}
printf(" \n");
}
/* Move cursor 17 lines up : http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html */
printf("\x1B[16A");
}
return ret;
}
/****************************************************************************
* Name : status
*
* Description :
* Show device status
****************************************************************************/
static int status(int fd)
{
union ieee802154_radioarg_u arg;
struct ieee802154_cca_s cca;
uint8_t eaddr[EADDR_SIZE];
uint8_t chan;
uint16_t panid;
uint16_t saddr;
bool promisc;
int ret;
int i;
/* Get information */
ret = ioctl(fd, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_PANID failed\n");
return ret;
}
panid = arg.panid;
ret = ieee802154_getchan(fd, &chan);
if (ret)
{
return ret;
}
ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_SADDR failed\n");
return ret;
}
saddr = arg.saddr;
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_EADDR failed\n");
return ret;
}
memcpy(eaddr, arg.eaddr, EADDR_SIZE);
ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_PROMISC failed\n");
return ret;
}
promisc = arg.promisc;
ret = ieee802154_getcca(fd, &cca);
if (ret)
{
return ret;
}
/* Display */
printf("PANID %02X%02X CHAN %2d (%d MHz)\nSADDR %02X%02X EADDR ",
panid>>8, panid&0xFF, (int)chan, 2350+(5*chan), saddr>>8, saddr&0xFF);
for (i = 0; i < 8; i++)
{
printf("%02X", eaddr[i]);
}
printf("\nCCA: ");
if (cca.use_ed)
{
printf("ED (%d) ", cca.edth);
}
if (cca.use_cs)
{
printf("CS (%d)", cca.csth);
}
printf("\nPromisc: %s\n", promisc?"Yes":"No");
return 0;
}
/****************************************************************************
* Name : display
*
* Description :
* Display a single packet
****************************************************************************/
static int display(uint8_t chan, FAR struct ieee802154_packet_s *pack, bool verbose)
{
int i;
int hlen = 0;
int dhlen = 0;
char buf[IEEE802154_ADDRSTRLEN+1];
struct ieee802154_addr_s dest,src;
hlen = ieee802154_addrparse(pack, &dest, &src);
dhlen = hlen;
if (hlen > pack->len)
{
dhlen = 0;
}
printf("chan=%2d rssi=%3u lqi=%3u len=%3u ",
chan, pack->rssi, pack->lqi, pack->len - dhlen);
if (hlen < 0)
{
printf("[invalid header] ");
dhlen = 0;
}
else
{
ieee802154_addrtostr(buf,sizeof(buf),&src);
printf("[%s -> ", buf);
ieee802154_addrtostr(buf,sizeof(buf),&dest);
printf("%s] ", buf);
}
for (i = 0; i < pack->len - dhlen; i++)
{
printf("%02X", pack->data[i+dhlen]);
}
printf("\n");
return 0;
}
/****************************************************************************
* Name : sniff
*
* Description :
* Listen for all packets with a valid CRC on a given channel.
****************************************************************************/
static FAR void *sniff(FAR void *arg)
{
int ret;
FAR struct sniffargs *sa = (struct sniffargs*)arg;
int fd = sa->fd;
uint8_t chan;
printf("Listening...\n");
while (1)
{
ret = read(fd, &g_rxpacket, sizeof(struct ieee802154_packet_s));
if (ret < 0)
{
if (errno == EAGAIN)
{
continue;
}
if (errno == EINTR)
{
printf("read: interrupted\n");
break;
}
else
{
printf("read: errno=%d\n",errno);
break;
}
}
/* Display packet */
chan = 0;
ieee802154_getchan(fd, &chan);
display(chan, &g_rxpacket, sa->verbose);
}
return (FAR void *)((uintptr_t)ret);
}
/****************************************************************************
* Name : tx
*
* Description :
* Transmit a frame.
* Transmit a data frame.
****************************************************************************/
static int tx(int fd, FAR struct ieee802154_packet_s *pack, int verbose)
static int tx(int fd, FAR const char *str, int verbose)
{
int i,ret;
struct mac802154dev_txframe_s tx;
int ret, str_len;
int i = 0;
/* 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;
str_len = strlen(str);
/* Each byte is represented by 2 chars */
tx.meta.msdu_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.meta.msdu_length > IEEE802154_MAX_MAC_PAYLOAD_SIZE))
{
goto data_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 data_error;
}
}
if (verbose)
{
for (i = 0; i < pack->len; i++)
for (i = 0; i < tx.meta.msdu_length; i++)
{
printf("%02X", pack->data[i]);
printf("%02X", g_txframe[i]);
}
fflush(stdout);
}
ret = write(fd, pack, sizeof(struct ieee802154_packet_s));
tx.payload = &g_txframe[0];
ret = write(fd, &tx, sizeof(struct mac802154dev_txframe_s));
if (ret == OK)
{
if (verbose)
@ -389,7 +173,11 @@ static int tx(int fd, FAR struct ieee802154_packet_s *pack, int verbose)
printf(" write: errno=%d\n",errno);
}
return OK;
return ret;
data_error:
printf("data error\n");
return ERROR;;
}
/****************************************************************************
@ -403,16 +191,7 @@ static int tx(int fd, FAR struct ieee802154_packet_s *pack, int verbose)
int usage(void)
{
printf("i8 <device> <op> [<args>]\n"
" scan Energy scan\n"
" beacons [single] Aactive scan [on cur chan]\n"
" dump Show device registers\n"
" chan <ch> Select current channel\n"
" snif Listen for packets\n"
" stat Device status\n"
" pa <on|off> Enable/Disable external RF amplifiers\n"
" edth <off|rssi> Select Energy detection rx threshold\n"
" csth <off|corr> Select preamble correlation rx threshold\n"
" tx <hexpacket> Transmit a raw packet\n"
" tx <hexpacket> Transmit a data frame\n"
);
return ERROR;
@ -428,13 +207,10 @@ int main(int argc, FAR char *argv[])
int i8_main(int argc, char *argv[])
#endif
{
struct ieee802154_cca_s cca;
unsigned long arg = 0;
int fd;
int ret = OK;
printf("IEEE packet sniffer/dumper argc=%d\n", argc);
if (argc < 3)
{
return usage();
@ -457,203 +233,13 @@ int i8_main(int argc, char *argv[])
/* Get mode */
if (!strcmp(argv[2], "scan"))
if (!strcmp(argv[2], "tx"))
{
ret = energy_scan(fd);
}
else if (!strcmp(argv[2], "dump"))
{
ret = ioctl(fd, 1000, 0);
}
else if (!strcmp(argv[2], "pa"))
{
if (argc != 4)
{
goto usage;
}
if (!strcmp(argv[3],"off"))
{
ret = ioctl(fd, 1001, 0);
}
else if (!strcmp(argv[3],"on"))
{
ret = ioctl(fd, 1001, 1);
}
else
{
goto usage;
}
}
else if (!strcmp(argv[2], "stat"))
{
ret = status(fd);
}
else if (!strcmp(argv[2], "chan"))
{
if (argc != 4)
{
goto usage;
}
ret = ieee802154_setchan(fd, arg);
}
else if (!strcmp(argv[2], "edth"))
{
if (argc != 4)
{
goto usage;
}
ret = ieee802154_getcca(fd, &cca);
if (!strcmp("off",argv[3]))
{
cca.use_ed = 0;
}
else
{
cca.use_ed = 1;
cca.edth = arg;
}
ret = ieee802154_setcca(fd, &cca);
}
else if (!strcmp(argv[2], "csth"))
{
if (argc != 4)
{
goto usage;
}
ret = ieee802154_getcca(fd, &cca);
if (!strcmp("off",argv[3]))
{
cca.use_cs = 0;
}
else
{
cca.use_cs = 1;
cca.csth = arg;
}
ret = ieee802154_setcca(fd, &cca);
}
else if (!strcmp(argv[2], "snif"))
{
struct sniffargs args;
ret = ieee802154_setpromisc(fd, TRUE);
args.fd = fd;
args.verbose = FALSE;
ret = (int)((intptr_t)sniff(&args));
ret = ieee802154_setpromisc(fd, FALSE);
}
else if (!strcmp(argv[2], "tx"))
{
int id = 0;
int len = strlen(argv[3]);
FAR char *ptr = argv[3];
if (len & 1)
{
goto data_error;
}
/* Decode hex packet */
while (id <125 && len > 0)
{
int dat;
if (sscanf(ptr, "%2x", &dat) == 1)
{
g_txpacket.data[id++] = dat;
ptr += 2;
len -= 2;
}
else
{
data_error:
printf("data error\n");
ret = ERROR;
goto error;
}
}
g_txpacket.len = id;
ret = tx(fd, &g_txpacket, TRUE);
}
else if (!strcmp(argv[2], "beacons"))
{
struct sniffargs args;
struct ieee802154_addr_s dest;
pthread_t pth;
int single = FALSE;
int i;
uint8_t ch;
if (argc == 4 && !strcmp(argv[3], "single") )
{
single = TRUE;
}
args.fd = fd;
args.verbose = FALSE;
pthread_create(&pth, NULL, sniff, &args);
/* Beacon request */
g_txpacket.len = 0;
g_txpacket.data[g_txpacket.len++] = 0x03; /* Mac command, no ack, no panid compression */
g_txpacket.data[g_txpacket.len++] = 0x00; /* Short destination address, no source address */
g_txpacket.data[g_txpacket.len++] = 0; /* seq */
dest.mode = IEEE802154_ADDRMODE_SHORT;
dest.panid = 0xFFFF;
dest.saddr = 0xFFFF;
g_txpacket.len = ieee802154_addrstore(&g_txpacket, &dest, NULL);
g_txpacket.data[g_txpacket.len++] = IEEE802154_CMD_BEACON_REQ;
if (!single)
{
ch = 11;
}
i = 0;
while (1)
{
if (!single)
{
ieee802154_setchan(fd, ch);
}
ieee802154_getchan(fd, &ch);
printf("chan=%2d seq=%2X ...\r", (int)ch, i); fflush(stdout);
g_txpacket.data[2] = i; //seq
tx(fd, &g_txpacket, FALSE);
sleep(1);
i++;
if (i == 256)
{
i=0;
}
if (!single)
{
ch++;
if (ch==27)
{
ch=11;
}
}
}
pthread_kill(pth, SIGUSR1);
ret = tx(fd, argv[3], TRUE);
if (ret < 0)
{
goto error;
}
}
else
{

View File

@ -1,5 +1,5 @@
############################################################################
# apps/wireless/ieee802154/libradio/Make.defs
# apps/wireless/ieee802154/libmac/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2016-17 Gregory Nutt. All rights reserved.

View File

@ -40,19 +40,35 @@ 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_settxpwr.c ieee802154_gettxpwr.c
ifeq ($(CONFIG_NET_6LOWPAN),y)
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
endif
# 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_settxpwr.c sixlowpan_gettxpwr.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_getchan.c
* apps/wireless/ieee802154/libmac/ieee802154_getchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -45,8 +45,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,17 +55,13 @@
int ieee802154_getchan(int fd, FAR uint8_t *chan)
{
union ieee802154_radioarg_u arg;
struct ieee802154_get_req_s req;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CHAN failed: %d\n", ret);
return ret;
}
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
ret = ieee802154_get_req(fd, &req);
*chan = arg.channel;
return OK;
*chan = req.attr_value.phy.channel;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_geteaddr.c
* apps/wireless/ieee802154/libmac/ieee802154_geteaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,17 +55,13 @@
int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr)
{
union ieee802154_radioarg_u arg;
struct ieee802154_get_req_s req;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_EADDR failed: %d\n", ret);
return ret;
}
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
ret = ieee802154_get_req(fd, &req);
memcpy(eaddr, arg.eaddr, EADDR_SIZE);
return OK;
memcpy(eaddr, &req.attr_value.mac.eaddr[0], 8);
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_getpanid.c
* apps/wireless/ieee802154/libmac/ieee802154_getpanid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -44,8 +44,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -55,17 +54,13 @@
int ieee802154_getpanid(int fd, FAR uint16_t *panid)
{
union ieee802154_radioarg_u arg;
struct ieee802154_get_req_s req;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PANID failed: %d\n", ret);
return ret;
}
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
ret = ieee802154_get_req(fd, &req);
*panid = arg.panid;
return OK;
*panid = req.attr_value.mac.panid;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_getpromisc.c
* apps/wireless/ieee802154/libmac/ieee802154_getpromisc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -44,8 +44,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -55,17 +54,14 @@
int ieee802154_getpromisc(int fd, FAR bool *promisc)
{
union ieee802154_radioarg_u arg;
struct ieee802154_get_req_s req;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PROMISC failed: %d\n", ret);
return ret;
}
req.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
ret = ieee802154_get_req(fd, &req);
*promisc = req.attr_value.mac.promisc_mode;
return ret;
*promisc = arg.promisc;
return OK;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_getsaddr.c
* apps/wireless/ieee802154/libmac/ieee802154_getsaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -44,8 +44,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -55,17 +54,13 @@
int ieee802154_getsaddr(int fd, FAR uint16_t *saddr)
{
union ieee802154_radioarg_u arg;
struct ieee802154_get_req_s req;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_SADDR failed: %d\n", ret);
return ret;
}
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
ret = ieee802154_get_req(fd, &req);
*saddr = arg.saddr;
return OK;
*saddr = req.attr_value.mac.saddr;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_gettxpwr.c
* apps/wireless/ieee802154/libmac/ieee802154_gettxpwr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -44,8 +44,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -55,17 +54,13 @@
int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr)
{
union ieee802154_radioarg_u arg;
struct ieee802154_get_req_s req;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_TXPWR failed: %d\n", ret);
return ret;
}
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
ret = ieee802154_get_req(fd, &req);
*txpwr = arg.txpwr;
return OK;
*txpwr = req.attr_value.phy.txpwr;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_setchan.c
* apps/wireless/ieee802154/libmac/ieee802154_setchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -45,8 +45,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,17 +55,10 @@
int ieee802154_setchan(int fd, uint8_t chan)
{
union ieee802154_radioarg_u arg;
int ret;
struct ieee802154_set_req_s req;
arg.channel = chan;
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
req.attr_value.phy.channel = chan;
ret = ioctl(fd, PHY802154IOC_SET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CHAN failed: %d\n", ret);
}
return ret;
return ieee802154_set_req(fd, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_eaddr.c
* apps/wireless/ieee802154/libmac/ieee802154_eaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -46,8 +46,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -57,17 +56,10 @@
int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr)
{
union ieee802154_radioarg_u arg;
int ret;
struct ieee802154_set_req_s req;
memcpy(arg.eaddr, eaddr, EADDR_SIZE);
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
memcpy(&req.attr_value.mac.eaddr[0], eaddr, 8);
ret = ioctl(fd, PHY802154IOC_SET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_EADDR failed: %d\n", ret);
}
return ret;
return ieee802154_set_req(fd, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_setpanid.c
* apps/wireless/ieee802154/libmac/ieee802154_setpanid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -45,8 +45,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,17 +55,10 @@
int ieee802154_setpanid(int fd, uint16_t panid)
{
union ieee802154_radioarg_u arg;
int ret;
struct ieee802154_set_req_s req;
arg.panid = panid;
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
req.attr_value.mac.panid = panid;
ret = ioctl(fd, PHY802154IOC_SET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PANID failed: %d\n", ret);
}
return ret;
return ieee802154_set_req(fd, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_setpromisc.c
* apps/wireless/ieee802154/libmac/ieee802154_setpromisc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -46,8 +46,7 @@
#include <stdbool.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -57,17 +56,10 @@
int ieee802154_setpromisc(int fd, bool promisc)
{
union ieee802154_radioarg_u arg;
int ret;
struct ieee802154_set_req_s req;
arg.promisc = promisc;
req.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
req.attr_value.mac.promisc_mode = promisc;
ret = ioctl(fd, PHY802154IOC_SET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PROMISC failed: %d\n", ret);
}
return ret;
return ieee802154_set_req(fd, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_setsaddr.c
* apps/wireless/ieee802154/libmac/ieee802154_setsaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -45,8 +45,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,17 +55,10 @@
int ieee802154_setsaddr(int fd, uint16_t saddr)
{
union ieee802154_radioarg_u arg;
int ret;
struct ieee802154_set_req_s req;
arg.saddr = saddr;
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
req.attr_value.mac.saddr = saddr;
ret = ioctl(fd, PHY802154IOC_SET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_SADDR failed: %d\n", ret);
}
return ret;
return ieee802154_set_req(fd, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_settxpwr.c
* apps/wireless/ieee802154/libmac/ieee802154_settxpwr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -44,8 +44,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -55,17 +54,10 @@
int ieee802154_settxpwr(int fd, int32_t txpwr)
{
union ieee802154_radioarg_u arg;
int ret;
struct ieee802154_set_req_s req;
arg.txpwr = txpwr;
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
req.attr_value.phy.txpwr = txpwr;
ret = ioctl(fd, PHY802154IOC_SET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_TXPWR failed: %d\n", ret);
}
return ret;
return ieee802154_set_req(fd, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getchan.c
* apps/wireless/ieee802154/libmac/sixlowpan_getchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,19 +55,13 @@
int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan)
{
struct ieee802154_netradio_s arg;
struct ieee802154_get_req_s req;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
ret = sixlowpan_get_req(sock, ifname, &req);
ret = ioctl(sock, PHY802154IOC_GET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CHAN failed: %d\n", ret);
return ret;
}
*chan = req.attr_value.phy.channel;
*chan = arg.u.channel;
return OK;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_geteaddr.c
* apps/wireless/ieee802154/libmac/sixlowpan_geteaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,19 +55,13 @@
int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
{
struct ieee802154_netradio_s arg;
struct ieee802154_get_req_s req;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
ret = sixlowpan_get_req(sock, ifname, &req);
ret = ioctl(sock, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_EADDR failed: %d\n", ret);
return ret;
}
memcpy(eaddr, &req.attr_value.mac.eaddr[0], 8);
memcpy(eaddr, arg.u.eaddr, EADDR_SIZE);
return OK;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getpanid.c
* apps/wireless/ieee802154/libmac/sixlowpan_getpanid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,19 +55,13 @@
int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid)
{
struct ieee802154_netradio_s arg;
struct ieee802154_get_req_s req;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
ret = sixlowpan_get_req(sock, ifname, &req);
ret = ioctl(sock, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PANID failed: %d\n", ret);
return ret;
}
*panid = req.attr_value.mac.panid;
*panid = arg.u.panid;
return OK;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getpromisc.c
* apps/wireless/ieee802154/libmac/sixlowpan_getpromisc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,19 +55,13 @@
int sixlowpan_getpromisc(int sock, FAR const char *ifname, FAR bool *promisc)
{
struct ieee802154_netradio_s arg;
struct ieee802154_get_req_s req;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
req.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
ret = sixlowpan_get_req(sock, ifname, &req);
ret = ioctl(sock, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PROMISC failed: %d\n", ret);
return ret;
}
*promisc = req.attr_value.mac.promisc_mode;
*promisc = arg.u.promisc;
return OK;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getsaddr.c
* apps/wireless/ieee802154/libmac/sixlowpan_getsaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,19 +55,13 @@
int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr)
{
struct ieee802154_netradio_s arg;
struct ieee802154_get_req_s req;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
ret = sixlowpan_get_req(sock, ifname, &req);
ret = ioctl(sock, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_SADDR failed: %d\n", ret);
return ret;
}
*saddr = req.attr_value.mac.saddr;
*saddr = arg.u.saddr;
return OK;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_gettxpwr.c
* apps/wireless/ieee802154/libmac/sixlowpan_gettxpwr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,19 +55,13 @@
int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr)
{
struct ieee802154_netradio_s arg;
struct ieee802154_get_req_s req;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
ret = sixlowpan_get_req(sock, ifname, &req);
ret = ioctl(sock, PHY802154IOC_GET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_TXPWR failed: %d\n", ret);
return ret;
}
*txpwr = req.attr_value.phy.txpwr;
*txpwr = arg.u.txpwr;
return OK;
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setchan.c
* apps/wireless/ieee802154/libmac/sixlowpan_setchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,18 +55,10 @@
int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan)
{
struct ieee802154_netradio_s arg;
int ret;
struct ieee802154_set_req_s req;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.channel = chan;
req.pib_attr = IEEE802154_PIB_PHY_CURRENT_CHANNEL;
req.attr_value.phy.channel = chan;
ret = ioctl(sock, PHY802154IOC_SET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CHAN failed: %d\n", ret);
}
return ret;
return sixlowpan_set_req(sock, ifname, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_seteaddr.c
* apps/wireless/ieee802154/libmac/sixlowpan_seteaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,18 +55,10 @@
int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eaddr)
{
struct ieee802154_netradio_s arg;
int ret;
struct ieee802154_set_req_s req;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(arg.u.eaddr, eaddr, EADDR_SIZE);
req.pib_attr = IEEE802154_PIB_MAC_EXTENDED_ADDR;
memcpy(&req.attr_value.mac.eaddr[0], eaddr, 8);
ret = ioctl(sock, PHY802154IOC_SET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_EADDR failed: %d\n", ret);
}
return ret;
return sixlowpan_set_req(sock, ifname, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setpanid.c
* apps/wireless/ieee802154/libmac/sixlowpan_setpanid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,18 +55,10 @@
int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid)
{
struct ieee802154_netradio_s arg;
int ret;
struct ieee802154_set_req_s req;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.panid = panid;
req.pib_attr = IEEE802154_PIB_MAC_PAN_ID;
req.attr_value.mac.panid = panid;
ret = ioctl(sock, PHY802154IOC_SET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PANID failed: %d\n", ret);
}
return ret;
return sixlowpan_set_req(sock, ifname, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setpromisc.c
* apps/wireless/ieee802154/libmac/sixlowpan_setpromisc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -46,8 +46,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -57,18 +56,10 @@
int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc)
{
struct ieee802154_netradio_s arg;
int ret;
struct ieee802154_set_req_s req;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.promisc = promisc;
req.pib_attr = IEEE802154_PIB_MAC_PROMISCUOUS_MODE;
req.attr_value.mac.promisc_mode = promisc;
ret = ioctl(sock, PHY802154IOC_SET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PROMISC failed: %d\n", ret);
}
return ret;
return sixlowpan_set_req(sock, ifname, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setsaddr.c
* apps/wireless/ieee802154/libmac/sixlowpan_setsaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,18 +55,10 @@
int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr)
{
struct ieee802154_netradio_s arg;
int ret;
struct ieee802154_set_req_s req;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.saddr = saddr;
req.pib_attr = IEEE802154_PIB_MAC_SHORT_ADDRESS;
req.attr_value.mac.saddr = saddr;
ret = ioctl(sock, PHY802154IOC_SET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_SADDR failed: %d\n", ret);
}
return ret;
return sixlowpan_set_req(sock, ifname, &req);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_settxpwr.c
* apps/wireless/ieee802154/libmac/sixlowpan_settxpwr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,8 +45,7 @@
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
@ -56,18 +55,10 @@
int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr)
{
struct ieee802154_netradio_s arg;
int ret;
struct ieee802154_set_req_s req;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.txpwr = txpwr;
req.pib_attr = IEEE802154_PIB_PHY_TX_POWER;
req.attr_value.phy.txpwr = txpwr;
ret = ioctl(sock, PHY802154IOC_SET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_TXPWR failed: %d\n", ret);
}
return ret;
return sixlowpan_set_req(sock, ifname, &req);
}

View File

@ -1,11 +0,0 @@
/Make.dep
/.depend
/.built
/*.asm
/*.obj
/*.rel
/*.lst
/*.sym
/*.adb
/*.lib
/*.src

View File

@ -1,11 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config IEEE802154_LIBRADIO
bool "IEEE 802.15.4 radio library routines"
default n
---help---
Some radio library routines for ieee 802.15.4 apps

View File

@ -1,40 +0,0 @@
############################################################################
# apps/wireless/ieee802154/libradio/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_LIBRADIO),y)
CONFIGURED_APPS += wireless/ieee802154/libradio
endif

View File

@ -1,118 +0,0 @@
############################################################################
# apps/wireless/ieee802154/libradio/Makefile
#
# 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.
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# libradio source files
ASRCS =
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_setdevmode.c ieee802154_getdevmode.c
CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c
CSRCS += ieee802154_setcca.c ieee802154_getcca.c
CSRCS += ieee802154_energydetect.c
ifeq ($(CONFIG_NET_6LOWPAN),y)
CSRCS += sixlowpan_setchan.c sixlowpan_getchan.c
CSRCS += sixlowpan_setpanid.c sixlowpan_getpanid.c
CSRCS += sixlowpan_setsaddr.c sixlowpan_getsaddr.c
CSRCS += sixlowpan_seteaddr.c sixlowpan_geteaddr.c
CSRCS += sixlowpan_setpromisc.c sixlowpan_getpromisc.c
CSRCS += sixlowpan_setdevmode.c sixlowpan_getdevmode.c
CSRCS += sixlowpan_settxpwr.c sixlowpan_gettxpwr.c
CSRCS += sixlowpan_setcca.c sixlowpan_getcca.c
CSRCS += sixlowpan_energydetect.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
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

View File

@ -1,71 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_energydetect.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_energydetect(int fd, FAR bool *energy)
{
union ieee802154_radioarg_u arg;
int ret;
ret = ioctl(fd, PHY802154IOC_ENERGYDETECT, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_ENERGYDETECT failed: %d\n", ret);
return ret;
}
*energy = arg.energy;
return OK;
}

View File

@ -1,73 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_getcca.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/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca)
{
union ieee802154_radioarg_u arg;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CCA failed\n", ret);
return ret;
}
memcpy(cca, &arg.cca, sizeof(struct ieee802154_cca_s));
return OK;
}

View File

@ -1,71 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_getdevmode.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_getdevmode(int fd, FAR uint8_t *devmode)
{
union ieee802154_radioarg_u arg;
int ret;
ret = ioctl(fd, PHY802154IOC_GET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_DEVMODE failed: %d\n", ret);
return ret;
}
*devmode = arg.devmode;
return OK;
}

View File

@ -1,73 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/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 <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca)
{
union ieee802154_radioarg_u arg;
int ret;
memcpy(&arg.cca, cca, sizeof(struct ieee802154_cca_s));
ret = ioctl(fd, PHY802154IOC_SET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CCA failed: %d\n", ret);
}
return ret;
}

View File

@ -1,72 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/ieee802154_setdevmode.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/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_setdevmode(int fd, uint8_t devmode)
{
union ieee802154_radioarg_u arg;
int ret;
arg.devmode = devmode;
ret = ioctl(fd, PHY802154IOC_SET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_DEVMODE failed: %d\n", ret);
}
return ret;
}

View File

@ -1,74 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_energydetect.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_energydetect(int sock, FAR const char *ifname, FAR bool *energy)
{
struct ieee802154_netradio_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
ret = ioctl(sock, PHY802154IOC_ENERGYDETECT, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_ENERGYDETECT failed: %d\n", ret);
return ret;
}
*energy = arg.u.energy;
return OK;
}

View File

@ -1,75 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getcca.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_getcca(int sock, FAR const char *ifname,
FAR struct ieee802154_cca_s *cca)
{
struct ieee802154_netradio_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
ret = ioctl(sock, PHY802154IOC_GET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CCA failed: %d\n", ret);
return ret;
}
memcpy(cca, &arg.u.cca, sizeof(struct ieee802154_cca_s));
return OK;
}

View File

@ -1,73 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_getdevmode.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_getdevmode(int sock, FAR const char *ifname,
FAR uint8_t *devmode)
{
struct ieee802154_netradio_s arg;
int ret;
ret = ioctl(sock, PHY802154IOC_GET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_DEVMODE failed: %d\n", ret);
return ret;
}
*devmode = arg.u.devmode;
return OK;
}

View File

@ -1,73 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_setcca(int sock, FAR const char *ifname, FAR struct ieee802154_cca_s *cca)
{
struct ieee802154_netradio_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
memcpy(&arg.u.cca, cca, sizeof(struct ieee802154_cca_s));
ret = ioctl(sock, PHY802154IOC_SET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CCA failed: %d\n", ret);
}
return ret;
}

View File

@ -1,73 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libradio/sixlowpan_setdevmode.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int sixlowpan_setdevmode(int sock, FAR const char *ifname, uint8_t devmode)
{
struct ieee802154_netradio_s arg;
int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.devmode = devmode;
ret = ioctl(sock, PHY802154IOC_SET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_DEVMODE failed: %d\n", ret);
}
return ret;
}

View File

@ -1,5 +1,5 @@
############################################################################
# apps/wireless/ieee802154/libradio/Makefile
# apps/wireless/ieee802154/libmac/Makefile
#
# Copyright (C) 2016-2-17 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
@ -40,7 +40,7 @@ include $(APPDIR)/Make.defs
# libutils source files
ASRCS =
CSRCS += ieee802154_addrparse.c ieee802154_addrstore.c ieee802154_addrtostr.c
CSRCS += ieee802154_addrtostr.c
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))

View File

@ -1,145 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libutils/ieee802154_addrparse.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 <string.h>
#include <errno.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_addrparse(FAR struct ieee802154_packet_s *packet,
FAR struct ieee802154_addr_s *dest,
FAR struct ieee802154_addr_s *src)
{
uint16_t frame_ctrl;
int index=3;
/* Read fc */
frame_ctrl = packet->data[0];
frame_ctrl |= packet->data[1] << 8;
dest->mode = (frame_ctrl & IEEE802154_FRAMECTRL_DADDR)
>> IEEE802154_FRAMECTRL_SHIFT_DADDR;
src->mode = (frame_ctrl & IEEE802154_FRAMECTRL_SADDR)
>> IEEE802154_FRAMECTRL_SHIFT_SADDR;
/* Decode dest addr */
switch (dest->mode)
{
case IEEE802154_ADDRMODE_SHORT:
{
memcpy(&dest->panid, packet->data+index, 2);
index += 2; /* Skip dest pan id */
memcpy(&dest->saddr, packet->data+index, 2);
index += 2; /* Skip dest addr */
}
break;
case IEEE802154_ADDRMODE_EXTENDED:
{
memcpy(&dest->panid, packet->data+index, 2);
index += 2; /* Skip dest pan id */
memcpy(dest->eaddr, packet->data+index, 8);
index += 8; /* Skip dest addr */
}
break;
case IEEE802154_ADDRMODE_NONE:
break;
default:
return -EINVAL;
}
if ((src->mode == IEEE802154_ADDRMODE_SHORT) ||
(src->mode == IEEE802154_ADDRMODE_EXTENDED))
{
/* If PANID compression, src PAN ID is same as dest */
if(frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP)
{
src->panid = dest->panid;
}
else
{
memcpy(&src->panid, packet->data+index, 2);
index += 2; /*skip dest pan id*/
}
}
/* Decode source addr */
switch (src->mode)
{
case IEEE802154_ADDRMODE_SHORT:
{
memcpy(&src->saddr, packet->data+index, 2);
index += 2; /* Skip src addr */
}
break;
case IEEE802154_ADDRMODE_EXTENDED:
{
memcpy(src->eaddr, packet->data+index, 8);
index += 8; /* Skip src addr */
}
break;
case IEEE802154_ADDRMODE_NONE:
break;
default:
return -EINVAL;
}
return index;
}

View File

@ -1,166 +0,0 @@
/****************************************************************************
* apps/wireless/ieee802154/libutils/ieee802154_addrparse.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 <string.h>
#include <errno.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
FAR struct ieee802154_addr_s *dest,
FAR struct ieee802154_addr_s *src)
{
uint16_t frame_ctrl;
int index = 3; /* Skip fc and seq */
/* Get the frame control word so we can manipulate it */
frame_ctrl = packet->data[0];
frame_ctrl |= packet->data[1] << 8;
/* Clear the destination address mode */
frame_ctrl &= ~IEEE802154_FRAMECTRL_DADDR;
/* Encode dest addr */
if(dest == NULL || dest->mode == IEEE802154_ADDRMODE_NONE)
{
/* Set the destination address mode to none */
frame_ctrl |= IEEE802154_ADDRMODE_NONE << IEEE802154_FRAMECTRL_SHIFT_DADDR;
}
else
{
memcpy(packet->data+index, &dest->panid, 2);
index += 2; /* Skip dest pan id */
/* Set the dest address mode field */
frame_ctrl |= dest->mode << IEEE802154_FRAMECTRL_SHIFT_DADDR;
if(dest->mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(packet->data+index, &dest->saddr, 2);
index += 2; /* Skip dest addr */
}
else if(dest->mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(packet->data+index, &dest->panid, 2);
index += 2; /* Skip dest pan id */
memcpy(packet->data+index, dest->eaddr, 8);
index += 8; /* Skip dest addr */
}
else
{
return -EINVAL;
}
}
/* Clear the PAN ID Compression Field */
frame_ctrl &= ~IEEE802154_FRAMECTRL_PANIDCOMP;
if( (dest != NULL && dest->mode != IEEE802154_ADDRMODE_NONE) &&
(src != NULL && src->mode != IEEE802154_ADDRMODE_NONE) )
{
/* We have both adresses, encode source pan id according to compression */
if( dest->panid == src->panid)
{
frame_ctrl |= IEEE802154_FRAMECTRL_PANIDCOMP;
}
}
/* Clear the source address mode */
frame_ctrl &= ~IEEE802154_FRAMECTRL_SADDR;
/* Encode source addr */
if(src == NULL || src->mode == IEEE802154_ADDRMODE_NONE)
{
/* Set the source address mode to none */
frame_ctrl |= IEEE802154_ADDRMODE_NONE << IEEE802154_FRAMECTRL_SHIFT_SADDR;
}
else
{
/* Add src pan id if it was not compressed before */
if(!(frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP))
{
memcpy(packet->data+index, &src->panid, 2);
index += 2; /*skip src pan id*/
}
/* Set the source address mode field */
frame_ctrl |= src->mode << IEEE802154_FRAMECTRL_SHIFT_SADDR;
if(src->mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(packet->data+index, &src->saddr, 2);
index += 2; /* Skip src addr */
}
else if(src->mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(packet->data+index, src->eaddr, 8);
index += 8; /* Skip src addr */
}
else
{
return -EINVAL;
}
}
/* Copy the frame control word back to the buffer */
memcpy(packet->data, &frame_ctrl, 2);
return index;
}

View File

@ -8,7 +8,6 @@ menuconfig WIRELESS_IWPAN
default n
depends on NET && DRIVERS_WIRELESS
select IEEE802154_LIBMAC
select IEEE802154_LIBRADIO
select IEEE802154_LIBUTILS
---help---
IWPAN is a tool similar to wapi and inspired by iwpan on Linux that can

View File

@ -315,7 +315,7 @@ static bool iwpan_str2bool(FAR const char *str)
static void iwpan_show_cmd(int sock, FAR const char *ifname)
{
uint8_t eaddr[EADDR_SIZE] =
uint8_t eaddr[IEEE802154_EADDR_LEN] =
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
@ -506,7 +506,7 @@ static void iwpan_devmode_cmd(int sock, FAR const char *ifname,
static void iwpan_eaddr_cmd(int sock, FAR const char *ifname,
FAR const char *addrstr)
{
uint8_t eaddr[EADDR_SIZE];
uint8_t eaddr[IEEE802154_EADDR_LEN];
int ret;
/* Convert input strings to values */