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:
12:057089026a20
Parent:
11:71d67fea5ace
Child:
13:189e04ac70bd
--- a/GSwifi/GSwifi.cpp	Fri Nov 15 04:20:14 2013 +0000
+++ b/GSwifi/GSwifi.cpp	Fri Nov 22 14:03:07 2013 +0000
@@ -63,6 +63,7 @@
         strncpy(_state.name, CFG_DHCPNAME, sizeof(_state.name));
     }
     clearFlags();
+    _state.mode = MODE_COMMAND;
     sendCommand(NULL, RES_NULL, 0);
     if (cmdE(false)) return -1;
     if (_flow) {
@@ -156,6 +157,7 @@
     _state.wm = WM_ADHOCK;
     _state.initialized = true;
     clearFlags();
+    _state.mode = MODE_COMMAND;
     sendCommand(NULL, RES_NULL, 0);
     if (cmdE(false)) return -1;
     if (_flow) {
@@ -204,6 +206,7 @@
         strncpy(_state.name, CFG_DNSNAME, sizeof(_state.name));
     }
     clearFlags();
+    _state.mode = MODE_COMMAND;
     sendCommand(NULL, RES_NULL, 0);
     if (cmdE(false)) return -1;
     if (_flow) {
@@ -245,7 +248,7 @@
     return r;
 }
 
-int GSwifi::disconnect()
+int GSwifi::dissociate()
 {
     int i;
 
@@ -274,7 +277,7 @@
 
 }
 
-bool GSwifi::isConnected()
+bool GSwifi::isAssociated()
 {
     return _state.associated;
 }
@@ -283,7 +286,7 @@
 #ifndef CFG_ENABLE_RTOS
     static int t = 0;
 
-    if (_state.wm == WM_INFRASTRUCTURE && (! isConnected()) && _state.ssid) {
+    if (_state.wm == WM_INFRASTRUCTURE && (! isAssociated()) && _state.ssid) {
       if (t && time(NULL) > t) {
         // Wi-Fi re-associate
         if (_state.initialized) {
@@ -306,7 +309,7 @@
             t = time(NULL) + CFG_RECONNECT;
     }
 #else
-    if (_state.wm == WM_INFRASTRUCTURE && (! isConnected()) && _state.ssid) {
+    if (_state.wm == WM_INFRASTRUCTURE && (! isAssociated()) && _state.ssid) {
         // Wi-Fi re-associate
         if (_state.initialized) {
             if (!cmdWA(_state.ssid)) {
@@ -317,6 +320,20 @@
         }
     }
 #endif
+
+    for (int i = 0; i < 16; i ++) {
+        if (isConnected(i) && _con[i].received && _con[i].buf)
+          if (_con[i].func != NULL && !_con[i].buf->isEmpty()) {
+            _con[i].func(i);
+            if (_con[i].buf->isEmpty()) {
+                _con[i].received = false;
+            }
+        }
+    }
+
+#ifdef CFG_ENABLE_HTTPD
+    httpdPoll();
+#endif
 }
 
 #ifdef CFG_ENABLE_RTOS
@@ -330,7 +347,7 @@
         Thread::signal_wait(1);
         Thread::wait(1000);
         INFO("disassociated");
-        while (!_wifi->isConnected()){
+        while (!_wifi->isAssociated()){
             _wifi->poll();
             Thread::wait(CFG_TIMEOUT);
         }
@@ -338,6 +355,22 @@
 }
 #endif
 
+GSwifi::Status GSwifi::getStatus () {
+    return _state.status;
+}
+
+int GSwifi::setMacAddress (const char *mac) {
+    if (cmdNMAC(mac)) return -1;
+    strncpy(_state.mac, mac, sizeof(_state.mac));
+    return 0;
+}
+
+int GSwifi::getMacAddress (char *mac) {
+    if (cmdNMAC()) return -1;
+    strcpy(mac, _state.mac);
+    return 0;
+}
+
 int GSwifi::setAddress (const char *name) {
     _state.dhcp = true;
     strncpy(_state.name, name, sizeof(_state.name));