GainSpan Wi-Fi library see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

Dependents:   GSwifi_httpd GSwifi_websocket GSwifi_tcpclient GSwifi_tcpserver ... more

Fork of GSwifi by gs fan

GainSpan Wi-Fi library

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

see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

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

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

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

解説: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

Revision:
6:a423f0d197de
Parent:
5:6def1d0df519
Child:
7:b75b7fc144ff
--- a/GSwifi.cpp	Fri Jul 13 04:14:14 2012 +0000
+++ b/GSwifi.cpp	Thu Aug 16 05:01:19 2012 +0000
@@ -517,6 +517,10 @@
             r = command("AT+NDHCP=1", GSRES_DHCP, GS_TIMEOUT2);
         }
         break;
+    default:
+        DBG("Can't use security\r\n");
+        r = -1;
+        break;
     }
 
     if (r == 0) _connect = true;
@@ -595,7 +599,7 @@
     command("AT+NDHCP=0", GSRES_NORMAL);
     setAddress(ipaddr, netmask, ipaddr, ipaddr);
     command("AT+DHCPSRVR=1", GSRES_NORMAL);
-    command("AT+DNS=1,gainspan", GSRES_NORMAL);
+    command("AT+DNS=1,setup", GSRES_NORMAL);
 
     switch (sec) {
     case GSSEC_NONE:
@@ -827,6 +831,15 @@
     return _time;
 }
 
+int GSwifi::gpioOut (int port, int out) {
+    char cmd[GS_CMD_SIZE];
+
+    if (_status != GSSTAT_READY) return -1;
+
+    sprintf(cmd, "AT+DGPIO=%d,%d", port, out);
+    return command(cmd, GSRES_NORMAL);
+}
+
 void GSwifi::poll() {
     int i;
 
@@ -968,6 +981,7 @@
 
 int GSwifi::send (int cid, char *buf, int len) {
     int i;
+    Timer timeout;
 
     if (! _gs_sock[cid].connect) return -1;
 
@@ -996,12 +1010,14 @@
     } else {
         return -1;
     }
-    while (!_gs_ok && !_gs_failure);
+    timeout.start();
+    while (!_gs_ok && !_gs_failure && timeout.read_ms() < GS_TIMEOUT);
     return _gs_ok == 1 ? 0 : -1;
 }
 
 int GSwifi::send (int cid, char *buf, int len, Host &host) {
     int i;
+    Timer timeout;
 
     if (! _gs_sock[cid].connect) return -1;
 
@@ -1009,7 +1025,6 @@
         // UDP Server
         _gs_ok = 0;
         _gs_failure = 0;
-        _gs_putc(0x1b);
 #ifdef GS_BULK
         _gs.printf("\x1bY%X", cid);
         _gs.printf("%d.%d.%d.%d %d:", host.getIp()[0], host.getIp()[1], host.getIp()[2], host.getIp()[3], host.getPort());
@@ -1033,7 +1048,8 @@
     } else {
         return -1;
     }
-    while (!_gs_ok && !_gs_failure);
+    timeout.start();
+    while (!_gs_ok && !_gs_failure && timeout.read_ms() < GS_TIMEOUT);
     return _gs_ok == 1 ? 0 : -1;
 }