Rename common directory to libradio; fix numerous compile errors.

This commit is contained in:
Gregory Nutt 2017-04-21 07:03:50 -06:00
parent 9ef7d4830a
commit 0098fec8e3
20 changed files with 133 additions and 90 deletions

View File

@ -5,7 +5,7 @@
menu "IEEE 802.15.4 applications"
source "$APPSDIR/wireless/ieee802154/common/Kconfig"
source "$APPSDIR/wireless/ieee802154/libradio/Kconfig"
source "$APPSDIR/wireless/ieee802154/coord/Kconfig"
source "$APPSDIR/wireless/ieee802154/i8sak/Kconfig"

View File

@ -1,7 +1,7 @@
############################################################################
# apps/wireless/ieee802154/Makefile
#
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
# Author: Sebastien Lorquet <sebastien@lorquet.fr>
#
# Redistribution and use in source and binary forms, with or without

View File

@ -238,15 +238,32 @@ static int coord_command(FAR struct ieee_coord_s *coord)
switch (cmd)
{
case IEEE802154_CMD_ASSOC_REQ : break;
case IEEE802154_CMD_ASSOC_RSP : 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); break;
case IEEE802154_CMD_COORD_REALIGN : break;
case IEEE802154_CMD_GTS_REQ : break;
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;
@ -298,11 +315,25 @@ static int coord_manage(FAR struct ieee_coord_s *coord)
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!");
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;
@ -334,9 +365,9 @@ static void coord_initialize(FAR struct ieee_coord_s *coord, FAR char *dev,
coord->chan = strtol(chan , NULL, 0);
coord->addr.ia_mode = IEEE802154_ADDRMODE_SHORT;
coord->addr.ia_panid = strtol(panid, NULL, 0);
coord->addr.ia_saddr = 0x0001;
coord->addr.mode = IEEE802154_ADDRMODE_SHORT;
coord->addr.panid = strtol(panid, NULL, 0);
coord->addr.saddr = 0x0001;
coord->fd = open(dev, O_RDWR);
}
@ -353,11 +384,11 @@ int coord_task(int s_argc, char **s_argv)
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.ia_panid, s_argc);
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.ia_saddr);
ieee802154_setpanid(g_coord.fd , g_coord.addr.ia_panid);
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)
@ -386,12 +417,13 @@ int coord_task(int s_argc, char **s_argv)
break;
case ACTION_PANID:
g_coord.addr.ia_panid = (uint16_t)g_message.param;
ieee802154_setpanid(g_coord.fd, g_coord.addr.ia_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");
printf("Received unknown message\n");
break;
}
}
}

View File

@ -428,7 +428,6 @@ int main(int argc, FAR char *argv[])
int i8_main(int argc, char *argv[])
#endif
{
union ieee802154_radioarg_u arg;
struct ieee802154_cca_s cca;
unsigned long arg = 0;
int fd;
@ -612,9 +611,9 @@ data_error:
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.ia_mode = IEEE802154_ADDRMODE_SHORT;
dest.ia_panid = 0xFFFF;
dest.ia_saddr = 0xFFFF;
dest.mode = IEEE802154_ADDRMODE_SHORT;
dest.panid = 0xFFFF;
dest.saddr = 0xFFFF;
g_txpacket.len = ieee802154_addrstore(&g_txpacket, &dest, NULL);

View File

@ -35,6 +35,6 @@
############################################################################
ifeq ($(CONFIG_IEEE802154_COMMON),y)
CONFIGURED_APPS += wireless/ieee802154/common
CONFIGURED_APPS += wireless/ieee802154/libradio
endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_addrparse.c
* apps/wireless/ieee802154/libradio/ieee802154_addrparse.c
*
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
@ -38,12 +38,14 @@
****************************************************************************/
#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 "ieee802154/ieee802154.h"
/****************************************************************************
@ -62,31 +64,31 @@ int ieee802154_addrparse(FAR struct ieee802154_packet_s *packet,
frame_ctrl = packet->data[0];
frame_ctrl |= packet->data[1] << 8;
dest->ia_mode = (frame_ctrl & IEEE802154_FRAMECTRL_DADDR)
>> IEEE802154_FRAMECTRL_SHIFT_DADDR;
dest->mode = (frame_ctrl & IEEE802154_FRAMECTRL_DADDR)
>> IEEE802154_FRAMECTRL_SHIFT_DADDR;
src->ia_mode = (frame_ctrl & IEEE802154_FRAMECTRL_SADDR)
>> IEEE802154_FRAMECTRL_SHIFT_SADDR;
src->mode = (frame_ctrl & IEEE802154_FRAMECTRL_SADDR)
>> IEEE802154_FRAMECTRL_SHIFT_SADDR;
/* Decode dest addr */
switch (dest->ia_mode)
switch (dest->mode)
{
case IEEE802154_ADDRMODE_SHORT:
{
memcpy(&dest->ia_panid, packet->data+index, 2);
memcpy(&dest->panid, packet->data+index, 2);
index += 2; /* Skip dest pan id */
memcpy(&dest->ia_saddr, packet->data+index, 2);
memcpy(&dest->saddr, packet->data+index, 2);
index += 2; /* Skip dest addr */
}
break;
case IEEE802154_ADDRMODE_EXTENDED:
{
memcpy(&dest->ia_panid, packet->data+index, 2);
memcpy(&dest->panid, packet->data+index, 2);
index += 2; /* Skip dest pan id */
memcpy(dest->ia_eaddr, packet->data+index, 8);
memcpy(dest->eaddr, packet->data+index, 8);
index += 8; /* Skip dest addr */
}
break;
@ -98,36 +100,36 @@ int ieee802154_addrparse(FAR struct ieee802154_packet_s *packet,
return -EINVAL;
}
if ((src->ia_mode == IEEE802154_ADDRMODE_SHORT) ||
(src->ia_mode == IEEE802154_ADDRMODE_EXTENDED))
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->ia_panid = dest->ia_panid;
src->panid = dest->panid;
}
else
{
memcpy(&src->ia_panid, packet->data+index, 2);
memcpy(&src->panid, packet->data+index, 2);
index += 2; /*skip dest pan id*/
}
}
/* Decode source addr */
switch (src->ia_mode)
switch (src->mode)
{
case IEEE802154_ADDRMODE_SHORT:
{
memcpy(&src->ia_saddr, packet->data+index, 2);
memcpy(&src->saddr, packet->data+index, 2);
index += 2; /* Skip src addr */
}
break;
case IEEE802154_ADDRMODE_EXTENDED:
{
memcpy(src->ia_eaddr, packet->data+index, 8);
memcpy(src->eaddr, packet->data+index, 8);
index += 8; /* Skip src addr */
}
break;

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_addrparse.c
* apps/wireless/ieee802154/libradio/ieee802154_addrparse.c
*
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
@ -68,7 +68,7 @@ int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
/* Encode dest addr */
if(dest == NULL || dest->ia_mode == IEEE802154_ADDRMODE_NONE)
if(dest == NULL || dest->mode == IEEE802154_ADDRMODE_NONE)
{
/* Set the destination address mode to none */
@ -76,23 +76,23 @@ int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
}
else
{
memcpy(packet->data+index, &dest->ia_panid, 2);
memcpy(packet->data+index, &dest->panid, 2);
index += 2; /* Skip dest pan id */
/* Set the dest address mode field */
frame_ctrl |= dest->ia_mode << IEEE802154_FRAMECTRL_SHIFT_DADDR;
frame_ctrl |= dest->mode << IEEE802154_FRAMECTRL_SHIFT_DADDR;
if(dest->ia_mode == IEEE802154_ADDRMODE_SHORT)
if(dest->mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(packet->data+index, &dest->ia_saddr, 2);
memcpy(packet->data+index, &dest->saddr, 2);
index += 2; /* Skip dest addr */
}
else if(dest->ia_mode == IEEE802154_ADDRMODE_EXTENDED)
else if(dest->mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(packet->data+index, &dest->ia_panid, 2);
memcpy(packet->data+index, &dest->panid, 2);
index += 2; /* Skip dest pan id */
memcpy(packet->data+index, dest->ia_eaddr, 8);
memcpy(packet->data+index, dest->eaddr, 8);
index += 8; /* Skip dest addr */
}
else
@ -105,12 +105,12 @@ int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
frame_ctrl &= ~IEEE802154_FRAMECTRL_PANIDCOMP;
if( (dest != NULL && dest->ia_mode != IEEE802154_ADDRMODE_NONE) &&
(src != NULL && src->ia_mode != IEEE802154_ADDRMODE_NONE) )
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->ia_panid == src->ia_panid)
if( dest->panid == src->panid)
{
frame_ctrl |= IEEE802154_FRAMECTRL_PANIDCOMP;
}
@ -122,7 +122,7 @@ int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
/* Encode source addr */
if(src == NULL || src->ia_mode == IEEE802154_ADDRMODE_NONE)
if(src == NULL || src->mode == IEEE802154_ADDRMODE_NONE)
{
/* Set the source address mode to none */
@ -134,22 +134,22 @@ int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
if(!(frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP))
{
memcpy(packet->data+index, &src->ia_panid, 2);
memcpy(packet->data+index, &src->panid, 2);
index += 2; /*skip src pan id*/
}
/* Set the source address mode field */
frame_ctrl |= src->ia_mode << IEEE802154_FRAMECTRL_SHIFT_SADDR;
frame_ctrl |= src->mode << IEEE802154_FRAMECTRL_SHIFT_SADDR;
if(src->ia_mode == IEEE802154_ADDRMODE_SHORT)
if(src->mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(packet->data+index, &src->ia_saddr, 2);
memcpy(packet->data+index, &src->saddr, 2);
index += 2; /* Skip src addr */
}
else if(src->ia_mode == IEEE802154_ADDRMODE_EXTENDED)
else if(src->mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(packet->data+index, src->ia_eaddr, 8);
memcpy(packet->data+index, src->eaddr, 8);
index += 8; /* Skip src addr */
}
else

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_addrtostr.c
* apps/wireless/ieee802154/libradio/ieee802154_addrtostr.c
*
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
@ -52,32 +52,32 @@ int ieee802154_addrtostr(FAR char *buf, int len,
FAR struct ieee802154_addr_s *addr)
{
#ifndef CONFIG_BIG_ENDIAN
uint16_t panid = ((addr->ia_panid & 0xff) << 8) | ((addr->ia_panid >> 8) & 0xff);
uint16_t panid = ((addr->panid & 0xff) << 8) | ((addr->panid >> 8) & 0xff);
#else
uint16_t panid = addr->ia_panid;
uint16_t panid = addr->panid;
#endif
if (addr->ia_mode == IEEE802154_ADDRMODE_NONE)
if (addr->mode == IEEE802154_ADDRMODE_NONE)
{
return snprintf(buf, len, "none");
}
else if (addr->ia_mode == IEEE802154_ADDRMODE_SHORT)
else if (addr->mode == IEEE802154_ADDRMODE_SHORT)
{
#ifndef CONFIG_BIG_ENDIAN
uint16_t saddr = ((addr->ia_saddr & 0xff) << 8) | ((addr->ia_saddr >> 8) & 0xff);
uint16_t saddr = ((addr->saddr & 0xff) << 8) | ((addr->saddr >> 8) & 0xff);
#else
uint16_t saddr = addr->ia_saddr;
uint16_t saddr = addr->saddr;
#endif
return snprintf(buf, len, "%04X/%04X", panid, saddr);
}
else if (addr->ia_mode == IEEE802154_ADDRMODE_EXTENDED)
else if (addr->mode == IEEE802154_ADDRMODE_EXTENDED)
{
int i;
int off = snprintf(buf, len, "%04X/", panid);
for (i = 0; i < 8; i++)
{
off += snprintf(buf + off, len -off, "%02X", addr->ia_eaddr[i]);
off += snprintf(buf + off, len -off, "%02X", addr->eaddr[i]);
}
return off;

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_getcca.c
* apps/wireless/ieee802154/libradio/ieee802154_getcca.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -39,12 +39,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <nuttx/fs/ioctl.h>
#include <string.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "ieee802154/ieee802154.h"
/****************************************************************************
@ -62,6 +65,6 @@ int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca)
printf("PHY802154IOC_GET_CCA failed\n");
}
mempy(cca, &arg.cca, sizeof(struct ieee802154_cca_s));
memcpy(cca, &arg.cca, sizeof(struct ieee802154_cca_s));
return ret;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_getchan.c
* apps/wireless/ieee802154/libradio/ieee802154_getchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setchan.c
* apps/wireless/ieee802154/libradio/ieee802154_setchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -39,9 +39,12 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <string.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
@ -55,7 +58,7 @@ int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca)
{
union ieee802154_radioarg_u arg;
mempy(&arg.cca, cca, sizeof(struct ieee802154_cca_s));
memcpy(&arg.cca, cca, sizeof(struct ieee802154_cca_s));
int ret = ioctl(fd, PHY802154IOC_SET_CCA,
(unsigned long)((uintptr_t)&arg));

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setchan.c
* apps/wireless/ieee802154/libradio/ieee802154_setchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setdevmode.c
* apps/wireless/ieee802154/libradio/ieee802154_setdevmode.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_eaddr.c
* apps/wireless/ieee802154/libradio/ieee802154_eaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
@ -39,11 +39,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <string.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "ieee802154/ieee802154.h"
/****************************************************************************

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setpanid.c
* apps/wireless/ieee802154/libradio/ieee802154_setpanid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setpromisc.c
* apps/wireless/ieee802154/libradio/ieee802154_setpromisc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setsaddr.c
* apps/wireless/ieee802154/libradio/ieee802154_setsaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.