You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/09/19 08:14:50 UTC

[incubator-nuttx-apps] branch master updated: wireless/wapi: add scan partial channel support

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new a0f6b14  wireless/wapi: add scan partial channel support
a0f6b14 is described below

commit a0f6b14c0d1ecb37cd133046c15ec69ed0427bc5
Author: chao.an <an...@xiaomi.com>
AuthorDate: Wed Sep 2 19:37:21 2020 +0800

    wireless/wapi: add scan partial channel support
    
    Change-Id: I2279406a9ca0cc3a9535ce79fbf651dbaf14ad4c
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 include/wireless/wapi.h      | 13 +++++++++++++
 wireless/wapi/src/wireless.c | 32 +++++++++++++++++++++++++++++---
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/include/wireless/wapi.h b/include/wireless/wapi.h
index af05e2d..90817f4 100644
--- a/include/wireless/wapi.h
+++ b/include/wireless/wapi.h
@@ -644,6 +644,19 @@ int wapi_make_socket(void);
 int wapi_scan_init(int sock, FAR const char *ifname, FAR const char *essid);
 
 /****************************************************************************
+ * Name: wapi_scan_channel_init
+ *
+ * Description:
+ *   Starts a scan on the given interface. Root privileges are required to
+ *   start a scan with specified channels.
+ *
+ ****************************************************************************/
+
+int wapi_scan_channel_init(int sock, FAR const char *ifname,
+                           FAR const char *essid,
+                           uint8_t *channels, int num_channels);
+
+/****************************************************************************
  * Name: wapi_scan_stat
  *
  * Description:
diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c
index f41c3bc..c5fd8d0 100644
--- a/wireless/wapi/src/wireless.c
+++ b/wireless/wapi/src/wireless.c
@@ -1138,15 +1138,17 @@ int wapi_set_txpower(int sock, FAR const char *ifname, int power,
 }
 
 /****************************************************************************
- * Name: wapi_scan_init
+ * Name: wapi_scan_channel_init
  *
  * Description:
  *   Starts a scan on the given interface. Root privileges are required to
- *   start a scan.
+ *   start a scan with specified channels.
  *
  ****************************************************************************/
 
-int wapi_scan_init(int sock, const char *ifname, const char *essid)
+int wapi_scan_channel_init(int sock, FAR const char *ifname,
+                           FAR const char *essid,
+                           uint8_t *channels, int num_channels)
 {
   struct iw_scan_req req;
   struct iwreq wrq =
@@ -1155,6 +1157,7 @@ int wapi_scan_init(int sock, const char *ifname, const char *essid)
 
   size_t essid_len;
   int ret;
+  int i;
 
   if (essid && (essid_len = strlen(essid)) > 0)
     {
@@ -1168,6 +1171,15 @@ int wapi_scan_init(int sock, const char *ifname, const char *essid)
       wrq.u.data.flags    = IW_SCAN_THIS_ESSID;
     }
 
+  if (channels && num_channels > 0)
+    {
+      req.num_channels = num_channels;
+      for (i = 0; i < num_channels; i++)
+        {
+          req.channel_list[i].m = channels[i];
+        }
+    }
+
   strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
   ret = ioctl(sock, SIOCSIWSCAN, (unsigned long)((uintptr_t)&wrq));
   if (ret < 0)
@@ -1181,6 +1193,20 @@ int wapi_scan_init(int sock, const char *ifname, const char *essid)
 }
 
 /****************************************************************************
+ * Name: wapi_scan_init
+ *
+ * Description:
+ *   Starts a scan on the given interface. Root privileges are required to
+ *   start a scan.
+ *
+ ****************************************************************************/
+
+int wapi_scan_init(int sock, FAR const char *ifname, FAR const char *essid)
+{
+  return wapi_scan_channel_init(sock, ifname, essid, NULL, 0);
+}
+
+/****************************************************************************
  * Name: wapi_scan_stat
  *
  * Description: