GSwifiInterface library (interface for GainSpan Wi-Fi GS1011 modules) Please see https://mbed.org/users/gsfan/notebook/GSwifiInterface/

Dependents:   GSwifiInterface_HelloWorld GSwifiInterface_HelloServo GSwifiInterface_UDPEchoServer GSwifiInterface_UDPEchoClient ... more

Fork of WiflyInterface by mbed official

GainSpan Wi-Fi library

The GS1011/GS2100 is an ultra low power 802.11b wireless module from GainSpan.

mbed RTOS supported.

/media/uploads/gsfan/gs_im_002.jpg /media/uploads/gsfan/gs1011m_2.jpg

ゲインスパン Wi-Fi モジュール ライブラリ

ゲインスパン社の低電力 Wi-Fiモジュール(無線LAN) GS1011/GS2100 シリーズ用のライブラリです。

mbed RTOS に対応しています。(mbed2.0)

Revision:
22:d25a5a0d2497
Parent:
15:086d1a33a197
--- a/GSwifi/GSwifi_at.cpp	Thu Jun 05 06:12:59 2014 +0000
+++ b/GSwifi/GSwifi_at.cpp	Tue Sep 24 06:24:37 2019 +0000
@@ -45,8 +45,13 @@
         t.start();
         for (;;) {
             if (_state.ok && _state.res == RES_NULL) break;
-            if (_state.failure || t.read_ms() > timeout) {
-                WARN("failure or timeout\r\n");
+            if (_state.failure) {
+                WARN("failure\r\n");
+                _state.res = RES_NULL;
+                return -1;
+            }
+            if (t.read_ms() > timeout) {
+                WARN("timeout\r\n");
                 _state.res = RES_NULL;
                 return -1;
             }
@@ -63,6 +68,34 @@
     int i;
     Timer t;
 
+#ifdef CFG_SPI_DATAINTERFACE
+    if (_state.datainterface) {
+        if (lockSpi(timeout)) return -1;
+    
+        clearFlags();
+        for (i = 0; i < strlen(cmd); i ++) {
+            putSpi(cmd[i]);
+        }
+        for (i = 0; i < len; i ++) {
+            switch (data[i]) {
+            case 0: // encode
+            case 0xf3:
+            case 0xf5:
+            case 0xfa:
+            case 0xfb:
+            case 0xfd:
+            case 0xff:
+                putSpi(0xfb);
+                putSpi(data[i] ^ 0x20); // xor
+                break;
+            default:
+                putSpi(data[i]);
+                break;
+            }
+        }
+        unlockSpi();
+    } else {
+#endif
     if (lockUart(timeout)) return -1;
 
     clearFlags();
@@ -73,14 +106,21 @@
         putUart(data[i]);
     }
     unlockUart();
-    INFO("data: '%s' %d\r\n", cmd, len);
+#ifdef CFG_SPI_DATAINTERFACE
+    } // _state.datainterface
+#endif
+    INFO("data: '%s' %d %d\r\n", cmd, len, _state.datainterface);
 
     if (timeout) {
         t.start();
         for (;;) {
             if (_state.ok) break;
-            if (_state.failure || t.read_ms() > timeout) {
-                WARN("failure or timeout\r\n");
+            if (_state.failure) {
+                WARN("failure\r\n");
+                return -1;
+            }
+            if (t.read_ms() > timeout) {
+                WARN("timeout\r\n");
                 return -1;
             }
         }