Merge remote-tracking branch 'nuttx_bitbucket/master'

This commit is contained in:
Masayuki Ishikawa 2017-07-04 10:03:21 +09:00
commit 10b5585d94
17 changed files with 162 additions and 294 deletions

View File

@ -6,6 +6,7 @@
config EXAMPLES_TELNETD
bool "Telnet daemon example"
default n
depends on NETUTILS_TELNETD
---help---
Enable the Telnet daemon example

View File

@ -50,7 +50,7 @@ ROMFS_IMG = $(CONTENT_DIR)/romfs.img
ROMFS_HDR = $(CONTENT_DIR)/romfs.h
ASRCS =
CSRCS = hello.c netstat.c tasks.c
CSRCS = hello.c tasks.c
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
@ -74,8 +74,8 @@ else
INSTALL_DIR = $(BIN_DIR)
endif
ROOTDEPPATH = --dep-path hello --dep-path netstat --dep-path tasks
VPATH = hello:netstat:tasks
ROOTDEPPATH = --dep-path hello --dep-path tasks
VPATH = hello:tasks
all: .built
.PHONY: context headers binaries depend clean
@ -122,13 +122,10 @@ headers: $(ROMFS_HDR)
$(BUILTIN_REGISTRY)$(DELIM)hello_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,hello,$(PRIORITY),$(STACKSIZE),hello_main)
$(BUILTIN_REGISTRY)$(DELIM)netstat_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,netstat,$(PRIORITY),$(STACKSIZE),netstat_main)
$(BUILTIN_REGISTRY)$(DELIM)tasks_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,tasks,$(PRIORITY),$(STACKSIZE),tasks_main)
context: $(BUILTIN_REGISTRY)$(DELIM)hello_main.bdat $(BUILTIN_REGISTRY)$(DELIM)netstat_main.bdat $(BUILTIN_REGISTRY)$(DELIM)tasks_main.bdat
context: $(BUILTIN_REGISTRY)$(DELIM)hello_main.bdat $(BUILTIN_REGISTRY)$(DELIM)tasks_main.bdat
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep

View File

@ -33,7 +33,7 @@
#
############################################################################
SUBDIRS = hello tasks netstat
SUBDIRS = hello tasks
INSTALL_FILES = index.html style.css
THTTPD_DIR = $(APPDIR)/examples/thttpd

View File

@ -69,7 +69,6 @@ int main(int argc, char *argv[])
"<div class=\"menubox\"><a href=\"/index.html\">Front page</a></div>\r\n"
"<div class=\"menubox\"><a href=\"hello\">Say Hello</a></div>\r\n"
"<div class=\"menubox\"><a href=\"tasks\">Tasks</a></div>\r\n"
"<div class=\"menubox\"><a href=\"netstat\">Network status</a></div>\r\n"
"<br>\r\n"
"</div>\r\n"
"<div class=\"contentblock\">\r\n");

View File

@ -10,7 +10,6 @@
<div class="menubox"><a href="index.html">Front page</a></div>
<div class="menubox"><a href="cgi-bin/hello">Say Hello</a></div>
<div class="menubox"><a href="cgi-bin/tasks">Tasks</a></div>
<div class="menubox"><a href="cgi-bin/netstat">Network status</a></div>
<br>
</div>

View File

@ -1,5 +0,0 @@
netstat
*.r1
*.r2
*-thunk.S

View File

