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/

Files at this revision

API Documentation at this revision

Comitter:
gsfan
Date:
Wed Dec 18 01:16:04 2013 +0000
Parent:
41:0afda15e9bb4
Child:
43:0b5e2727e020
Commit message:
fix reconnect

Changed in this revision

GSwifi.cpp Show annotated file Show diff for this revision Revisions of this file
GSwifi.h Show annotated file Show diff for this revision Revisions of this file
--- a/GSwifi.cpp	Wed Aug 21 13:53:56 2013 +0000
+++ b/GSwifi.cpp	Wed Dec 18 01:16:04 2013 +0000
@@ -135,7 +135,6 @@
     _ssid = NULL;
     _pass = NULL;
     _reconnect = 0;
-    _reconnect_time = 0;
     _buf_cmd.flush();
 
     wait_ms(100);
@@ -643,6 +642,8 @@
 
 void GSwifi::poll () {
     int i, j;
+    static int t = 0;
+    static Timer timer;
 
     for (i = 0; i < 16; i ++) {
         if (_gs_sock[i].connect && _gs_sock[i].received) {
@@ -657,12 +658,12 @@
         }
     }
 
-    if (_reconnect > 0 && ! _connect) {
-        if (_reconnect_time < time(NULL)) {
-            DBG("reconnect %d\r\n", _reconnect_time);
-            if (reconnect()) {
-                _reconnect_time = time(NULL) + _reconnect;
-            }
+    if (t == 0 || timer.read() > _reconnect) {
+        DBG("reconnect\r\n");
+        if (reconnect()) {
+            timer.reset();
+            timer.start();
+            t = 1;
         }
     }
 }
@@ -822,8 +823,7 @@
 
     if (r == 0) {
         _connect = true;
-        _reconnect = reconnect;
-        _reconnect_time = 0;
+        _reconnect = reconnect * 1000;
         _sec = sec;
         _dhcp = dhcp;
         if (_reconnect && ssid) {
--- a/GSwifi.h	Wed Aug 21 13:53:56 2013 +0000
+++ b/GSwifi.h	Wed Dec 18 01:16:04 2013 +0000
@@ -607,7 +607,6 @@
     GSSECURITY _sec;
     char *_ssid, *_pass;
     int _reconnect;
-    time_t _reconnect_time;
     
 #ifdef GS_ENABLE_HTTPD
     struct GS_httpd _httpd[16];