Merge remote-tracking branch 'origin/master' into composite
This commit is contained in:
commit
fe1e52a83a
@ -332,7 +332,7 @@ int telnet_main(int argc, char *argv[])
|
|||||||
|
|
||||||
memset(&local, 0, sizeof(local));
|
memset(&local, 0, sizeof(local));
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
addrlen = sizeof(struct sockaddr_in6);
|
addrlen = sizeof(struct sockaddr_in6);
|
||||||
family = AF_INET6;
|
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);
|
ret = inet_pton(AF_INET6, argv[1], server.ipv6.sin6_addr.s6_addr);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv
|
#ifdef CONFIG_NET_IPv4
|
||||||
{
|
{
|
||||||
addrlen = sizeof(struct sockaddr_in);
|
addrlen = sizeof(struct sockaddr_in);
|
||||||
family = AF_INET;
|
family = AF_INET;
|
||||||
|
@ -143,6 +143,7 @@ struct i8sak_s
|
|||||||
pid_t daemon_pid;
|
pid_t daemon_pid;
|
||||||
FAR char devname[I8SAK_MAX_DEVNAME];
|
FAR char devname[I8SAK_MAX_DEVNAME];
|
||||||
struct wpanlistener_s wpanlistener;
|
struct wpanlistener_s wpanlistener;
|
||||||
|
int result;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
sem_t exclsem; /* For synchronizing access to the signaling semaphore */
|
sem_t exclsem; /* For synchronizing access to the signaling semaphore */
|
||||||
|
@ -39,12 +39,15 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
|
|
||||||
#include "i8sak.h"
|
#include "i8sak.h"
|
||||||
@ -57,7 +60,8 @@
|
|||||||
* Private Function Prototypes
|
* 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
|
* Public Functions
|
||||||
@ -70,10 +74,12 @@ static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *
|
|||||||
* Start accepting association requests.
|
* 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;
|
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 option;
|
||||||
int optcnt;
|
int optcnt;
|
||||||
int fd;
|
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"
|
" -e = only accept requests from eaddr\n"
|
||||||
"Note: No option accepts all requests\n"
|
"Note: No option accepts all requests\n"
|
||||||
, argv[0]);
|
, argv[0]);
|
||||||
|
|
||||||
/* Must manually reset optind if we are going to exit early */
|
/* Must manually reset optind if we are going to exit early */
|
||||||
|
|
||||||
optind = -1;
|
optind = -1;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'e': /* Accept only this extended address */
|
case 'e': /* Accept only this extended address */
|
||||||
i8sak_str2eaddr(optarg, &i8sak->ep.eaddr[0]);
|
i8sak_str2eaddr(optarg, &i8sak->ep.eaddr[0]);
|
||||||
acceptall = false;
|
acceptall = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
fprintf(stderr, "ERROR: missing argument\n");
|
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;
|
optind = -1;
|
||||||
i8sak_cmd_error(i8sak); /* This exits for us */
|
i8sak_cmd_error(i8sak); /* This exits for us */
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
fprintf(stderr, "ERROR: invalid argument\n");
|
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);
|
&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;
|
FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg;
|
||||||
struct ieee802154_assoc_resp_s assocresp;
|
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))
|
if (IEEE802154_EADDRCMP(notif->u.assocind.devaddr, i8sak->ep.eaddr))
|
||||||
{
|
{
|
||||||
|
/* Assign the short address */
|
||||||
|
|
||||||
IEEE802154_SADDRCOPY(assocresp.assocsaddr, i8sak->next_saddr);
|
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;
|
assocresp.status = IEEE802154_STATUS_SUCCESS;
|
||||||
printf("i8sak: accepting association request\n");
|
printf("i8sak: accepting association request\n");
|
||||||
}
|
}
|
||||||
|
@ -44,12 +44,15 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
|
|
||||||
#include "i8sak.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 ieee802154_assoc_req_s assocreq;
|
||||||
struct wpanlistener_eventfilter_s filter;
|
struct wpanlistener_eventfilter_s filter;
|
||||||
FAR struct ieee802154_pandesc_s *pandesc;
|
FAR struct ieee802154_pandesc_s *pandesc;
|
||||||
|
bool retry = false;
|
||||||
|
int maxretries = 0;
|
||||||
|
int retrycnt;
|
||||||
int fd;
|
int fd;
|
||||||
int option;
|
int option;
|
||||||
int optcnt;
|
int optcnt;
|
||||||
@ -98,15 +104,16 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
optcnt = 0;
|
optcnt = 0;
|
||||||
while ((option = getopt(argc, argv, ":hr:s:e:")) != ERROR)
|
while ((option = getopt(argc, argv, ":hr:s:e:w:")) != ERROR)
|
||||||
{
|
{
|
||||||
optcnt++;
|
optcnt++;
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
fprintf(stderr, "Requests association with endpoint\n"
|
fprintf(stderr, "Requests association with endpoint\n"
|
||||||
"Usage: %s [-h]\n"
|
"Usage: %s [-h] [-w <count>\n"
|
||||||
" -h = this help menu\n"
|
" -h = this help menu\n"
|
||||||
|
" -w = wait and retry on failure\n"
|
||||||
" -r = use scan result index\n"
|
" -r = use scan result index\n"
|
||||||
, argv[0]);
|
, argv[0]);
|
||||||
|
|
||||||
@ -114,12 +121,14 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
|||||||
|
|
||||||
optind = -1;
|
optind = -1;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
resindex = i8sak_str2luint8(optarg);
|
resindex = i8sak_str2luint8(optarg);
|
||||||
|
|
||||||
if (resindex >= i8sak->npandesc)
|
if (resindex >= i8sak->npandesc)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: missing argument\n");
|
fprintf(stderr, "ERROR: missing argument\n");
|
||||||
|
|
||||||
/* Must manually reset optind if we are going to exit early */
|
/* Must manually reset optind if we are going to exit early */
|
||||||
|
|
||||||
optind = -1;
|
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;
|
i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
/* Wait and retry if we fail to associate */
|
||||||
|
|
||||||
|
retry = true;
|
||||||
|
maxretries = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
fprintf(stderr, "ERROR: missing argument\n");
|
fprintf(stderr, "ERROR: missing argument\n");
|
||||||
|
|
||||||
/* Must manually reset optind if we are going to exit early */
|
/* Must manually reset optind if we are going to exit early */
|
||||||
|
|
||||||
optind = -1;
|
optind = -1;
|
||||||
@ -156,6 +173,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
|||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
fprintf(stderr, "ERROR: unknown argument\n");
|
fprintf(stderr, "ERROR: unknown argument\n");
|
||||||
|
|
||||||
/* Must manually reset optind if we are going to exit early */
|
/* Must manually reset optind if we are going to exit early */
|
||||||
|
|
||||||
optind = -1;
|
optind = -1;
|
||||||
@ -179,20 +197,29 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
|||||||
i8sak_cmd_error(i8sak);
|
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));
|
memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s));
|
||||||
filter.confevents.assoc = true;
|
filter.confevents.assoc = true;
|
||||||
|
|
||||||
wpanlistener_add_eventreceiver(&i8sak->wpanlistener, assoc_eventcb, &filter,
|
wpanlistener_add_eventreceiver(&i8sak->wpanlistener, assoc_eventcb,
|
||||||
(FAR void *)i8sak, true);
|
&filter, (FAR void *)i8sak, false);
|
||||||
|
|
||||||
printf("i8sak: issuing ASSOC. request\n");
|
/* Loop for the specified retry count if the association fails.
|
||||||
|
*/
|
||||||
|
|
||||||
|
retrycnt = 0;
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
printf("i8sak: issuing ASSOC. request %d\n", retrycnt + 1);
|
||||||
|
|
||||||
|
/* Issue association request */
|
||||||
|
|
||||||
assocreq.chan = i8sak->chan;
|
assocreq.chan = i8sak->chan;
|
||||||
assocreq.chpage = i8sak->chpage;
|
assocreq.chpage = i8sak->chpage;
|
||||||
|
|
||||||
memcpy(&assocreq.coordaddr, &i8sak->ep, sizeof(struct ieee802154_addr_s));
|
memcpy(&assocreq.coordaddr, &i8sak->ep,
|
||||||
|
sizeof(struct ieee802154_addr_s));
|
||||||
|
|
||||||
assocreq.capabilities.devtype = 0;
|
assocreq.capabilities.devtype = 0;
|
||||||
assocreq.capabilities.powersource = 1;
|
assocreq.capabilities.powersource = 1;
|
||||||
@ -202,11 +229,10 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
|||||||
|
|
||||||
ieee802154_assoc_req(fd, &assocreq);
|
ieee802154_assoc_req(fd, &assocreq);
|
||||||
|
|
||||||
close(fd);
|
/* Wait for the assocconf event */
|
||||||
|
|
||||||
/* Wait here, the event listener will notify us if the correct event occurs */
|
|
||||||
|
|
||||||
i8sak->assoc = true;
|
i8sak->assoc = true;
|
||||||
|
i8sak->result = -EBUSY;
|
||||||
|
|
||||||
ret = sem_wait(&i8sak->sigsem);
|
ret = sem_wait(&i8sak->sigsem);
|
||||||
sem_post(&i8sak->exclsem);
|
sem_post(&i8sak->exclsem);
|
||||||
@ -215,7 +241,54 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
|||||||
i8sak->assoc = false;
|
i8sak->assoc = false;
|
||||||
printf("i8sak: test cancelled\n");
|
printf("i8sak: test cancelled\n");
|
||||||
i8sak_cmd_error(i8sak);
|
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)
|
if (notif->u.assocconf.status == IEEE802154_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
printf("i8sak: ASSOC.request succeeded\n");
|
printf("i8sak: ASSOC.request succeeded\n");
|
||||||
|
i8sak->result = OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("i8sak: ASSOC.request failed: %s\n",
|
printf("i8sak: ASSOC.request failed: %s\n",
|
||||||
IEEE802154_STATUS_STRING[notif->u.assocconf.status]);
|
IEEE802154_STATUS_STRING[notif->u.assocconf.status]);
|
||||||
|
i8sak->result = -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i8sak->assoc)
|
if (i8sak->assoc)
|
||||||
{
|
{
|
||||||
sem_post(&i8sak->sigsem);
|
|
||||||
i8sak->assoc = false;
|
i8sak->assoc = false;
|
||||||
|
sem_post(&i8sak->sigsem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ static int i8sak_showusage(FAR const char *progname, int exitcode)
|
|||||||
" startpan [-h]\n"
|
" startpan [-h]\n"
|
||||||
" acceptassoc [-h|e <eaddr>]\n"
|
" acceptassoc [-h|e <eaddr>]\n"
|
||||||
" scan [-h|p|a|e] minch-maxch\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"
|
" tx [-h|d] <hex-payload>\n"
|
||||||
" poll [-h]\n"
|
" poll [-h]\n"
|
||||||
" blaster [-h|q|f <hex payload>|p <period_ms>]\n"
|
" blaster [-h|q|f <hex payload>|p <period_ms>]\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user