nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerpe...@apache.org
Subject [incubator-nuttx] branch master updated: drivers: wireless: Add WPA2-PSK in AP mode for gs2200m
Date Fri, 22 May 2020 08:20:16 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 287b9f9  drivers: wireless: Add WPA2-PSK in AP mode for gs2200m
287b9f9 is described below

commit 287b9f9c385fe68c1fbfc71e0bbcb29b6ab36640
Author: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>
AuthorDate: Fri May 22 13:52:37 2020 +0900

    drivers: wireless: Add WPA2-PSK in AP mode for gs2200m
    
    NOTE: By default, WPA2-PSK is used instead of WEP
    
    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>>
---
 boards/arm/cxd56xx/spresense/README.txt | 10 +++++---
 drivers/wireless/Kconfig                |  4 +++
 drivers/wireless/gs2200m.c              | 44 ++++++++++++++++++++++++++++++---
 3 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/boards/arm/cxd56xx/spresense/README.txt b/boards/arm/cxd56xx/spresense/README.txt
index 74625e2..dc4ecdf 100644
--- a/boards/arm/cxd56xx/spresense/README.txt
+++ b/boards/arm/cxd56xx/spresense/README.txt
@@ -95,8 +95,12 @@ Configuration sub-directories
     (2) Access Point (AP) mode
 
     To run the module in AP mode, you need to specify SSID to advertise and
-    WEP-key. (NOTE: in AP mode, you can also specify channel number to use)
+    WPA2-PSK passphrase or WEP-key. (NOTE: in AP mode, you can also specify
+    channel number to use. Also, you need to set CONFIG_WL_GS2200M_ENABLE_WEP=y
+    if you want to use WEP instead of WPA2-PSK)
 
+      nsh> gs2200m -a ssid-to-advertise 8-to-63-wpa2-psk-passphrase &
+      or
       nsh> gs2200m -a ssid-to-advertise 10-hex-digits-wep-key &
 
     If the module was initialized in AP mode, you can see a new IP address is
@@ -106,5 +110,5 @@ Configuration sub-directories
       eth0    Link encap:Ethernet HWaddr 3c:95:09:00:69:93 at UP
       inet    addr:192.168.11.1 DRaddr:192.168.11.1 Mask:255.255.255.0
 
-    Now you can connect your PC to the AP with the above SSID and WEP-key
-    which you specified.
+    Now you can connect your PC to the AP with the above SSID and WPA2-PSK
+    passphrase or WEP-key which you specified.
diff --git a/drivers/wireless/Kconfig b/drivers/wireless/Kconfig
index bd500be..c9f46c8 100644
--- a/drivers/wireless/Kconfig
+++ b/drivers/wireless/Kconfig
@@ -37,6 +37,10 @@ config WL_GS2200M
 
 if WL_GS2200M
 
+config WL_GS2200M_ENABLE_WEP
+	bool "WEP support in AP mode"
+	default false
+
 config WL_GS2200M_SPI_FREQUENCY
 	int "SPI frequency for GS2200M"
 	default 4000000
diff --git a/drivers/wireless/gs2200m.c b/drivers/wireless/gs2200m.c
index 49caecd..907ef3c 100644
--- a/drivers/wireless/gs2200m.c
+++ b/drivers/wireless/gs2200m.c
@@ -106,6 +106,9 @@
 #define PORT_START   50000
 #define PORT_END     59999
 
+#define SEC_MODE_WEP     2
+#define SEC_MODE_WPA2PSK 8
+
 /****************************************************************************
  * Private Data Types
  ****************************************************************************/
@@ -1686,9 +1689,11 @@ static enum pkt_type_e gs2200m_set_auth(FAR struct gs2200m_dev_s *dev,
   return gs2200m_send_cmd(dev, cmd, NULL);
 }
 
+#ifdef CONFIG_WL_GS2200M_ENABLE_WEP
+
 /****************************************************************************
  * Name: gs2200m_set_wepkey
- * NOTE: See xxxx
+ * NOTE: See 5.3.3.2
  ****************************************************************************/
 
 static enum pkt_type_e gs2200m_set_wepkey(FAR struct gs2200m_dev_s *dev,
@@ -1700,6 +1705,24 @@ static enum pkt_type_e gs2200m_set_wepkey(FAR struct gs2200m_dev_s
*dev,
   return gs2200m_send_cmd(dev, cmd, NULL);
 }
 
+#else
+
+/****************************************************************************
+ * Name: gs2200m_set_wpa2pf
+ * NOTE: See 5.3.3.4
+ ****************************************************************************/
+
+static enum pkt_type_e gs2200m_set_wpa2pf(FAR struct gs2200m_dev_s *dev,
+                                          FAR char *key)
+{
+  char cmd[64];
+
+  snprintf(cmd, sizeof(cmd), "AT+WWPA=%s\r\n", key);
+  return gs2200m_send_cmd(dev, cmd, NULL);
+}
+
+#endif /* CONFIG_WL_GS2200M_ENABLE_WEP */
+
 /****************************************************************************
  * Name: gs2200m_get_wstatus
  * NOTE: See 11.3.5 WLAN Status
@@ -2539,9 +2562,10 @@ static int gs2200m_ioctl_assoc_ap(FAR struct gs2200m_dev_s *dev,
   t = gs2200m_set_auth(dev, 2);
   ASSERT(TYPE_OK == t);
 
-  /* Set security mode */
+#ifdef CONFIG_WL_GS2200M_ENABLE_WEP
+  /* Set security mode (WEP) */
 
-  t = gs2200m_set_security(dev, 2);
+  t = gs2200m_set_security(dev, SEC_MODE_WEP);
   ASSERT(TYPE_OK == t);
 
   /* Set WEP key */
@@ -2551,6 +2575,20 @@ static int gs2200m_ioctl_assoc_ap(FAR struct gs2200m_dev_s *dev,
       wlerr("*** error: invalid wepkey: %s \n", msg->key);
       return -1;
     }
+#else
+  /* Set security mode (WPA2-PSK) */
+
+  t = gs2200m_set_security(dev, SEC_MODE_WPA2PSK);
+  ASSERT(TYPE_OK == t);
+
+  /* Set WPA-PSK and WPA2-PSK Passphrase */
+
+  if (TYPE_OK != gs2200m_set_wpa2pf(dev, msg->key))
+    {
+      wlerr("*** error: invalid passphrase: %s \n", msg->key);
+      return -1;
+    }
+#endif
 
   /* Start DHCP server */
 


Mime
View raw message