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/11/11 03:36:27 UTC

[incubator-nuttx-apps] branch master updated: wireless/wapi: add channel frequency set during associate

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 3959f75  wireless/wapi: add channel frequency set during associate
3959f75 is described below

commit 3959f7535e75c0754ef79e247ce844c93c5d1d15
Author: chao.an <an...@xiaomi.com>
AuthorDate: Fri Sep 18 11:43:00 2020 +0800

    wireless/wapi: add channel frequency set during associate
    
    Therefore, the associate can support the connection of specified
    channel if the scan results contain the multiple AP with same essids.
    
    Change-Id: I4e657c52e638693e7ae19aea2a4fe8a431885547
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 include/wireless/wapi.h         |  2 ++
 wireless/wapi/src/driver_wext.c | 37 +++++++++++++++++++++++++++----------
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/include/wireless/wapi.h b/include/wireless/wapi.h
index be7ac7f..4a851fa 100644
--- a/include/wireless/wapi.h
+++ b/include/wireless/wapi.h
@@ -258,6 +258,8 @@ struct wpa_wconfig_s
                                   * IW_AUTH_CIPHER_CCMP */
   uint8_t alg;                   /* See enum wpa_alg_e above, e.g.
                                   * WPA_ALG_CCMP */
+  double freq;                   /* Channel frequency */
+  enum wapi_freq_flag_e flag;    /* Channel frequency flag */
   uint8_t ssidlen;               /* Length of the SSID */
   uint8_t phraselen;             /* Length of the passphrase */
   FAR const char *ifname;        /* E.g., "wlan0" */
diff --git a/wireless/wapi/src/driver_wext.c b/wireless/wapi/src/driver_wext.c
index 8e5b786..9249122 100644
--- a/wireless/wapi/src/driver_wext.c
+++ b/wireless/wapi/src/driver_wext.c
@@ -279,6 +279,18 @@ int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig)
       goto close_socket;
     }
 
+  if (wconfig->freq)
+    {
+      ret = wapi_set_freq(sockfd, wconfig->ifname,
+                          wconfig->freq,
+                          wconfig->flag == WAPI_FREQ_FIXED ?
+                          IW_FREQ_FIXED : IW_FREQ_AUTO);
+      if (ret < 0)
+        {
+          nerr("WARNING: Fail set freq: %d\n", ret);
+        }
+    }
+
   if (wconfig->phraselen > 0)
     {
       ret = wpa_driver_wext_set_key_ext(sockfd, wconfig->ifname,
@@ -292,20 +304,25 @@ int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig)
         }
     }
 
-  if (wconfig->bssid)
-    {
-      ret = wapi_set_ap(sockfd, wconfig->ifname,
-                        (FAR const struct ether_addr *)wconfig->bssid);
-    }
-  else
+  if (wconfig->ssid)
     {
-      ret = wapi_set_essid(sockfd, wconfig->ifname, wconfig->ssid,
-                           WAPI_ESSID_ON);
+      ret = wapi_set_essid(sockfd, wconfig->ifname,
+                           wconfig->ssid, WAPI_ESSID_ON);
+      if (ret < 0)
+        {
+          nerr("ERROR: Fail set ssid: %d\n", ret);
+          goto close_socket;
+        }
     }
 
-  if (ret < 0)
+  if (wconfig->bssid)
     {
-      nerr("ERROR: Fail set ssid: %d\n", ret);
+      ret = wapi_set_ap(sockfd, wconfig->ifname,
+                        (FAR const struct ether_addr *)wconfig->bssid);
+      if (ret < 0)
+        {
+          nerr("ERROR: Fail set bssid: %d\n", ret);
+        }
     }
 
 close_socket: