Merge branch 'ieee802154' of https://bitbucket.org/nuttx/apps into ieee802154
This commit is contained in:
commit
0d1a7d1e18
208
include/wireless/ieee802154.h
Normal file
208
include/wireless/ieee802154.h
Normal file
@ -0,0 +1,208 @@
|
||||
/****************************************************************************
|
||||
* apps/include/wireless/ieee802154.h
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_WIRELESS_IEEE802154_H
|
||||
#define __APPS_INCLUDE_WIRELESS_IEEE802154_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.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 */
|
||||
|
||||
#if 0
|
||||
int ieee802154_mcps_register(int fd,
|
||||
FAR struct ieee802154_mcps_register_s *info);
|
||||
int ieee802154_mlme_register(int fd,
|
||||
FAR struct ieee802154_mlme_register_s *info);
|
||||
#endif
|
||||
int ieee802154_assoc_req(int fd, FAR struct ieee802154_assoc_req_s *req);
|
||||
int ieee802154_assoc_resp(int fd, FAR struct ieee802154_assoc_resp_s *resp);
|
||||
int ieee802154_disassoc_req(int fd,
|
||||
FAR struct ieee802154_disassoc_req_s *req);
|
||||
int ieee802154_get_req(int fd, FAR struct ieee802154_get_req_s *req);
|
||||
int ieee802154_gts_req(int fd, FAR struct ieee802154_gts_req_s *req);
|
||||
int ieee802154_orphan_resp(int fd,
|
||||
FAR struct ieee802154_orphan_resp_s *resp);
|
||||
int ieee802154_rxenable_req(int fd,
|
||||
FAR struct ieee802154_rxenable_req_s *req);
|
||||
int ieee802154_scan_req(int fd, FAR struct ieee802154_scan_req_s *req);
|
||||
int ieee802154_set_req(int fd, FAR struct ieee802154_set_req_s *req);
|
||||
int ieee802154_start_req(int fd, FAR struct ieee802154_start_req_s *req);
|
||||
int ieee802154_sync_req(int fd, FAR struct ieee802154_sync_req_s *req);
|
||||
int ieee802154_poll_req(int fd, FAR struct ieee802154_poll_req_s *req);
|
||||
#if 0
|
||||
int ieee802154_dps_req(int fd, FAR struct ieee802154_dps_req_s *req);
|
||||
int ieee802154_sounding_req(int fd,
|
||||
FAR struct ieee802154_sounding_req_s *req);
|
||||
int ieee802154_calibrate_req(int fd,
|
||||
FAR struct ieee802154_calibrate_req_s *req);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
/* Netork driver IOCTL helpers */
|
||||
|
||||
#if 0
|
||||
int sixlowpan_mcps_register(int fd, FAR const char *ifname,
|
||||
FAR const struct ieee802154_mcps_register_s *info);
|
||||
int sixlowpan_mlme_register(int fd, FAR const char *ifname,
|
||||
FAR const struct ieee802154_mlme_register_s *info);
|
||||
#endif
|
||||
int sixlowpan_assoc_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_assoc_req_s *req);
|
||||
int sixlowpan_assoc_resp(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_assoc_resp_s *resp);
|
||||
int sixlowpan_disassoc_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_disassoc_req_s *req);
|
||||
int sixlowpan_get_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_get_req_s *req);
|
||||
int sixlowpan_gts_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_gts_req_s *req);
|
||||
int sixlowpan_orphan_resp(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_orphan_resp_s *resp);
|
||||
int sixlowpan_rxenable_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_rxenable_req_s *req);
|
||||
int sixlowpan_scan_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_scan_req_s *req);
|
||||
int sixlowpan_set_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_set_req_s *req);
|
||||
int sixlowpan_start_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_start_req_s *req);
|
||||
int sixlowpan_sync_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_sync_req_s *req);
|
||||
int sixlowpan_poll_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_poll_req_s *req);
|
||||
#if 0
|
||||
int sixlowpan_dps_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_dps_req_s *req);
|
||||
int sixlowpan_sounding_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_sounding_req_s *req);
|
||||
int sixlowpan_calibrate_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_calibrate_req_s *req);
|
||||
#endif
|
||||
#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);
|
||||
|
||||
#endif /*__APPS_INCLUDE_WIRELESS_IEEE802154_H */
|
68
include/wireless/iwpan.h
Normal file
68
include/wireless/iwpan.h
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/include/wireless/iwpan.h
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_WIRELESS_IWPAN_H
|
||||
#define __APPS_INCLUDE_WIRELESS_IWPAN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototyppes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_WIRELESS_IWPAN_H */
|
||||
|
@ -7,6 +7,8 @@ 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.
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
#include "netutils/netlib.h"
|
||||
|
||||
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
@ -80,13 +81,10 @@ int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid)
|
||||
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
/* Put the driver name into the request */
|
||||
#warning Missing logic
|
||||
/* Perform the ioctl to get the current PAN ID */
|
||||
/* Use the helper provided in libradio */
|
||||
|
||||
ret = sixlowpan_getpanid(sockfd, ifname, panid);
|
||||
close(sockfd);
|
||||
|
||||
/* Reuturn the current PAN ID */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
#include "netutils/netlib.h"
|
||||
|
||||
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
@ -80,12 +81,9 @@ int netlib_setpanid(FAR const char *ifname, uint16_t panid)
|
||||
int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
/* Put the driver name into the request */
|
||||
# warning Missing Logic
|
||||
/* Put the new PAN ID into the request */
|
||||
|
||||
/* Perform the ioctl to set the new PAN ID */
|
||||
/* Use the helper provided in libradio */
|
||||
|
||||
ret = sixlowpan_setpanid(sockfd, ifname, panid);
|
||||
close(sockfd);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,9 @@
|
||||
|
||||
menu "IEEE 802.15.4 applications"
|
||||
|
||||
source "$APPSDIR/wireless/ieee802154/common/Kconfig"
|
||||
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"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/Make.defs
|
||||
# apps/wireless/ieee802154/libradio/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
|
@ -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
|
||||
|
@ -6,7 +6,8 @@
|
||||
config IEEE802154_COORD
|
||||
bool "Generic IEEE 802.15.4 coordinator"
|
||||
default n
|
||||
select IEEE802154_COMMON
|
||||
select IEEE802154_LIBRADIO
|
||||
select IEEE802154_LIBUTILS
|
||||
---help---
|
||||
Enable the IEEE 802.15.4 generic coordinator
|
||||
|
||||
|
@ -71,7 +71,7 @@
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
config IEEE802154_I8SAK
|
||||
bool "IEEE 802.15.4 Swiss Army Knife"
|
||||
default n
|
||||
select IEEE802154_COMMON
|
||||
select IEEE802154_LIBRADIO
|
||||
select IEEE802154_LIBUTILS
|
||||
---help---
|
||||
Enable the IEEE 802.15.4 Swiss Army Knife
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* apps/wireless/ieee802154/i8sak/i8sak_main.c
|
||||
* IEEE 802.15.4 Swiss Army Knife
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@ -94,8 +94,10 @@ uint8_t g_disp[16];
|
||||
|
||||
int energy_scan(int fd)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
uint8_t chan;
|
||||
uint8_t energy;
|
||||
int ret = OK;
|
||||
uint8_t chan, energy;
|
||||
|
||||
printf("\n");
|
||||
|
||||
@ -114,14 +116,15 @@ int energy_scan(int fd)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_ENERGYDETECT, (unsigned long)&energy);
|
||||
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] = energy;
|
||||
g_levels[chan] = arg.energy;
|
||||
}
|
||||
|
||||
/* Compute max with decay */
|
||||
@ -146,7 +149,7 @@ int energy_scan(int fd)
|
||||
printf("%2d : [%3d] ",chan+11, g_disp[chan]);
|
||||
|
||||
energy = g_disp[chan] >> 3;
|
||||
while(energy-- > 0)
|
||||
while (energy-- > 0)
|
||||
{
|
||||
printf("#");
|
||||
}
|
||||
@ -171,63 +174,66 @@ int energy_scan(int fd)
|
||||
|
||||
static int status(int fd)
|
||||
{
|
||||
int ret,i;
|
||||
uint8_t chan, eaddr[8];
|
||||
uint16_t panid, saddr;
|
||||
bool promisc;
|
||||
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)&panid);
|
||||
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)&saddr);
|
||||
ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret)
|
||||
{
|
||||
printf("PHY802154IOC_GET_SADDR failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)&eaddr[0]);
|
||||
saddr = arg.saddr;
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret)
|
||||
{
|
||||
printf("PHY802154IOC_GET_EADDR failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)&promisc);
|
||||
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;
|
||||
}
|
||||
|
||||
#if 0
|
||||
ret = ioctl(fd, MAC854IOCGORDER, (unsigned long)&order);
|
||||
if (ret)
|
||||
{
|
||||
printf("MAC854IOCGORDER failed\n");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Display */
|
||||
|
||||
printf("PANID %02X%02X CHAN %2d (%d MHz)\nSADDR %02X%02X EADDR ",
|
||||
@ -422,10 +428,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;
|
||||
unsigned long arg=0;
|
||||
struct ieee802154_cca_s cca;
|
||||
|
||||
printf("IEEE packet sniffer/dumper argc=%d\n", argc);
|
||||
|
||||
@ -605,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);
|
||||
|
||||
|
11
wireless/ieee802154/libmac/Kconfig
Normal file
11
wireless/ieee802154/libmac/Kconfig
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config IEEE802154_LIBMAC
|
||||
bool "IEEE 802.15.4 MAC library routines"
|
||||
default n
|
||||
---help---
|
||||
Some MAC library routines for ieee 802.15.4 apps
|
||||
|
@ -1,8 +1,8 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/Make.defs
|
||||
# apps/wireless/ieee802154/libradio/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
# 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
|
||||
@ -34,7 +34,7 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_IEEE802154_COMMON),y)
|
||||
CONFIGURED_APPS += wireless/ieee802154/common
|
||||
ifeq ($(CONFIG_IEEE802154_LIBMAC),y)
|
||||
CONFIGURED_APPS += wireless/ieee802154/libmac
|
||||
endif
|
||||
|
110
wireless/ieee802154/libmac/Makefile
Normal file
110
wireless/ieee802154/libmac/Makefile
Normal file
@ -0,0 +1,110 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/libmac/Makefile
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# libmac source files
|
||||
|
||||
ASRCS =
|
||||
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
|
||||
|
||||
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
||||
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
|
||||
|
||||
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
|
||||
|
68
wireless/ieee802154/libmac/ieee802154_assocreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_assocreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_assocreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_assoc_req(int fd, FAR struct ieee802154_assoc_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_ASSOC_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
72
wireless/ieee802154/libmac/ieee802154_assocresp.c
Normal file
72
wireless/ieee802154/libmac/ieee802154_assocresp.c
Normal file
@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_assocresp.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_assoc_resp(int fd, FAR struct ieee802154_assoc_resp_s *resp)
|
||||
{
|
||||
union ieee802154_macarg_u arg;
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_ASSOC_RESPONSE, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_RESPONSE failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
memcpy(resp, &arg.assocresp, sizeof(struct ieee802154_assoc_resp_s));
|
||||
return OK;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_disassocreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_disassocreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_assocreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_disassoc_req(int fd, FAR struct ieee802154_disassoc_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_DISASSOC_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_DISASSOC_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_getreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_getreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_getreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_get_req(int fd, FAR struct ieee802154_get_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_GET_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_gtsreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_gtsreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_gtsreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_gts_req(int fd, FAR struct ieee802154_gts_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_GTS_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_GTS_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
72
wireless/ieee802154/libmac/ieee802154_orphanresp.c
Normal file
72
wireless/ieee802154/libmac/ieee802154_orphanresp.c
Normal file
@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_orphanresp.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_orphan_resp(int fd, FAR struct ieee802154_orphan_resp_s *resp)
|
||||
{
|
||||
union ieee802154_macarg_u arg;
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_ORPHAN_RESPONSE, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_ORPHAN_RESPONSE failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
memcpy(resp, &arg.orphanresp, sizeof(struct ieee802154_orphan_resp_s));
|
||||
return OK;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_pollreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_pollreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_pollreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_poll_req(int fd, FAR struct ieee802154_poll_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_POLL_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_POLL_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_resetreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_resetreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_resetreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_reset_req(int fd, FAR struct ieee802154_reset_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_RESET_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_RESET_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_rxenabreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_rxenabreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_rxenabreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_rxenable_req(int fd, FAR struct ieee802154_rxenable_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_RXENABLE_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_RXENABLE_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_scanreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_scanreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_scanreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_scan_req(int fd, FAR struct ieee802154_scan_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_SCAN_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_SCAN_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_setreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_setreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_setreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_set_req(int fd, FAR struct ieee802154_set_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_SET_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_SET_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_startreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_startreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_startreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_start_req(int fd, FAR struct ieee802154_start_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_START_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_START_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
68
wireless/ieee802154/libmac/ieee802154_syncreq.c
Normal file
68
wireless/ieee802154/libmac/ieee802154_syncreq.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_syncreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_sync_req(int fd, FAR struct ieee802154_sync_req_s *req)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, MAC802154IOC_MLME_SYNC_REQUEST, (unsigned long)((uintptr_t)req));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_SYNC_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_assocreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_assocreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_assocreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_assoc_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_assoc_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.assocreq, req, sizeof(struct ieee802154_assoc_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
76
wireless/ieee802154/libmac/sixlowpan_assocresp.c
Normal file
76
wireless/ieee802154/libmac/sixlowpan_assocresp.c
Normal file
@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_assocresp.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_assoc_resp(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_assoc_resp_s *resp)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_RESPONSE,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_ASSOC_RESPONSE failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
memcpy(resp, &arg.u.assocresp, sizeof(struct ieee802154_assoc_resp_s));
|
||||
return OK;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_disassocreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_disassocreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_disassocreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_desassoc_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_disassoc_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.disassocreq, req, sizeof(struct ieee802154_disassoc_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_DISASSOC_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_DISASSOC_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_getreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_getreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_getreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_get_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_get_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.getreq, req, sizeof(struct ieee802154_get_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_GET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_gtsreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_gtsreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_gtsreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_gts_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_gts_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.gtsreq, req, sizeof(struct ieee802154_gts_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_GTS_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_GTS_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
76
wireless/ieee802154/libmac/sixlowpan_orphanresp.c
Normal file
76
wireless/ieee802154/libmac/sixlowpan_orphanresp.c
Normal file
@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_orphanresp.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_orphan_resp(int sock, FAR const char *ifname,
|
||||
FAR struct ieee802154_orphan_resp_s *resp)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_ORPHAN_RESPONSE,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_ORPHAN_RESPONSE failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
memcpy(resp, &arg.u.orphanresp, sizeof(struct ieee802154_orphan_resp_s));
|
||||
return OK;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_pollreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_pollreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_pollreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_poll_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_poll_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.pollreq, req, sizeof(struct ieee802154_poll_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_POLL_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_POLL_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_resetreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_resetreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_resetreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_reset_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_reset_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.resetreq, req, sizeof(struct ieee802154_reset_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_RESET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_RESET_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_rxenabreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_rxenabreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_rxenabreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_rxenable_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_rxenable_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.rxenabreq, req, sizeof(struct ieee802154_rxenable_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_RXENABLE_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_RXENABLE_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_scanreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_scanreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_scanreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_scan_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_scan_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.scanreq, req, sizeof(struct ieee802154_scan_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_SCAN_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_SCAN_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_setreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_setreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_setreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_set_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_set_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.setreq, req, sizeof(struct ieee802154_set_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_SET_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_SET_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_startreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_startreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_startreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_start_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_start_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.startreq, req, sizeof(struct ieee802154_start_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_START_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_START_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
75
wireless/ieee802154/libmac/sixlowpan_syncreq.c
Normal file
75
wireless/ieee802154/libmac/sixlowpan_syncreq.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/sixlowpan_syncreq.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_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_sync_req(int sock, FAR const char *ifname,
|
||||
FAR const struct ieee802154_sync_req_s *req)
|
||||
{
|
||||
struct ieee802154_netmac_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&arg.u.syncreq, req, sizeof(struct ieee802154_sync_req_s));
|
||||
|
||||
ret = ioctl(sock, MAC802154IOC_MLME_SYNC_REQUEST,
|
||||
(unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -errno;
|
||||
fprintf(stderr, "MAC802154IOC_MLME_SYNC_REQUEST failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
11
wireless/ieee802154/libradio/.gitignore
vendored
Normal file
11
wireless/ieee802154/libradio/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/*.asm
|
||||
/*.obj
|
||||
/*.rel
|
||||
/*.lst
|
||||
/*.sym
|
||||
/*.adb
|
||||
/*.lib
|
||||
/*.src
|
11
wireless/ieee802154/libradio/Kconfig
Normal file
11
wireless/ieee802154/libradio/Kconfig
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# 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
|
||||
|
40
wireless/ieee802154/libradio/Make.defs
Normal file
40
wireless/ieee802154/libradio/Make.defs
Normal file
@ -0,0 +1,40 @@
|
||||
############################################################################
|
||||
# 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
|
||||
|
118
wireless/ieee802154/libradio/Makefile
Normal file
118
wireless/ieee802154/libradio/Makefile
Normal file
@ -0,0 +1,118 @@
|
||||
############################################################################
|
||||
# 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
|
||||
|
71
wireless/ieee802154/libradio/ieee802154_energydetect.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_energydetect.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,13 +39,17 @@
|
||||
****************************************************************************/
|
||||
|
||||
#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 <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -52,11 +57,17 @@
|
||||
|
||||
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_GET_CCA, (unsigned long)cca );
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_GET_CCA, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("PHY802154IOC_GET_CCA failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_GET_CCA failed\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
memcpy(cca, &arg.cca, sizeof(struct ieee802154_cca_s));
|
||||
return OK;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,13 +39,16 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -52,11 +56,17 @@
|
||||
|
||||
int ieee802154_getchan(int fd, FAR uint8_t *chan)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_GET_CHAN, (unsigned long)chan);
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_GET_CHAN, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("PHY802154IOC_GET_CHAN failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_GET_CHAN failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
*chan = arg.channel;
|
||||
return OK;
|
||||
}
|
71
wireless/ieee802154/libradio/ieee802154_getdevmode.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_getdevmode.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
72
wireless/ieee802154/libradio/ieee802154_geteaddr.c
Normal file
72
wireless/ieee802154/libradio/ieee802154_geteaddr.c
Normal file
@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_geteaddr.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 ieee802154_geteaddr(int fd, FAR uint8_t *eaddr)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
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;
|
||||
}
|
||||
|
||||
memcpy(eaddr, arg.eaddr, EADDR_SIZE);
|
||||
return OK;
|
||||
}
|
71
wireless/ieee802154/libradio/ieee802154_getpanid.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_getpanid.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_getpanid.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_getpanid(int fd, FAR uint16_t *panid)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
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;
|
||||
}
|
||||
|
||||
*panid = arg.panid;
|
||||
return OK;
|
||||
}
|
71
wireless/ieee802154/libradio/ieee802154_getpromisc.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_getpromisc.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_getpromisc.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_getpromisc(int fd, FAR bool *promisc)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
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;
|
||||
}
|
||||
|
||||
*promisc = arg.promisc;
|
||||
return OK;
|
||||
}
|
71
wireless/ieee802154/libradio/ieee802154_getsaddr.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_getsaddr.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_getsaddr.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_getsaddr(int fd, FAR uint16_t *saddr)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
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;
|
||||
}
|
||||
|
||||
*saddr = arg.saddr;
|
||||
return OK;
|
||||
}
|
71
wireless/ieee802154/libradio/ieee802154_gettxpwr.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_gettxpwr.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_gettxpwr.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_gettxpwr(int fd, FAR int32_t *txpwr)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
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;
|
||||
}
|
||||
|
||||
*txpwr = arg.txpwr;
|
||||
return OK;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,13 +39,17 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -52,10 +57,16 @@
|
||||
|
||||
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_CCA, (unsigned long)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)
|
||||
{
|
||||
printf("PHY802154IOC_SET_CCA failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_SET_CCA failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,12 +39,16 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -51,10 +56,16 @@
|
||||
|
||||
int ieee802154_setchan(int fd, uint8_t chan)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_CHAN, (unsigned long)chan );
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
arg.channel = chan;
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_SET_CHAN, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("PHY802154IOC_SET_CHAN failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_SET_CHAN failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,12 +39,16 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -51,10 +56,16 @@
|
||||
|
||||
int ieee802154_setdevmode(int fd, uint8_t devmode)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_DEVMODE, (unsigned long)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)
|
||||
{
|
||||
printf("PHY802154IOC_SET_DEVMODE failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_SET_DEVMODE failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,23 +39,34 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_seteaddr(int fd, uint8_t *eaddr)
|
||||
int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_EADDR, (unsigned long)eaddr );
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
memcpy(arg.eaddr, eaddr, EADDR_SIZE);
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_SET_EADDR, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("PHY802154IOC_SET_EADDR failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_SET_EADDR failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,19 +39,33 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setpanid(int fd, uint16_t panid)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_PANID, (unsigned long)panid );
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
arg.panid = panid;
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_SET_PANID, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("PHY802154IOC_SET_PANID failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_SET_PANID failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,13 +39,17 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -52,10 +57,16 @@
|
||||
|
||||
int ieee802154_setpromisc(int fd, bool promisc)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_PROMISC, (unsigned long)promisc );
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
arg.promisc = promisc;
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_SET_PROMISC, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("PHY802154IOC_SET_PROMISC failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_SET_PROMISC failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
@ -38,12 +39,16 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -51,10 +56,16 @@
|
||||
|
||||
int ieee802154_setsaddr(int fd, uint16_t saddr)
|
||||
{
|
||||
int ret = ioctl(fd, PHY802154IOC_SET_SADDR, (unsigned long)saddr );
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
arg.saddr = saddr;
|
||||
|
||||
ret = ioctl(fd, PHY802154IOC_SET_SADDR, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("PHY802154IOC_SET_SADDR failed\n");
|
||||
ret = -errno;
|
||||
fprintf(stderr, "PHY802154IOC_SET_SADDR failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
71
wireless/ieee802154/libradio/ieee802154_settxpwr.c
Normal file
71
wireless/ieee802154/libradio/ieee802154_settxpwr.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/ieee802154_settxpwr.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_settxpwr(int fd, int32_t txpwr)
|
||||
{
|
||||
union ieee802154_radioarg_u arg;
|
||||
int ret;
|
||||
|
||||
arg.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;
|
||||
}
|
74
wireless/ieee802154/libradio/sixlowpan_energydetect.c
Normal file
74
wireless/ieee802154/libradio/sixlowpan_energydetect.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
75
wireless/ieee802154/libradio/sixlowpan_getcca.c
Normal file
75
wireless/ieee802154/libradio/sixlowpan_getcca.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
74
wireless/ieee802154/libradio/sixlowpan_getchan.c
Normal file
74
wireless/ieee802154/libradio/sixlowpan_getchan.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_getchan.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_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
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 = arg.u.channel;
|
||||
return OK;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_getdevmode.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_getdevmode.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
74
wireless/ieee802154/libradio/sixlowpan_geteaddr.c
Normal file
74
wireless/ieee802154/libradio/sixlowpan_geteaddr.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_geteaddr.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_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
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, arg.u.eaddr, EADDR_SIZE);
|
||||
return OK;
|
||||
}
|
74
wireless/ieee802154/libradio/sixlowpan_getpanid.c
Normal file
74
wireless/ieee802154/libradio/sixlowpan_getpanid.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_getpanid.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_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
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 = arg.u.panid;
|
||||
return OK;
|
||||
}
|
74
wireless/ieee802154/libradio/sixlowpan_getpromisc.c
Normal file
74
wireless/ieee802154/libradio/sixlowpan_getpromisc.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_getpromisc.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_getpromisc(int sock, FAR const char *ifname, FAR bool *promisc)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
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 = arg.u.promisc;
|
||||
return OK;
|
||||
}
|
74
wireless/ieee802154/libradio/sixlowpan_getsaddr.c
Normal file
74
wireless/ieee802154/libradio/sixlowpan_getsaddr.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_getsaddr.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_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
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 = arg.u.saddr;
|
||||
return OK;
|
||||
}
|
74
wireless/ieee802154/libradio/sixlowpan_gettxpwr.c
Normal file
74
wireless/ieee802154/libradio/sixlowpan_gettxpwr.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_gettxpwr.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_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
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 = arg.u.txpwr;
|
||||
return OK;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_setcca.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_setcca.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_setchan.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_setchan.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* 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_setchan(int sock, FAR const char *ifname, uint8_t chan)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
arg.u.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;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_setdevmode.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_setdevmode.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_seteaddr.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_seteaddr.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_seteaddr.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_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(arg.u.eaddr, eaddr, EADDR_SIZE);
|
||||
|
||||
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;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_setpanid.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_setpanid.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_setpanid.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_setpanid(int sock, FAR const char *ifname, uint16_t panid)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
arg.u.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;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
* apps/include/ieee802154/ieee802154.h
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_setpromisc.c
|
||||
*
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
* 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
|
||||
@ -33,29 +33,42 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_IEEE802154_IEEE802154_H
|
||||
#define __APPS_INCLUDE_IEEE802154_IEEE802154_H
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#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>
|
||||
|
||||
int ieee802154_setchan (int fd, uint8_t chan);
|
||||
int ieee802154_getchan (int fd, FAR uint8_t *chan);
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
int ieee802154_setpanid (int fd, uint16_t panid);
|
||||
int ieee802154_setsaddr (int fd, uint16_t saddr);
|
||||
int ieee802154_seteaddr (int fd, FAR uint8_t *chan);
|
||||
int ieee802154_setpromisc(int fd, bool promisc);
|
||||
int ieee802154_setdevmode(int fd, uint8_t devmode);
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca);
|
||||
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca);
|
||||
int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
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);
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
arg.u.promisc = promisc;
|
||||
|
||||
#endif /*__APPS_INCLUDE_IEEE802154_IEEE802154_H */
|
||||
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;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_setsaddr.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_setsaddr.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_setsaddr.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_setsaddr(int sock, FAR const char *ifname, uint16_t saddr)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
arg.u.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;
|
||||
}
|
73
wireless/ieee802154/libradio/sixlowpan_settxpwr.c
Normal file
73
wireless/ieee802154/libradio/sixlowpan_settxpwr.c
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libradio/sixlowpan_settxpwr.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_settxpwr(int sock, FAR const char *ifname, int32_t txpwr)
|
||||
{
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
|
||||
arg.u.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;
|
||||
}
|
11
wireless/ieee802154/libutils/.gitignore
vendored
Normal file
11
wireless/ieee802154/libutils/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/*.asm
|
||||
/*.obj
|
||||
/*.rel
|
||||
/*.lst
|
||||
/*.sym
|
||||
/*.adb
|
||||
/*.lib
|
||||
/*.src
|
@ -3,7 +3,7 @@
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config IEEE802154_COMMON
|
||||
config IEEE802154_LIBUTILS
|
||||
bool "Common IEEE 802.15.4 library routines"
|
||||
default n
|
||||
---help---
|
40
wireless/ieee802154/libutils/Make.defs
Normal file
40
wireless/ieee802154/libutils/Make.defs
Normal file
@ -0,0 +1,40 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/libutils/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2016-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_IEEE802154_LIBUTILS),y)
|
||||
CONFIGURED_APPS += wireless/ieee802154/libutils
|
||||
endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# apps/wireless/ieee802154/Makefile
|
||||
# apps/wireless/ieee802154/libradio/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2016-2-17 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -37,18 +37,11 @@
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# NSH Library
|
||||
# libutils source files
|
||||
|
||||
ASRCS =
|
||||
CSRCS = ieee802154_setchan.c ieee802154_getchan.c
|
||||
CSRCS += ieee802154_setpanid.c
|
||||
CSRCS += ieee802154_seteaddr.c ieee802154_setsaddr.c
|
||||
CSRCS += ieee802154_setpromisc.c ieee802154_setdevmode.c
|
||||
CSRCS += ieee802154_setcca.c ieee802154_getcca.c
|
||||
CSRCS += ieee802154_addrparse.c ieee802154_addrstore.c ieee802154_addrtostr.c
|
||||
|
||||
#
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
@ -56,12 +49,12 @@ SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\..\libapps$(LIBEXT)
|
||||
BIN = ..\..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\..\\libapps$(LIBEXT)
|
||||
BIN = ..\\..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../../libapps$(LIBEXT)
|
||||
BIN = ../../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/common/ieee802154_addrparse.c
|
||||
* apps/wireless/ieee802154/libutils/ieee802154_addrparse.c
|
||||
*
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
@ -38,13 +38,15 @@
|
||||
****************************************************************************/
|
||||
|
||||
#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"
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -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;
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/common/ieee802154_addrparse.c
|
||||
* apps/wireless/ieee802154/libutils/ieee802154_addrparse.c
|
||||
*
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -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
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/common/ieee802154_addrtostr.c
|
||||
* apps/wireless/ieee802154/libutils/ieee802154_addrtostr.c
|
||||
*
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
@ -42,7 +42,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -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;
|
35
wireless/iwpan/Kconfig
Normal file
35
wireless/iwpan/Kconfig
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
menuconfig WIRELESS_IWPAN
|
||||
bool "IEEE 802.15.4 Command Line Tool"
|
||||
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
|
||||
be used to manage 802.15.4 PAN.
|
||||
|
||||
if WIRELESS_IWPAN
|
||||
|
||||
config WIRELESS_IWPAN_PROGNAME
|
||||
string "Program Name"
|
||||
default "iwpan"
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the name of the program that will be use when the NSH ELF
|
||||
program is installed.
|
||||
|
||||
config WIRELESS_IWPAN_STACKSIZE
|
||||
int "Stack Size (bytes)"
|
||||
default 2048
|
||||
|
||||
config WIRELESS_IWPAN_PRIORITY
|
||||
int "Command Priority"
|
||||
default 100
|
||||
|
||||
endif
|
41
wireless/iwpan/Make.defs
Normal file
41
wireless/iwpan/Make.defs
Normal file
@ -0,0 +1,41 @@
|
||||
############################################################################
|
||||
# apps/wireless/iwpan/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_WIRELESS_IWPAN),y)
|
||||
CONFIGURED_APPS += wireless/iwpan
|
||||
endif
|
||||
|
150
wireless/iwpan/Makefile
Normal file
150
wireless/iwpan/Makefile
Normal file
@ -0,0 +1,150 @@
|
||||
############################################################################
|
||||
# apps/wireless/iwpan/Makefile
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# TODO, this makefile should run make under the app dirs, instead of
|
||||
# sourcing the Make.defs!
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# IEEE802.11 Wapi Application
|
||||
|
||||
CONFIG_WIRELESS_IWPAN_PRIORITY ?= 100
|
||||
CONFIG_WIRELESS_IWPAN_STACKSIZE ?= 2048
|
||||
|
||||
APPNAME = iwpan
|
||||
PRIORITY = $(CONFIG_WIRELESS_IWPAN_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_WIRELESS_IWPAN_STACKSIZE)
|
||||
|
||||
ASRCS =
|
||||
CSRCS =
|
||||
MAINSRC =
|
||||
|
||||
VPATH = .
|
||||
|
||||
include $(APPDIR)/wireless/iwpan/src/Make.defs
|
||||
|
||||
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_IWPAN_PROGNAME ?= iwpan$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_IWPAN_PROGNAME)
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Common build
|
||||
|
||||
all: .built
|
||||
.PHONY: context depend clean distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
$(Q) 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
|
||||
|
||||
# Register application
|
||||
|
||||
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
|
||||
|
||||
# Create dependencies
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
.PHONY: preconfig
|
||||
preconfig:
|
47
wireless/iwpan/src/Make.defs
Normal file
47
wireless/iwpan/src/Make.defs
Normal file
@ -0,0 +1,47 @@
|
||||
############################################################################
|
||||
# apps/wireless/iwpan/src/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_WIRELESS_IWPAN),y)
|
||||
|
||||
CSRCS =
|
||||
MAINSRC = iwpan.c
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/wireless/iwpan/src}
|
||||
|
||||
endif
|
||||
|
774
wireless/iwpan/src/iwpan.c
Normal file
774
wireless/iwpan/src/iwpan.c
Normal file
@ -0,0 +1,774 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/iwpan/src/iwpan.c
|
||||
*
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - 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.
|
||||
*
|
||||
* 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 <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
#include "wireless/iwpan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The address family that we used to create the socket really does not
|
||||
* matter. It should, however, be valid in the current configuration.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NET_IPv4)
|
||||
# define PF_INETX PF_INET
|
||||
#elif defined(CONFIG_NET_IPv6)
|
||||
# define PF_INETX PF_INET6
|
||||
#endif
|
||||
|
||||
/* SOCK_DGRAM is the preferred socket type to use when we just want a
|
||||
* socket for performing driver ioctls. However, we can't use SOCK_DRAM
|
||||
* if UDP is disabled.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
# define SOCK_IWPAN SOCK_DGRAM
|
||||
#else
|
||||
# define SOCK_IWPAN SOCK_STREAM
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Describes one command */
|
||||
|
||||
struct iwpan_command_s
|
||||
{
|
||||
FAR const char *name;
|
||||
uint8_t noptions;
|
||||
CODE void *handler;
|
||||
};
|
||||
|
||||
/* Generic form of a command handler */
|
||||
|
||||
typedef void (*cmd1_t)(int sock, FAR const char *arg1);
|
||||
typedef void (*cmd2_t)(int sock, FAR const char *arg1,
|
||||
FAR const char *arg2);
|
||||
typedef void (*cmd3_t)(int sock, FAR const char *arg1,
|
||||
FAR const char *arg2, FAR const char *arg3);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_show_cmd(int sock, FAR const char *ifname);
|
||||
static void iwpan_cca_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *ccastr);
|
||||
static void iwpan_chan_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *chanstr);
|
||||
static void iwpan_devmode_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *modstr);
|
||||
static void iwpan_eaddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr);
|
||||
static void iwpan_panid_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *panstr);
|
||||
static void iwpan_promisc_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *boolstr);
|
||||
static void iwpan_saddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr);
|
||||
static void iwpan_txpwr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *pwrstr);
|
||||
|
||||
static void iwpan_showusage(FAR const char *progname, int exitcode);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct iwpan_command_s g_iwpan_commands[] =
|
||||
{
|
||||
{"help", 0, (CODE void *)NULL},
|
||||
{"show", 1, (CODE void *)iwpan_show_cmd},
|
||||
{"cca", 2, (CODE void *)iwpan_cca_cmd},
|
||||
{"chan", 2, (CODE void *)iwpan_chan_cmd},
|
||||
{"devmode", 2, (CODE void *)iwpan_devmode_cmd},
|
||||
{"eaddr", 2, (CODE void *)iwpan_eaddr_cmd},
|
||||
{"panid", 2, (CODE void *)iwpan_panid_cmd},
|
||||
{"promisc", 2, (CODE void *)iwpan_promisc_cmd},
|
||||
{"saddr", 2, (CODE void *)iwpan_saddr_cmd},
|
||||
{"txpwr", 2, (CODE void *)iwpan_txpwr_cmd},
|
||||
};
|
||||
|
||||
#define NCOMMANDS (sizeof(g_iwpan_commands) / sizeof(struct iwpan_command_s))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2long
|
||||
*
|
||||
* Description:
|
||||
* Convert a string to an integer value
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static long iwpan_str2long(FAR const char *str)
|
||||
{
|
||||
FAR char *endptr;
|
||||
long value;
|
||||
|
||||
value = strtol(str, &endptr, 0);
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Garbage after numeric argument\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (value > INT_MAX || value < INT_MIN)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Integer value out of range\n");
|
||||
return LONG_MAX;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2luint8
|
||||
*
|
||||
* Description:
|
||||
* Convert a string to an integer value
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t iwpan_str2luint8(FAR const char *str)
|
||||
{
|
||||
long value = iwpan_str2long(str);
|
||||
if (value < 0 || value > UINT8_MAX)
|
||||
{
|
||||
fprintf(stderr, "ERROR: 8-bit value out of range\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return (uint8_t)value;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2luint16
|
||||
*
|
||||
* Description:
|
||||
* Convert a string to an integer value
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint16_t iwpan_str2luint16(FAR const char *str)
|
||||
{
|
||||
long value = iwpan_str2long(str);
|
||||
if (value < 0 || value > UINT16_MAX)
|
||||
{
|
||||
fprintf(stderr, "ERROR: 16-bit value out of range\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return (uint8_t)value;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_char2nibble
|
||||
*
|
||||
* Description:
|
||||
* Convert an hexadecimal character to a 4-bit nibble.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t iwpan_char2nibble(char ch)
|
||||
{
|
||||
if (ch >= '0' && ch <= '9')
|
||||
{
|
||||
return ch - '0';
|
||||
}
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
{
|
||||
return ch - 'a' + 10;
|
||||
}
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
{
|
||||
return ch - 'A' + 10;
|
||||
}
|
||||
else if (ch == '\0')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unexpected end hex\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unexpected character in hex value: %02x\n", ch);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2eaddr
|
||||
*
|
||||
* Description:
|
||||
* Convert a string 8-byte EADAR array.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_str2eaddr(FAR const char *str, FAR uint8_t *eaddr)
|
||||
{
|
||||
FAR const char *src = str;
|
||||
uint8_t bvalue;
|
||||
char ch;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
bvalue = iwpan_char2nibble(ch) << 4;
|
||||
|
||||
ch = (char)*src++;
|
||||
bvalue |= iwpan_char2nibble(ch);
|
||||
|
||||
*eaddr++ = bvalue;
|
||||
|
||||
if (i < 7)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
if (ch != ':')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing colon separator: %s\n", str);
|
||||
fprintf(stderr, " Expected xx:xx:xx:xx:xx:xx:xx:xx\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_str2bool
|
||||
*
|
||||
* Description:
|
||||
* Convert a boolean name to a boolean value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static bool iwpan_str2bool(FAR const char *str)
|
||||
{
|
||||
if (strcasecmp(str, "true") == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (strcasecmp(str, "false") == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Invalid boolean name: %s\n", str);
|
||||
fprintf(stderr, " Expected true or false\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_show_cmd
|
||||
*
|
||||
* Description:
|
||||
* Show all radio device settings
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_show_cmd(int sock, FAR const char *ifname)
|
||||
{
|
||||
uint8_t eaddr[EADDR_SIZE] =
|
||||
{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
struct ieee802154_cca_s cca;
|
||||
uint8_t b;
|
||||
} u;
|
||||
|
||||
int32_t txpwr = INT32_MAX;
|
||||
uint16_t saddr = UINT16_MAX;
|
||||
uint16_t panid = UINT16_MAX;
|
||||
uint8_t chan = UINT8_MAX;
|
||||
uint8_t devmode = UINT8_MAX;
|
||||
bool promisc = false;
|
||||
bool energy = false;
|
||||
int ret;
|
||||
|
||||
u.b = 0xff;
|
||||
|
||||
/* Read all parameters from the radio */
|
||||
|
||||
ret = sixlowpan_getchan(sock, ifname, &chan);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getchan() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getpanid(sock, ifname, &panid);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getpanid() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getsaddr(sock, ifname, &saddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getsaddr() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_geteaddr(sock, ifname, eaddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_geteaddr() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getpromisc(sock, ifname, &promisc);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getpromisc() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getdevmode(sock, ifname, &devmode);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getdevmode() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_gettxpwr(sock, ifname, &txpwr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_gettxpwr() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_getcca(sock, ifname, &u.cca);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_getcca() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = sixlowpan_energydetect(sock, ifname, &energy);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_energydetect() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
/* And generate the output */
|
||||
|
||||
fprintf(stderr, "\nRadio Settings (%s):\n", ifname);
|
||||
fprintf(stderr, " chan: %u\n", chan);
|
||||
fprintf(stderr, " saddr: %04x\n", saddr);
|
||||
fprintf(stderr, " eaddr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5],
|
||||
eaddr[6], eaddr[7]);
|
||||
fprintf(stderr, " panid: %04x\n", panid);
|
||||
fprintf(stderr, " devmode: %u\n", devmode);
|
||||
fprintf(stderr, " promisc: %s\n", promisc ? "true" : "false");
|
||||
fprintf(stderr, " cca: %02x\n", u.b);
|
||||
fprintf(stderr, " txpwr: %ld\n", (long)txpwr);
|
||||
fprintf(stderr, " ernergy: %s\n", energy ? "true" : "false");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_cca_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device Clear Channel Assessment (CCA) thresholds.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_cca_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *ccastr)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct ieee802154_cca_s cca;
|
||||
uint8_t b;
|
||||
} u;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
u.b = iwpan_str2luint8(ccastr);
|
||||
|
||||
/* Set the CCA */
|
||||
|
||||
ret = sixlowpan_setcca(sock, ifname, &u.cca);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setcca() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_chan_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device channel
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_chan_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *chanstr)
|
||||
{
|
||||
uint8_t chan;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
chan = iwpan_str2luint8(chanstr);
|
||||
|
||||
/* Set the channel */
|
||||
|
||||
ret = sixlowpan_setchan(sock, ifname, chan);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setchan() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_devmode_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device mode
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_devmode_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *modestr)
|
||||
{
|
||||
uint8_t devmode;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
devmode = iwpan_str2luint8(modestr);
|
||||
|
||||
/* Set the devmode */
|
||||
|
||||
ret = sixlowpan_setdevmode(sock, ifname, devmode);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR:int sixlowpan_setdevmode() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_eaddr_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device extended address
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_eaddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr)
|
||||
{
|
||||
uint8_t eaddr[EADDR_SIZE];
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
iwpan_str2eaddr(addrstr, eaddr);
|
||||
|
||||
/* Set the extended address */
|
||||
|
||||
ret = sixlowpan_seteaddr(sock, ifname, eaddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_seteaddr() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_panid_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device PAN ID.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_panid_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *panstr)
|
||||
{
|
||||
uint16_t panid;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
panid = iwpan_str2luint16(panstr);
|
||||
|
||||
/* Set the PAN ID */
|
||||
|
||||
ret = sixlowpan_setpanid(sock, ifname, panid);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setpanid() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_promisc_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device PAN ID.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_promisc_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *boolstr)
|
||||
{
|
||||
bool promisc;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
promisc = iwpan_str2bool(boolstr);
|
||||
|
||||
/* Set the promisc */
|
||||
|
||||
ret = sixlowpan_setpromisc(sock, ifname, promisc);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setpromisc() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_saddr_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device short address
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_saddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr)
|
||||
{
|
||||
uint16_t saddr;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
saddr = iwpan_str2luint16(addrstr);
|
||||
|
||||
/* Set the short address */
|
||||
|
||||
ret = sixlowpan_setsaddr(sock, ifname, saddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_setsaddr() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_txpwr_cmd
|
||||
*
|
||||
* Description:
|
||||
* Set radio device TX power
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_txpwr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *pwrstr)
|
||||
{
|
||||
long txpwr;
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
txpwr = iwpan_str2long(pwrstr);
|
||||
|
||||
/* Set the TX power */
|
||||
|
||||
ret = sixlowpan_settxpwr(sock, ifname, (int32_t)txpwr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sixlowpan_settxpwr() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iwpan_showusage
|
||||
*
|
||||
* Description:
|
||||
* Show program usage.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void iwpan_showusage(FAR const char *progname, int exitcode)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n", progname);
|
||||
fprintf(stderr, "\t%s <command> <ifname> [OPTIONS]\n", progname);
|
||||
fprintf(stderr, "\nWhere supported commands an [OPTIONS] appear below\n");
|
||||
fprintf(stderr, "\nRadio Query:\n");
|
||||
fprintf(stderr, "\t%s show <ifname>\n", progname);
|
||||
fprintf(stderr, "\nRadio Settings:\n");
|
||||
fprintf(stderr, "\t%s cca <ifname> <hex cca>\n", progname);
|
||||
fprintf(stderr, "\t%s chan <ifname> <channel>\n", progname);
|
||||
fprintf(stderr, "\t%s devmode <ifname> <devmode>\n", progname);
|
||||
fprintf(stderr, "\t%s eaddr <ifname> <eaddr>\n", progname);
|
||||
fprintf(stderr, "\t%s panid <ifname> <panid>\n", progname);
|
||||
fprintf(stderr, "\t%s promisc <ifname> <true|false>\n", progname);
|
||||
fprintf(stderr, "\t%s saddr <ifname> <saddr>\n", progname);
|
||||
fprintf(stderr, "\t%s txpwr <ifname> <txpwr>\n", progname);
|
||||
fprintf(stderr, "\nMAC Commands:\n");
|
||||
fprintf(stderr, "\t%s assoc <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s disassoc <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s get <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s gts <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s poll <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s rxenab <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s scan <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s set <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s start <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\t%s sync <ifname> TBD\n", progname);
|
||||
fprintf(stderr, "\nWhere:\n");
|
||||
fprintf(stderr, "\t<eaddr> must be entered as xx:xx:xx:xx:xx:xx:xx\n");
|
||||
exit(exitcode);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int iwpan_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
FAR const char *cmdname;
|
||||
FAR const struct iwpan_command_s *iwpancmd;
|
||||
int sock;
|
||||
int i;
|
||||
|
||||
/* Get the command */
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing command\n");
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cmdname = argv[1];
|
||||
|
||||
/* Find the command in the g_iwpan_command[] list */
|
||||
|
||||
iwpancmd = NULL;
|
||||
for (i = 0; i < NCOMMANDS; i++)
|
||||
{
|
||||
FAR const struct iwpan_command_s *cmd = &g_iwpan_commands[i];
|
||||
if (strcmp(cmdname, cmd->name) == 0)
|
||||
{
|
||||
iwpancmd = cmd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (iwpancmd == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unsupported command: %s\n", cmdname);
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (iwpancmd->noptions + 2 < argc)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Garbage at end of command ignored\n");
|
||||
}
|
||||
else if (iwpancmd->noptions + 2 > argc)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing required command options: %s\n",
|
||||
cmdname);
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Special case the help command which has no arguments, no handler,
|
||||
* and does not need a socket.
|
||||
*/
|
||||
|
||||
if (iwpancmd->handler == NULL)
|
||||
{
|
||||
iwpan_showusage(argv[0], EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Create a communication socket */
|
||||
|
||||
sock = socket(PF_INETX, SOCK_IWPAN, 0);
|
||||
if (sock < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: iwpan_make_socket() failed: %d\n", sock);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Dispatch the command handling */
|
||||
|
||||
switch (iwpancmd->noptions)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
fprintf(stderr, "ERROR: Internal craziness\n");
|
||||
iwpan_showusage(argv[0], EXIT_FAILURE);
|
||||
|
||||
case 1:
|
||||
((cmd1_t)iwpancmd->handler)(sock, argv[2]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
((cmd2_t)iwpancmd->handler)(sock, argv[2], argv[3]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
((cmd3_t)iwpancmd->handler)(sock, argv[2], argv[3], argv[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Close communication socket */
|
||||
|
||||
close(sock);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
|
||||
menuconfig WIRELESS_WAPI
|
||||
bool "IEEE802.11 Configuration Library"
|
||||
bool "IEEE 802.11 Configuration Library"
|
||||
default n
|
||||
depends on NET && DRIVERS_WIRELESS && EXPERIMENTAL
|
||||
---help---
|
||||
@ -14,7 +14,7 @@ menuconfig WIRELESS_WAPI
|
||||
if WIRELESS_WAPI
|
||||
|
||||
config WIRELESS_WAPI_CMDTOOL
|
||||
bool "IEEE802.11 Command Line Tool"
|
||||
bool "IEEE 802.11 Command Line Tool"
|
||||
default n
|
||||
---help---
|
||||
By default, Wapi is build as only a library. If this option is
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/wapi/examples/network.c
|
||||
*
|
||||
* Copyright (C) 2011, 2017Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Adapted for Nuttx from WAPI:
|
||||
|
@ -62,7 +62,7 @@ struct wapi_command_s
|
||||
CODE void *handler;
|
||||
};
|
||||
|
||||
/* Generic form of a commnd handler */
|
||||
/* Generic form of a command handler */
|
||||
|
||||
typedef void (*cmd1_t)(int sock, FAR const char *arg1);
|
||||
typedef void (*cmd2_t)(int sock, FAR const char *arg1,
|
||||
|
Loading…
Reference in New Issue
Block a user