ieee802154: Changes to support beacon-enabled networks

This commit is contained in:
Anthony Merlino 2017-06-21 15:01:39 -04:00
parent 6b25b0d65e
commit 88e0312897
5 changed files with 97 additions and 5 deletions

View File

@ -112,6 +112,8 @@ int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca);
int ieee802154_getdevmode(int fd, FAR enum ieee802154_devmode_e *devmode);
int ieee802154_setassocpermit(int fd, bool assocpermit);
#ifdef CONFIG_NET_6LOWPAN
/* Netork driver IOCTL helpers */

View File

@ -76,6 +76,7 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]
bool acceptall = true; /* start off assuming we are going to allow all connections */
int option;
int optcnt;
int fd;
optcnt = 0;
while ((option = getopt(argc, argv, ":he:")) != ERROR)
@ -115,6 +116,15 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]
}
}
fd = open(i8sak->devname, O_RDWR);
if (fd < 0)
{
printf("cannot open %s, errno=%d\n", i8sak->devname, errno);
i8sak_cmd_error(i8sak);
}
ieee802154_setassocpermit(fd, true);
if (!optcnt)
{
i8sak->acceptall = acceptall;

View File

@ -73,11 +73,12 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
{
struct ieee802154_reset_req_s resetreq;
struct ieee802154_start_req_s startreq;
bool beaconenabled = false;
int option;
int fd;
int i;
while ((option = getopt(argc, argv, ":h")) != ERROR)
while ((option = getopt(argc, argv, ":hb")) != ERROR)
{
switch (option)
{
@ -85,11 +86,15 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
fprintf(stderr, "Starts PAN as PAN Coordinator\n"
"Usage: %s [-h]\n"
" -h = this help menu\n"
" -b = start beacon-enabled PAN\n"
, argv[0]);
/* Must manually reset optind if we are going to exit early */
optind = -1;
return;
case 'b':
beaconenabled = true;
break;
case ':':
fprintf(stderr, "ERROR: missing argument\n");
/* Must manually reset optind if we are going to exit early */
@ -184,11 +189,22 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
printf("i8sak: starting PAN\n");
IEEE802154_PANIDCOPY(startreq.panid, i8sak->addr.panid);
startreq.chnum = i8sak->chnum;
startreq.chnum = i8sak->chnum;
startreq.chpage = i8sak->chpage;
startreq.beaconorder = 15;
startreq.pancoord = true;
if (beaconenabled)
{
startreq.beaconorder = 6;
startreq.superframeorder = 5;
}
else
{
startreq.beaconorder = 15;
}
startreq.pancoord = true;
startreq.coordrealign = false;
startreq.battlifeext = false;
ieee802154_start_req(fd, &startreq);

View File

@ -54,7 +54,7 @@ CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c
CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c
CSRCS += ieee802154_setrxonidle.c ieee802154_getrxonidle.c
CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c
CSRCS += ieee802154_getdevmode.c
CSRCS += ieee802154_getdevmode.c ieee802154_setassocpermit.c
ifeq ($(CONFIG_NET_6LOWPAN),y)
# Add Get/Set Attribute helpers

View File

@ -0,0 +1,64 @@
/****************************************************************************
* apps/wireless/ieee802154/libmac/ieee802154_assocpermit.c
*
* Copyright (C) 2017 Verge Inc. All rights reserved.
* Author: Anthony Merlino <anthony@vergeaero.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#include "wireless/ieee802154.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int ieee802154_setassocpermit(int fd, bool assocpermit)
{
struct ieee802154_set_req_s req;
req.attr = IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT;
req.attrval.mac.assocpermit = assocpermit;
return ieee802154_set_req(fd, &req);
}