Merge branch 'master' of https://bitbucket.org/nuttx/apps into ieee802154
This commit is contained in:
commit
42a2aff968
@ -11,6 +11,22 @@ config EXAMPLES_HIDKBD
|
|||||||
|
|
||||||
if EXAMPLES_HIDKBD
|
if EXAMPLES_HIDKBD
|
||||||
|
|
||||||
|
config EXAMPLES_HIDKBD_PROGNAME
|
||||||
|
string "Program name"
|
||||||
|
default "hidkbd"
|
||||||
|
depends on BUILD_KERNEL
|
||||||
|
---help---
|
||||||
|
This is the name of the program that will be use when the Nettest
|
||||||
|
program is installed.
|
||||||
|
|
||||||
|
config EXAMPLES_HIDKBD_STACKSIZE
|
||||||
|
int "Task stack size"
|
||||||
|
default 2048
|
||||||
|
|
||||||
|
config EXAMPLES_HIDKBD_DEFPRIO
|
||||||
|
int "Task priority"
|
||||||
|
default 100
|
||||||
|
|
||||||
config EXAMPLES_HIDKBD_DEVNAME
|
config EXAMPLES_HIDKBD_DEVNAME
|
||||||
string "Keyboard Device Name"
|
string "Keyboard Device Name"
|
||||||
default "/dev/kbda"
|
default "/dev/kbda"
|
||||||
|
@ -37,11 +37,11 @@
|
|||||||
|
|
||||||
# USB Host HID keyboard Example
|
# USB Host HID keyboard Example
|
||||||
|
|
||||||
CONFIG_EXAMPLES_HIDKBD_PRIORITY ?= SCHED_PRIORITY_DEFAULT
|
CONFIG_EXAMPLES_HIDKBD_DEFPRIO ?= 100
|
||||||
CONFIG_EXAMPLES_HIDKBD_STACKSIZE ?= 2048
|
CONFIG_EXAMPLES_HIDKBD_STACKSIZE ?= 2048
|
||||||
|
|
||||||
APPNAME = hidkbd
|
APPNAME = hidkbd
|
||||||
PRIORITY = $(CONFIG_EXAMPLES_HIDKBD_PRIORITY)
|
PRIORITY = $(CONFIG_EXAMPLES_HIDKBD_DEFPRIO)
|
||||||
STACKSIZE = $(CONFIG_EXAMPLES_HIDKBD_STACKSIZE)
|
STACKSIZE = $(CONFIG_EXAMPLES_HIDKBD_STACKSIZE)
|
||||||
|
|
||||||
# Hello, World! Example
|
# Hello, World! Example
|
||||||
|
@ -60,16 +60,20 @@ static void cleanup(FAR void * data)
|
|||||||
FAR struct sync_s *sync = (FAR struct sync_s *) data;
|
FAR struct sync_s *sync = (FAR struct sync_s *) data;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
/* Note: pthread_cond_wait() will release the mutex while it waits on
|
/* Note: The behavior of canceling pthread_cond_wait() with asynchronous
|
||||||
* condition value. So a EPERM error is not a failure.
|
* cancellation is not defined. On NuttX we get EPERM here, but application
|
||||||
|
* code must not rely on this.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status = pthread_mutex_unlock(&sync->lock);
|
status = pthread_mutex_unlock(&sync->lock);
|
||||||
|
#ifndef CONFIG_CANCELLATION_POINTS
|
||||||
if (status == EPERM)
|
if (status == EPERM)
|
||||||
{
|
{
|
||||||
printf("pthread_cleanup: thread did not have mutex locked: %d\n", status);
|
printf("pthread_cleanup: thread did not have mutex locked: %d\n", status);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (status != 0)
|
#endif
|
||||||
|
if (status != 0)
|
||||||
{
|
{
|
||||||
printf("pthread_cleanup: ERROR pthread_mutex_unlock in cleanup handler. "
|
printf("pthread_cleanup: ERROR pthread_mutex_unlock in cleanup handler. "
|
||||||
"Status: %d\n", status);
|
"Status: %d\n", status);
|
||||||
@ -138,6 +142,7 @@ static void test_cleanup(void)
|
|||||||
printf("pthread_cleanup: ERROR pthread_join returned wrong result: %p\n", result);
|
printf("pthread_cleanup: ERROR pthread_join returned wrong result: %p\n", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_CANCELLATION_POINTS
|
||||||
/* Do some operations on lock in order to check if it is in usable state. */
|
/* Do some operations on lock in order to check if it is in usable state. */
|
||||||
|
|
||||||
status = pthread_mutex_trylock(&sync.lock);
|
status = pthread_mutex_trylock(&sync.lock);
|
||||||
@ -151,6 +156,7 @@ static void test_cleanup(void)
|
|||||||
{
|
{
|
||||||
printf("pthread_cleanup: ERROR pthread_mutex_unlock, status=%d\n", status);
|
printf("pthread_cleanup: ERROR pthread_mutex_unlock, status=%d\n", status);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
APPNAME = rand
|
APPNAME = rand
|
||||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||||
STACKSIZE = 1024
|
STACKSIZE = 2048
|
||||||
|
|
||||||
ASRCS =
|
ASRCS =
|
||||||
CSRCS =
|
CSRCS =
|
||||||
|
@ -92,12 +92,16 @@ int rand_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
nsamples = atoi(argv[1]);
|
nsamples = atoi(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clip the number of samples to the configured buffer size */
|
/* Clip the number of samples to the configured buffer size */
|
||||||
|
|
||||||
if (nsamples > CONFIG_EXAMPLES_MAXSAMPLES)
|
if (nsamples < 0)
|
||||||
|
{
|
||||||
|
nsamples = 0;
|
||||||
|
}
|
||||||
|
else if (nsamples > CONFIG_EXAMPLES_MAXSAMPLES)
|
||||||
{
|
{
|
||||||
nsamples = CONFIG_EXAMPLES_MAXSAMPLES;
|
nsamples = CONFIG_EXAMPLES_MAXSAMPLES;
|
||||||
}
|
}
|
||||||
@ -124,14 +128,14 @@ int rand_main(int argc, char *argv[])
|
|||||||
if (nread < 0)
|
if (nread < 0)
|
||||||
{
|
{
|
||||||
int errcode = errno;
|
int errcode = errno;
|
||||||
fprintf(stderr, "ERROR: Read from /dev/randon failed: %d\n", errcode);
|
fprintf(stderr, "ERROR: Read from /dev/random failed: %d\n", errcode);
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nread != nsamples * sizeof(uint32_t))
|
if (nread != nsamples * sizeof(uint32_t))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: Read from /dev/randon only produced %d bytes\n",
|
fprintf(stderr, "ERROR: Read from /dev/random only produced %d bytes\n",
|
||||||
(int)nread);
|
(int)nread);
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -117,7 +117,9 @@ int netlib_getmacaddr(FAR const char *ifname, FAR uint8_t *macaddr);
|
|||||||
#ifdef CONFIG_NET_6LOWPAN
|
#ifdef CONFIG_NET_6LOWPAN
|
||||||
/* Get IEEE802.15.4 MAC driver node address */
|
/* Get IEEE802.15.4 MAC driver node address */
|
||||||
|
|
||||||
|
int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid);
|
||||||
int netlib_setnodeaddr(FAR const char *ifname, FAR const uint8_t *nodeaddr);
|
int netlib_setnodeaddr(FAR const char *ifname, FAR const uint8_t *nodeaddr);
|
||||||
|
int netlib_setpanid(FAR const char *ifname, uint16_t panid);
|
||||||
bool netlib_nodeaddrconv(FAR const char *hwstr, FAR uint8_t *hw);
|
bool netlib_nodeaddrconv(FAR const char *hwstr, FAR uint8_t *hw);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -87,7 +87,8 @@ CSRCS += netlib_setmacaddr.c netlib_getmacaddr.c
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
||||||
CSRCS += netlib_setnodeaddr.c netlib_nodeaddrconv.c
|
CSRCS += netlib_getpanid.c netlib_setnodeaddr.c netlib_setpanid.c
|
||||||
|
CSRCS += netlib_nodeaddrconv.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# IGMP support
|
# IGMP support
|
||||||
|
@ -108,7 +108,7 @@ int netlib_getessid(FAR const char *ifname, FAR char *essid, size_t idlen)
|
|||||||
/* Put the driver name into the request */
|
/* Put the driver name into the request */
|
||||||
|
|
||||||
memset(&req, 0, sizeof(struct iwreq));
|
memset(&req, 0, sizeof(struct iwreq));
|
||||||
strncpy(req.ifrn_name, ifname, IFNAMSIZ);
|
strncpy(req.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
|
||||||
/* Put pointer to receive the ESSID into the request */
|
/* Put pointer to receive the ESSID into the request */
|
||||||
|
|
||||||
|
96
netutils/netlib/netlib_getpanid.c
Normal file
96
netutils/netlib/netlib_getpanid.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* netutils/netlib/netlib_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/socket.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "netutils/netlib.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: netlib_getpanid
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the current PAN ID
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* ifname The name of the interface to use
|
||||||
|
* panid The location to return the current PAN ID
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* 0 on success; -1 on failure. errno will be set on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid)
|
||||||
|
{
|
||||||
|
int ret = ERROR;
|
||||||
|
|
||||||
|
if (ifname != NULL && panid != NULL)
|
||||||
|
{
|
||||||
|
/* Get a socket (only so that we get access to the INET subsystem) */
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
close(sockfd);
|
||||||
|
|
||||||
|
/* Reuturn the current PAN ID */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
|
@ -106,7 +106,7 @@ int netlib_setessid(FAR const char *ifname, FAR const char *essid)
|
|||||||
|
|
||||||
/* Put the driver name into the request */
|
/* Put the driver name into the request */
|
||||||
|
|
||||||
strncpy(req.ifrn_name, ifname, IFNAMSIZ);
|
strncpy(req.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
|
||||||
/* Put the new ESSID into the request */
|
/* Put the new ESSID into the request */
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ int netlib_setnodeaddr(FAR const char *ifname, FAR const uint8_t *nodeaddr)
|
|||||||
req.ifr_hwaddr.sa_family = AF_INET6;
|
req.ifr_hwaddr.sa_family = AF_INET6;
|
||||||
memcpy(&req.ifr_hwaddr.sa_data, nodeaddr, NET_6LOWPAN_RIMEADDR_SIZE);
|
memcpy(&req.ifr_hwaddr.sa_data, nodeaddr, NET_6LOWPAN_RIMEADDR_SIZE);
|
||||||
|
|
||||||
/* Perform the ioctl to set the MAC address */
|
/* Perform the ioctl to set the node address */
|
||||||
|
|
||||||
ret = ioctl(sockfd, SIOCSIFHWADDR, (unsigned long)&req);
|
ret = ioctl(sockfd, SIOCSIFHWADDR, (unsigned long)&req);
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
|
96
netutils/netlib/netlib_setpanid.c
Normal file
96
netutils/netlib/netlib_setpanid.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* netutils/netlib/netlib_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/socket.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "netutils/netlib.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_6LOWPAN) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: netlib_setpanid
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Join the specified PAN ID
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* ifname The name of the interface to use
|
||||||
|
* panid The PAN ID to join
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* 0 on success; -1 on failure. errno will be set on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int netlib_setpanid(FAR const char *ifname, uint16_t panid)
|
||||||
|
{
|
||||||
|
int ret = ERROR;
|
||||||
|
|
||||||
|
if (ifname != NULL)
|
||||||
|
{
|
||||||
|
/* Get a socket (only so that we get access to the INET subsystem) */
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
close(sockfd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NSOCKET_DESCRIPTORS */
|
@ -1456,6 +1456,15 @@ config NSH_MACADDR
|
|||||||
MAC address must provided with this selection.
|
MAC address must provided with this selection.
|
||||||
|
|
||||||
endif # NSH_NOMAC
|
endif # NSH_NOMAC
|
||||||
|
|
||||||
|
config NSH_PANID
|
||||||
|
hex "6loWPAN PAN ID"
|
||||||
|
default 0xface
|
||||||
|
depends on NET_6LOWPAN
|
||||||
|
range 0x0000 0xffff
|
||||||
|
---help---
|
||||||
|
Select the PAN ID to join upon initialization.
|
||||||
|
|
||||||
endif # NSH_NETINIT
|
endif # NSH_NETINIT
|
||||||
|
|
||||||
config NSH_MAX_ROUNDTRIP
|
config NSH_MAX_ROUNDTRIP
|
||||||
|
@ -314,9 +314,9 @@ static int cmd_codecs_proc(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv,
|
|||||||
|
|
||||||
fullpath = nsh_getfullpath(vtbl, localfile);
|
fullpath = nsh_getfullpath(vtbl, localfile);
|
||||||
|
|
||||||
/* Open the local file for writing */
|
/* Open the local file for reading */
|
||||||
|
|
||||||
fd = open(fullpath, O_RDONLY|O_TRUNC, 0644);
|
fd = open(fullpath, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||||
|
@ -83,19 +83,16 @@
|
|||||||
#include <nuttx/net/sixlowpan.h>
|
#include <nuttx/net/sixlowpan.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \
|
#ifdef CONFIG_NETUTILS_NETLIB
|
||||||
!defined(CONFIG_DISABLE_SIGNALS)
|
|
||||||
# include "netutils/netlib.h"
|
# include "netutils/netlib.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0
|
#if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
# include "netutils/netlib.h"
|
# include "netutils/netlib.h"
|
||||||
# include "netutils/tftp.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP) && CONFIG_NFILE_DESCRIPTORS > 0
|
#if defined(CONFIG_NET_TCP) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
# ifndef CONFIG_NSH_DISABLE_WGET
|
# ifndef CONFIG_NSH_DISABLE_WGET
|
||||||
# include "netutils/netlib.h"
|
|
||||||
# include "netutils/webclient.h"
|
# include "netutils/webclient.h"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -295,8 +295,11 @@ static void nsh_netinit_configure(void)
|
|||||||
|
|
||||||
/* Set the 6loWPAN node address */
|
/* Set the 6loWPAN node address */
|
||||||
|
|
||||||
netlib_setnodeaddr(NET_DEVNAME, nodeaddr);
|
(void)netlib_setnodeaddr(NET_DEVNAME, nodeaddr);
|
||||||
|
|
||||||
|
/* Set the 6loWPAN PAN ID */
|
||||||
|
|
||||||
|
(void)netlib_setpanid(NET_DEVNAME, CONFIG_NSH_PANID);
|
||||||
#endif /* CONFIG_NET_ETHERNET */
|
#endif /* CONFIG_NET_ETHERNET */
|
||||||
#endif /* CONFIG_NSH_NOMAC && HAVE_MAC */
|
#endif /* CONFIG_NSH_NOMAC && HAVE_MAC */
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ CSRCS =
|
|||||||
MAINSRC =
|
MAINSRC =
|
||||||
|
|
||||||
VPATH = .
|
VPATH = .
|
||||||
|
DEPPATH = --dep-path .
|
||||||
|
|
||||||
include $(APPDIR)/wireless/wapi/src/Make.defs
|
include $(APPDIR)/wireless/wapi/src/Make.defs
|
||||||
|
|
||||||
@ -87,8 +88,6 @@ endif
|
|||||||
CONFIG_WAPI_PROGNAME ?= wapi$(EXEEXT)
|
CONFIG_WAPI_PROGNAME ?= wapi$(EXEEXT)
|
||||||
PROGNAME = $(CONFIG_WAPI_PROGNAME)
|
PROGNAME = $(CONFIG_WAPI_PROGNAME)
|
||||||
|
|
||||||
ROOTDEPPATH = --dep-path .
|
|
||||||
|
|
||||||
# Common build
|
# Common build
|
||||||
|
|
||||||
all: .built
|
all: .built
|
||||||
@ -131,7 +130,7 @@ endif
|
|||||||
# Create dependencies
|
# Create dependencies
|
||||||
|
|
||||||
.depend: Makefile $(SRCS)
|
.depend: Makefile $(SRCS)
|
||||||
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
$(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||||
$(Q) touch $@
|
$(Q) touch $@
|
||||||
|
|
||||||
depend: .depend
|
depend: .depend
|
||||||
|
@ -71,7 +71,9 @@ static int wapi_get_addr(int sock, FAR const char *ifname, int cmd,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(cmd);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(cmd, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -92,7 +94,9 @@ static int wapi_set_addr(int sock, FAR const char *ifname, int cmd,
|
|||||||
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, cmd, (unsigned long)((uintptr_t)&ifr))) < 0)
|
if ((ret = ioctl(sock, cmd, (unsigned long)((uintptr_t)&ifr))) < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(cmd);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(cmd, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -141,7 +145,9 @@ static int wapi_act_route_gw(int sock, int act,
|
|||||||
|
|
||||||
if ((ret = ioctl(sock, act, (unsigned long)((uintptr_t)&rt))) < 0)
|
if ((ret = ioctl(sock, act, (unsigned long)((uintptr_t)&rt))) < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(act);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(act, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -177,7 +183,9 @@ int wapi_get_ifup(int sock, FAR const char *ifname, FAR int *is_up)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIFFLAGS);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIFFLAGS, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -201,10 +209,18 @@ int wapi_set_ifup(int sock, FAR const char *ifname)
|
|||||||
{
|
{
|
||||||
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
|
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
|
||||||
ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr));
|
ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIFFLAGS, errcode);
|
||||||
|
ret = -errcode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIFFLAGS);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIFFLAGS, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -228,10 +244,18 @@ int wapi_set_ifdown(int sock, FAR const char *ifname)
|
|||||||
{
|
{
|
||||||
ifr.ifr_flags &= ~IFF_UP;
|
ifr.ifr_flags &= ~IFF_UP;
|
||||||
ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr));
|
ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIFFLAGS, errcode);
|
||||||
|
ret = -errcode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIFFLAGS);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIFFLAGS, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -47,29 +47,74 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define WAPI_IOCTL_STRERROR(cmd) \
|
#ifdef DEBUG_WIRELESS_ERROR
|
||||||
fprintf( \
|
# ifdef CONFIG_LIBC_STRERROR
|
||||||
stderr, "%s:%d:%s():ioctl(%s): %s\n", \
|
# define WAPI_IOCTL_STRERROR(cmd,errcode) \
|
||||||
__FILE__, __LINE__, __func__, \
|
fprintf( \
|
||||||
wapi_ioctl_command_name(cmd), strerror(errno))
|
stderr, "%s:%d:%s():ioctl(%s): %s\n", \
|
||||||
|
__FILE__, __LINE__, __func__, \
|
||||||
|
wapi_ioctl_command_name(cmd), strerror(errcode))
|
||||||
|
|
||||||
#define WAPI_STRERROR(fmt, ...) \
|
# define WAPI_STRERROR(fmt, ...) \
|
||||||
fprintf( \
|
fprintf( \
|
||||||
stderr, "%s:%d:%s():" fmt ": %s\n", \
|
stderr, "%s:%d:%s():" fmt ": %s\n", \
|
||||||
__FILE__, __LINE__, __func__, \
|
__FILE__, __LINE__, __func__, \
|
||||||
## __VA_ARGS__, strerror(errno))
|
## __VA_ARGS__, strerror(errno))
|
||||||
|
# else
|
||||||
|
# define WAPI_IOCTL_STRERROR(cmd,errcode) \
|
||||||
|
fprintf( \
|
||||||
|
stderr, "%s:%d:%s():ioctl(%s): %d\n", \
|
||||||
|
__FILE__, __LINE__, __func__, \
|
||||||
|
wapi_ioctl_command_name(cmd), errcode)
|
||||||
|
|
||||||
#define WAPI_ERROR(fmt, ...) \
|
# define WAPI_STRERROR(fmt, ...) \
|
||||||
fprintf( \
|
fprintf( \
|
||||||
stderr, "%s:%d:%s(): " fmt , \
|
stderr, "%s:%d:%s():" fmt ": %d\n", \
|
||||||
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
|
__FILE__, __LINE__, __func__, \
|
||||||
|
## __VA_ARGS__, errno)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define WAPI_ERROR(fmt, ...) \
|
||||||
|
fprintf( \
|
||||||
|
stderr, "%s:%d:%s(): " fmt , \
|
||||||
|
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
|
||||||
|
|
||||||
|
#else
|
||||||
|
# ifdef CONFIG_LIBC_STRERROR
|
||||||
|
# define WAPI_IOCTL_STRERROR(cmd,errcode) \
|
||||||
|
fprintf( \
|
||||||
|
stderr, "ioctl(%s): %s\n", \
|
||||||
|
wapi_ioctl_command_name(cmd), strerror(errcode))
|
||||||
|
|
||||||
|
# define WAPI_STRERROR(fmt, ...) \
|
||||||
|
fprintf( \
|
||||||
|
stderr, fmt ": %s\n", \
|
||||||
|
## __VA_ARGS__, strerror(errno))
|
||||||
|
# else
|
||||||
|
# define WAPI_IOCTL_STRERROR(cmd,errcode) \
|
||||||
|
fprintf( \
|
||||||
|
stderr, "ioctl(%s): %d\n", \
|
||||||
|
wapi_ioctl_command_name(cmd), errcode)
|
||||||
|
|
||||||
|
# define WAPI_STRERROR(fmt, ...) \
|
||||||
|
fprintf( \
|
||||||
|
stderr, fmt ": %d\n", \
|
||||||
|
## __VA_ARGS__, errno)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define WAPI_ERROR(fmt, ...) \
|
||||||
|
fprintf( \
|
||||||
|
stderr, fmt , \
|
||||||
|
## __VA_ARGS__)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define WAPI_VALIDATE_PTR(ptr) \
|
#define WAPI_VALIDATE_PTR(ptr) \
|
||||||
if (!ptr) \
|
if (ptr == NULL) \
|
||||||
{ \
|
{ \
|
||||||
WAPI_ERROR("Null pointer: %s.\n", #ptr); \
|
WAPI_ERROR("Null pointer: %p\n", ptr); \
|
||||||
return -1; \
|
return -EINVAL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
|
@ -76,6 +76,8 @@ typedef void (*cmd3_t)(int sock, FAR const char *arg1,
|
|||||||
|
|
||||||
static int wapi_str2int(FAR const char *str);
|
static int wapi_str2int(FAR const char *str);
|
||||||
static double wapi_str2double(FAR const char *str);
|
static double wapi_str2double(FAR const char *str);
|
||||||
|
static unsigned int wapi_str2ndx(FAR const char *name, FAR const char **list,
|
||||||
|
unsigned int listlen);
|
||||||
|
|
||||||
static void wapi_show_cmd(int sock, FAR const char *ifname);
|
static void wapi_show_cmd(int sock, FAR const char *ifname);
|
||||||
static void wapi_ip_cmd(int sock, FAR const char *ifname,
|
static void wapi_ip_cmd(int sock, FAR const char *ifname,
|
||||||
@ -114,7 +116,7 @@ static const struct wapi_command_s g_wapi_commands[] =
|
|||||||
{"mode", 2, (CODE void *)wapi_mode_cmd},
|
{"mode", 2, (CODE void *)wapi_mode_cmd},
|
||||||
{"ap", 2, (CODE void *)wapi_ap_cmd},
|
{"ap", 2, (CODE void *)wapi_ap_cmd},
|
||||||
{"bitrate", 3, (CODE void *)wapi_bitrate_cmd},
|
{"bitrate", 3, (CODE void *)wapi_bitrate_cmd},
|
||||||
{"txpower", 2, (CODE void *)wapi_txpower_cmd},
|
{"txpower", 3, (CODE void *)wapi_txpower_cmd},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NCOMMANDS (sizeof(g_wapi_commands) / sizeof(struct wapi_command_s))
|
#define NCOMMANDS (sizeof(g_wapi_commands) / sizeof(struct wapi_command_s))
|
||||||
@ -175,6 +177,37 @@ static double wapi_str2double(FAR const char *str)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: wapi_str2ndx
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the index of a string in a list of strings
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static unsigned int wapi_str2ndx(FAR const char *name, FAR const char **list,
|
||||||
|
unsigned int listlen)
|
||||||
|
{
|
||||||
|
unsigned int ndx;
|
||||||
|
|
||||||
|
for (ndx = 0; ndx < listlen; ndx++)
|
||||||
|
{
|
||||||
|
if (strcmp(name, list[ndx]) == 0)
|
||||||
|
{
|
||||||
|
return ndx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WAPI_ERROR("ERROR: Invalid option string: %s\n", name);
|
||||||
|
WAPI_ERROR(" Valid options include:\n");
|
||||||
|
for (ndx = 0; ndx < listlen; ndx++)
|
||||||
|
{
|
||||||
|
WAPI_ERROR(" - %s\n", list[ndx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: wapi_show_cmd
|
* Name: wapi_show_cmd
|
||||||
*
|
*
|
||||||
@ -236,7 +269,7 @@ static void wapi_show_cmd(int sock, FAR const char *ifname)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" NetMask: %s", inet_ntoa(addr));
|
printf(" NetMask: %s\n", inet_ntoa(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get frequency */
|
/* Get frequency */
|
||||||
@ -418,29 +451,13 @@ static void wapi_freq_cmd(int sock, FAR const char *ifname,
|
|||||||
{
|
{
|
||||||
double frequency;
|
double frequency;
|
||||||
wapi_freq_flag_t freq_flag;
|
wapi_freq_flag_t freq_flag;
|
||||||
bool found = false;
|
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Convert input strings to values */
|
/* Convert input strings to values */
|
||||||
|
|
||||||
frequency = wapi_str2double(freqstr);
|
frequency = wapi_str2double(freqstr);
|
||||||
|
freq_flag = (wapi_freq_flag_t)wapi_str2ndx(flagstr, g_wapi_freq_flags,
|
||||||
for (i = 0; i < IW_FREQ_NFLAGS; i++)
|
IW_FREQ_NFLAGS);
|
||||||
{
|
|
||||||
if (strcmp(flagstr, g_wapi_freq_flags[i]) == 0)
|
|
||||||
{
|
|
||||||
freq_flag = (wapi_freq_flag_t)i;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
WAPI_ERROR("ERROR: Invalid frequency flag: %s\n", flagstr);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the frequency */
|
/* Set the frequency */
|
||||||
|
|
||||||
@ -466,27 +483,11 @@ static void wapi_essid_cmd(int sock, FAR const char *ifname,
|
|||||||
FAR const char *essid, FAR const char *flagstr)
|
FAR const char *essid, FAR const char *flagstr)
|
||||||
{
|
{
|
||||||
wapi_essid_flag_t essid_flag;
|
wapi_essid_flag_t essid_flag;
|
||||||
bool found = false;
|
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Convert input strings to values */
|
/* Convert input strings to values */
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
essid_flag = (wapi_essid_flag_t)wapi_str2ndx(flagstr, g_wapi_essid_flags, 2);
|
||||||
{
|
|
||||||
if (strcmp(flagstr, g_wapi_essid_flags[i]) == 0)
|
|
||||||
{
|
|
||||||
essid_flag = (wapi_essid_flag_t)i;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
WAPI_ERROR("ERROR: Invalid ESSID flag: %s\n", flagstr);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the ESSID */
|
/* Set the ESSID */
|
||||||
|
|
||||||
@ -512,27 +513,11 @@ static void wapi_mode_cmd(int sock, FAR const char *ifname,
|
|||||||
FAR const char *modestr)
|
FAR const char *modestr)
|
||||||
{
|
{
|
||||||
wapi_mode_t mode;
|
wapi_mode_t mode;
|
||||||
bool found = false;
|
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Convert input strings to values */
|
/* Convert input strings to values */
|
||||||
|
|
||||||
for (i = 0; i < IW_MODE_NFLAGS; i++)
|
mode = (wapi_mode_t)wapi_str2ndx(modestr, g_wapi_modes, IW_MODE_NFLAGS);
|
||||||
{
|
|
||||||
if (strcmp(modestr, g_wapi_modes[i]) == 0)
|
|
||||||
{
|
|
||||||
mode = (wapi_mode_t)i;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
WAPI_ERROR("ERROR: Invalid operating mode: %s\n", modestr);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set operating mode */
|
/* Set operating mode */
|
||||||
|
|
||||||
@ -592,30 +577,14 @@ static void wapi_bitrate_cmd(int sock, FAR const char *ifname,
|
|||||||
|
|
||||||
{
|
{
|
||||||
wapi_bitrate_flag_t bitrate_flag;
|
wapi_bitrate_flag_t bitrate_flag;
|
||||||
bool found = false;
|
|
||||||
int bitrate;
|
int bitrate;
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Convert input strings to values */
|
/* Convert input strings to values */
|
||||||
|
|
||||||
bitrate = wapi_str2int(ratestr);
|
bitrate = wapi_str2int(ratestr);
|
||||||
|
bitrate_flag = (wapi_bitrate_flag_t)
|
||||||
for (i = 0; i < 2; i++)
|
wapi_str2ndx(flagstr, g_wapi_bitrate_flags, 2);
|
||||||
{
|
|
||||||
if (strcmp(flagstr, g_wapi_bitrate_flags[i]) == 0)
|
|
||||||
{
|
|
||||||
bitrate_flag = (wapi_bitrate_flag_t)i;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
WAPI_ERROR("ERROR: Invalid bitrate flag: %s\n", flagstr);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set bitrate */
|
/* Set bitrate */
|
||||||
|
|
||||||
@ -641,30 +610,14 @@ static void wapi_txpower_cmd(int sock, FAR const char *ifname,
|
|||||||
FAR const char *pwrstr, FAR const char *flagstr)
|
FAR const char *pwrstr, FAR const char *flagstr)
|
||||||
{
|
{
|
||||||
wapi_txpower_flag_t txpower_flag;
|
wapi_txpower_flag_t txpower_flag;
|
||||||
bool found = false;
|
|
||||||
int txpower;
|
int txpower;
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Convert input strings to values */
|
/* Convert input strings to values */
|
||||||
|
|
||||||
txpower = wapi_str2int(pwrstr);
|
txpower = wapi_str2int(pwrstr);
|
||||||
|
txpower_flag = (wapi_txpower_flag_t)
|
||||||
for (i = 0; i < IW_TXPOW_NFLAGS; i++)
|
wapi_str2ndx(flagstr, g_wapi_txpower_flags, IW_TXPOW_NFLAGS);
|
||||||
{
|
|
||||||
if (strcmp(flagstr, g_wapi_txpower_flags[i]) == 0)
|
|
||||||
{
|
|
||||||
txpower_flag = (wapi_txpower_flag_t)i;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
WAPI_ERROR("ERROR: Invalid TX power flag: %s\n", flagstr);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set txpower */
|
/* Set txpower */
|
||||||
|
|
||||||
@ -728,7 +681,7 @@ static void wapi_scan_cmd(int sock, FAR const char *ifname)
|
|||||||
|
|
||||||
for (info = list.head.scan; info; info = info->next)
|
for (info = list.head.scan; info; info = info->next)
|
||||||
{
|
{
|
||||||
printf(">> %02x:%02x:%02x:%02x:%02x:%02x %s\n",
|
printf(" %02x:%02x:%02x:%02x:%02x:%02x %s\n",
|
||||||
info->ap.ether_addr_octet[0], info->ap.ether_addr_octet[1],
|
info->ap.ether_addr_octet[0], info->ap.ether_addr_octet[1],
|
||||||
info->ap.ether_addr_octet[2], info->ap.ether_addr_octet[3],
|
info->ap.ether_addr_octet[2], info->ap.ether_addr_octet[3],
|
||||||
info->ap.ether_addr_octet[4], info->ap.ether_addr_octet[5],
|
info->ap.ether_addr_octet[4], info->ap.ether_addr_octet[5],
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/net/arp.h>
|
#include <nuttx/net/arp.h>
|
||||||
#include <nuttx/wireless/wireless.h>
|
#include <nuttx/wireless/wireless.h>
|
||||||
@ -341,7 +342,14 @@ int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq,
|
|||||||
WAPI_VALIDATE_PTR(flag);
|
WAPI_VALIDATE_PTR(flag);
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWFREQ, (unsigned long)((uintptr_t)&wrq))) >= 0)
|
ret = ioctl(sock, SIOCGIWFREQ, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWFREQ, errcode);
|
||||||
|
ret = -errcode;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* Set flag. */
|
/* Set flag. */
|
||||||
|
|
||||||
@ -402,7 +410,9 @@ int wapi_set_freq(int sock, FAR const char *ifname, double freq,
|
|||||||
ret = ioctl(sock, SIOCSIWFREQ, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCSIWFREQ, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCSIWFREQ);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIWFREQ, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -462,7 +472,9 @@ int wapi_freq2chan(int sock, FAR const char *ifname, double freq,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWRANGE);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWRANGE, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -518,7 +530,9 @@ int wapi_chan2freq(int sock, FAR const char *ifname, int chan,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWRANGE);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWRANGE, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -553,7 +567,9 @@ int wapi_get_essid(int sock, FAR const char *ifname, FAR char *essid,
|
|||||||
ret = ioctl(sock, SIOCGIWESSID, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCGIWESSID, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWESSID);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWESSID, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -591,7 +607,9 @@ int wapi_set_essid(int sock, FAR const char *ifname, FAR const char *essid,
|
|||||||
ret = ioctl(sock, SIOCSIWESSID, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCSIWESSID, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCSIWESSID);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIWESSID, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -619,7 +637,9 @@ int wapi_get_mode(int sock, FAR const char *ifname, FAR wapi_mode_t *mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWMODE);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWMODE, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -644,7 +664,9 @@ int wapi_set_mode(int sock, FAR const char *ifname, wapi_mode_t mode)
|
|||||||
ret = ioctl(sock, SIOCSIWMODE, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCSIWMODE, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCSIWMODE);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIWMODE, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -702,7 +724,9 @@ int wapi_get_ap(int sock, FAR const char *ifname, FAR struct ether_addr *ap)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWAP);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWAP, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -731,7 +755,9 @@ int wapi_set_ap(int sock, FAR const char *ifname,
|
|||||||
ret = ioctl(sock, SIOCSIWAP, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCSIWAP, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCSIWAP);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIWAP, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -772,7 +798,9 @@ int wapi_get_bitrate(int sock, FAR const char *ifname,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWRATE);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWRATE, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -799,7 +827,9 @@ int wapi_set_bitrate(int sock, FAR const char *ifname, int bitrate,
|
|||||||
ret = ioctl(sock, SIOCSIWRATE, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCSIWRATE, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCSIWRATE);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIWRATE, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -884,7 +914,9 @@ int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWTXPOW);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWTXPOW, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -928,7 +960,9 @@ int wapi_set_txpower(int sock, FAR const char *ifname, int power,
|
|||||||
ret = ioctl(sock, SIOCSIWTXPOW, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCSIWTXPOW, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCSIWTXPOW);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIWTXPOW, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -956,7 +990,9 @@ int wapi_scan_init(int sock, const char *ifname)
|
|||||||
ret = ioctl(sock, SIOCSIWSCAN, (unsigned long)((uintptr_t)&wrq));
|
ret = ioctl(sock, SIOCSIWSCAN, (unsigned long)((uintptr_t)&wrq));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCSIWSCAN);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCSIWSCAN, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1003,7 +1039,9 @@ int wapi_scan_stat(int sock, FAR const char *ifname)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWSCAN);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWSCAN, errcode);
|
||||||
|
ret = -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1069,9 +1107,10 @@ alloc:
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
WAPI_IOCTL_STRERROR(SIOCGIWSCAN);
|
int errcode = errno;
|
||||||
|
WAPI_IOCTL_STRERROR(SIOCGIWSCAN, errcode);
|
||||||
free(buf);
|
free(buf);
|
||||||
return ret;
|
return -errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have the results, process them. */
|
/* We have the results, process them. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user