@ -1,82 +0,0 @@
############################################################################
# examples/thttpd/content/netstat/Makefile
#
# Copyright (C) 2009, 2016 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)/Make.defs
BIN = netstat
R1SRCS = $(BIN).c
R1OBJS = $(R1SRCS:.c=.o)
R2SRC = $(BIN)-thunk.S
R2OBJ = $(R2SRC:.S=.o)
all: $(BIN)
.PHONY: clean install
$(R1OBJS): %.o: %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CPICFLAGS) $< -o $@
$(R2OBJ): %.o: %.S
@echo "AS: $<"
$(Q) $(CC) -c $(CPICFLAGS) $< -o $@
$(BIN).r1: $(R1OBJS)
@echo "LD: $<"
$(Q) $(LD) $(NXFLATLDFLAGS1) -o $@ $^
$(R2SRC): $(BIN).r1
@echo "MK: $<"
$(Q) $(MKNXFLAT) -o $@ $^
$(BIN).r2: $(R2OBJ)
@echo "LD: $<"
$(Q) $(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ)
$(BIN): $(BIN).r2
@echo "LD: $<"
$(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^
clean:
$(call DELFILE, $(BIN))
$(call DELFILE, $(R2SRC))
$(call DELFILE, *.r1)
$(call DELFILE, *.r2)
$(call CLEAN)
install:
$(Q) install -m 0755 -D $(BIN) $(CGI_DIR)/$(BIN)

View File

@ -1,140 +0,0 @@
/****************************************************************************
* examples/thttpd/netstat/netstat.c
*
* Copyright (C) 2009, 2011, 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/ether.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* NOTEs:
*
* 1. One limitation in the use of NXFLAT is that functions that are
* referenced as a pointer-to-a-function must have global scope. Otherwise
* ARM GCC will generate some bad logic.
* 2. In general, when called back, there is no guarantee to that PIC registers
* will be valid and, unless you take special precautions, it could be
* dangerous to reference global variables in the callback function.
*/
/* static */ int netdev_callback(FAR struct net_driver_s *dev, void *arg)
{
struct in_addr addr;
printf(" <dt>%s\r\n", dev->d_ifname);
#ifdef CONFIG_NET_ETHERNET
printf(" <dd>HWaddr: %s<br>\r\n", ether_ntoa(&dev->d_mac));
#endif
addr.s_addr = dev->d_ipaddr;
printf(" IPaddr: %s<br>\r\n", inet_ntoa(addr));
addr.s_addr = dev->d_draddr;
printf(" DRaddr: %s<br>\r\n", inet_ntoa(addr));
addr.s_addr = dev->d_netmask;
printf(" Mask: %s\r\n", inet_ntoa(addr));
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
#ifdef CONFIG_THTTPD_BINFS
int netstat_main(int argc, char *argv[])
#else
int main(int argc, char *argv[])
#endif
{
puts(
"Content-type: text/html\r\n"
"Status: 200/html\r\n"
"\r\n"
"<html>\r\n"
"<head>\r\n"
"<title>Network Status</title>\r\n"
"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\">\r\n"
"</head>\r\n"
"<body bgcolor=\"#fffeec\" text=\"black\">\r\n"
"<div class=\"menu\">\r\n"
"<div class=\"menubox\"><a href=\"/index.html\">Front page</a></div>\r\n"
"<div class=\"menubox\"><a href=\"hello\">Say Hello</a></div>\r\n"
"<div class=\"menubox\"><a href=\"tasks\">Tasks</a></div>\r\n"
"<div class=\"menubox\"><a href=\"netstat\">Network status</a></div>\r\n"
"<br>\r\n"
"</div>\r\n"
"<div class=\"contentblock\">\r\n"
"<dl>\r\n");
netdev_foreach(netdev_callback, NULL);
puts(
"</dl>\r\n"
"</body>\r\n"
"</html>\r\n");
return 0;
}

View File

@ -194,7 +194,6 @@ int main(int argc, char *argv[])
"<div class=\"menubox\"><a href=\"/index.html\">Front page</a></div>\r\n"
"<div class=\"menubox\"><a href=\"hello\">Say Hello</a></div>\r\n"
"<div class=\"menubox\"><a href=\"tasks\">Tasks</a></div>\r\n"
"<div class=\"menubox\"><a href=\"netstat\">Network status</a></div>\r\n"
"<br>\r\n"
"</div>\r\n"
"<div class=\"contentblock\">\r\n"

View File

@ -528,17 +528,17 @@ o ifconfig [nic_name [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask
nsh> mount -t procfs /proc
o ifdown <nic-name>
o ifdown <interface>
Take down the interface identified by the name <nic-name>.
Take down the interface identified by the name <interface>.
Example:
ifdown eth0
o ifup <nic-name>
o ifup <interface>
Bring up down the interface identified by the name <nic-name>.
Bring up down the interface identified by the name <interface>.
Example:

View File

@ -240,11 +240,11 @@ static const struct cmdmap_s g_cmdmap[] =
#ifdef CONFIG_NET
# ifndef CONFIG_NSH_DISABLE_IFCONFIG
{ "ifconfig", cmd_ifconfig, 1, 11, "[nic-name [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>] [dns <dns-address>] [hw <hw-mac>]" },
{ "ifconfig", cmd_ifconfig, 1, 11, "[interface [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>] [dns <dns-address>] [hw <hw-mac>]" },
# endif
# ifndef CONFIG_NSH_DISABLE_IFUPDOWN
{ "ifdown", cmd_ifdown, 2, 2, "<nic-name>" },
{ "ifup", cmd_ifup, 2, 2, "<nic-name>" },
{ "ifdown", cmd_ifdown, 2, 2, "<interface>" },
{ "ifup", cmd_ifup, 2, 2, "<interface>" },
# endif
#endif

View File

@ -1,7 +1,7 @@
/****************************************************************************
* apps/nshlib/nsh_netcmds.c
*
* Copyright (C) 2007-2012, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -758,10 +758,9 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
bool inet6 = false;
#endif
bool badarg = false;
#ifdef CONFIG_NET_ETHERNET
#if defined(CONFIG_NET_ETHERNET)
uint8_t mac[IFHWADDRLEN];
#endif
#ifdef CONFIG_NET_6LOWPAN
#elif defined(CONFIG_NET_6LOWPAN)
uint8_t eaddr[8];
#endif
#if defined(CONFIG_NSH_DHCPC)
@ -769,11 +768,11 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif
int ret;
/* With one or no arguments, ifconfig simply shows the status of Ethernet
* device:
/* With one or no arguments, ifconfig simply shows the status of the
* network device:
*
* ifconfig
* ifconfig [nic_name]
* ifconfig [interface]
*/
if (argc <= 2)

View File

@ -332,7 +332,7 @@ int telnet_main(int argc, char *argv[])
memset(&local, 0, sizeof(local));
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
#ifdef CONFIG_NET_IPv6
addrlen = sizeof(struct sockaddr_in6);
family = AF_INET6;
@ -343,7 +343,7 @@ int telnet_main(int argc, char *argv[])
ret = inet_pton(AF_INET6, argv[1], server.ipv6.sin6_addr.s6_addr);
if (ret < 0)
#endif
#ifdef CONFIG_EXAMPLES_NETTEST_IPv
#ifdef CONFIG_NET_IPv4
{
addrlen = sizeof(struct sockaddr_in);
family = AF_INET;

View File

@ -143,6 +143,7 @@ struct i8sak_s
pid_t daemon_pid;
FAR char devname[I8SAK_MAX_DEVNAME];
struct wpanlistener_s wpanlistener;
int result;
int fd;
sem_t exclsem; /* For synchronizing access to the signaling semaphore */

View File

@ -39,12 +39,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include "i8sak.h"
@ -57,7 +60,8 @@
* Private Function Prototypes
****************************************************************************/
static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg);
static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif,
FAR void *arg);
/****************************************************************************
* Public Functions
@ -70,10 +74,12 @@ static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *
* Start accepting association requests.
****************************************************************************/
void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc,
FAR char *argv[])
{
struct wpanlistener_eventfilter_s filter;
bool acceptall = true; /* start off assuming we are going to allow all connections */
bool acceptall = true; /* Start off assuming we are going to allow all
* connections */
int option;
int optcnt;
int fd;
@ -91,14 +97,17 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]
" -e = only accept requests from eaddr\n"
"Note: No option accepts all requests\n"
, argv[0]);
/* Must manually reset optind if we are going to exit early */
optind = -1;
return;
case 'e': /* Accept only this extended address */
i8sak_str2eaddr(optarg, &i8sak->ep.eaddr[0]);
acceptall = false;
break;
case ':':
fprintf(stderr, "ERROR: missing argument\n");
@ -106,6 +115,7 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]
optind = -1;
i8sak_cmd_error(i8sak); /* This exits for us */
case '?':
fprintf(stderr, "ERROR: invalid argument\n");
@ -140,7 +150,8 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]
&filter, (FAR void *)i8sak, !i8sak->acceptall);
}
static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg)
static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif,
FAR void *arg)
{
FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg;
struct ieee802154_assoc_resp_s assocresp;
@ -159,7 +170,21 @@ static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *
if (IEEE802154_EADDRCMP(notif->u.assocind.devaddr, i8sak->ep.eaddr))
{
/* Assign the short address */
IEEE802154_SADDRCOPY(assocresp.assocsaddr, i8sak->next_saddr);
/* Select a short address for the next association */
i8sak->next_saddr[0]++;
if (i8sak->next_saddr[0] == 0)
{
/* Handle the carry */
i8sak->next_saddr[1]++;
DEBUGASSERT(i8sak->next_saddr[1] != 0);
}
assocresp.status = IEEE802154_STATUS_SUCCESS;
printf("i8sak: accepting association request\n");
}

View File

@ -44,12 +44,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <nuttx/fs/ioctl.h>
#include "i8sak.h"
@ -80,6 +83,9 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
struct ieee802154_assoc_req_s assocreq;
struct wpanlistener_eventfilter_s filter;
FAR struct ieee802154_pandesc_s *pandesc;
bool retry = false;
int maxretries = 0;
int retrycnt;
int fd;
int option;
int optcnt;
@ -98,15 +104,16 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
}
optcnt = 0;
while ((option = getopt(argc, argv, ":hr:s:e:")) != ERROR)
while ((option = getopt(argc, argv, ":hr:s:e:w:")) != ERROR)
{
optcnt++;
switch (option)
{
case 'h':
fprintf(stderr, "Requests association with endpoint\n"
"Usage: %s [-h]\n"
"Usage: %s [-h] [-w <count>\n"
" -h = this help menu\n"
" -w = wait and retry on failure\n"
" -r = use scan result index\n"
, argv[0]);
@ -114,12 +121,14 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
optind = -1;
return;
case 'r':
resindex = i8sak_str2luint8(optarg);
if (resindex >= i8sak->npandesc)
{
fprintf(stderr, "ERROR: missing argument\n");
/* Must manually reset optind if we are going to exit early */
optind = -1;
@ -147,8 +156,16 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED;
break;
case 'w':
/* Wait and retry if we fail to associate */
retry = true;
maxretries = atoi(optarg);
break;
case ':':
fprintf(stderr, "ERROR: missing argument\n");
/* Must manually reset optind if we are going to exit early */
optind = -1;
@ -156,6 +173,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
case '?':
fprintf(stderr, "ERROR: unknown argument\n");
/* Must manually reset optind if we are going to exit early */
optind = -1;
@ -179,43 +197,98 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
i8sak_cmd_error(i8sak);
}
/* Register new callback for receiving the association notifications */
/* Register new callback for receiving the association notifications. */
memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s));
filter.confevents.assoc = true;
wpanlistener_add_eventreceiver(&i8sak->wpanlistener, assoc_eventcb, &filter,
(FAR void *)i8sak, true);
wpanlistener_add_eventreceiver(&i8sak->wpanlistener, assoc_eventcb,
&filter, (FAR void *)i8sak, false);
printf("i8sak: issuing ASSOC. request\n");
/* Loop for the specified retry count if the association fails.
*/
assocreq.chan = i8sak->chan;
assocreq.chpage = i8sak->chpage;
memcpy(&assocreq.coordaddr, &i8sak->ep, sizeof(struct ieee802154_addr_s));
assocreq.capabilities.devtype = 0;
assocreq.capabilities.powersource = 1;
assocreq.capabilities.rxonidle = 1;
assocreq.capabilities.security = 0;
assocreq.capabilities.allocaddr = 1;
ieee802154_assoc_req(fd, &assocreq);
close(fd);
/* Wait here, the event listener will notify us if the correct event occurs */
i8sak->assoc = true;
ret = sem_wait(&i8sak->sigsem);
sem_post(&i8sak->exclsem);
if (ret != OK)
retrycnt = 0;
for (; ; )
{
i8sak->assoc = false;
printf("i8sak: test cancelled\n");
i8sak_cmd_error(i8sak);
printf("i8sak: issuing ASSOC. request %d\n", retrycnt + 1);
/* Issue association request */
assocreq.chan = i8sak->chan;
assocreq.chpage = i8sak->chpage;
memcpy(&assocreq.coordaddr, &i8sak->ep,
sizeof(struct ieee802154_addr_s));
assocreq.capabilities.devtype = 0;
assocreq.capabilities.powersource = 1;
assocreq.capabilities.rxonidle = 1;
assocreq.capabilities.security = 0;
assocreq.capabilities.allocaddr = 1;
ieee802154_assoc_req(fd, &assocreq);
/* Wait for the assocconf event */
i8sak->assoc = true;
i8sak->result = -EBUSY;
ret = sem_wait(&i8sak->sigsem);
sem_post(&i8sak->exclsem);
if (ret != OK)
{
i8sak->assoc = false;
printf("i8sak: test cancelled\n");
i8sak_cmd_error(i8sak);
break;
}
/* Check if the association was successful */
if (i8sak->result == OK)
{
/* Break out and return if the association was successful. */
break;
}
/* Not successful .. were we asked to retry in the event of an
* association failure?
*/
if (!retry)
{
/* No retries... break out now with the failed association */
break;
}
/* A retry count of zero means to retry forever. Otherwise,
* abort as soon as the maximum number of retries have been
* performed.
*/
if (maxretries > 0 && retrycnt >= maxretries)
{
/* Max retry count exceeded -- break out now with a failed
* association.
*/
break;
}
/* Otherwise, wait a bit and try again */
sleep(2);
retrycnt++;
}
/* Clean up and return */
(void)wpanlistener_remove_eventreceiver(&i8sak->wpanlistener,
assoc_eventcb);
close(fd);
}
/****************************************************************************
@ -229,16 +302,18 @@ static void assoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg)
if (notif->u.assocconf.status == IEEE802154_STATUS_SUCCESS)
{
printf("i8sak: ASSOC.request succeeded\n");
i8sak->result = OK;
}
else
{
printf("i8sak: ASSOC.request failed: %s\n",
IEEE802154_STATUS_STRING[notif->u.assocconf.status]);
i8sak->result = -EAGAIN;
}
if (i8sak->assoc)
{
sem_post(&i8sak->sigsem);
i8sak->assoc = false;
sem_post(&i8sak->sigsem);
}
}

View File

@ -734,7 +734,7 @@ static int i8sak_showusage(FAR const char *progname, int exitcode)
" startpan [-h]\n"
" acceptassoc [-h|e <eaddr>]\n"
" scan [-h|p|a|e] minch-maxch\n"
" assoc [-h] [<panid>]\n"
" assoc [-h] [-w <count>] [<panid>]\n"
" tx [-h|d] <hex-payload>\n"
" poll [-h]\n"
" blaster [-h|q|f <hex payload>|p <period_ms>]\n"