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:
Tue Feb 26 06:05:11 2013 +0000
Parent:
30:f3e9053d9b46
Child:
32:e19538c1f13d
Commit message:
bug fix

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
GSwifi_conf.h Show annotated file Show diff for this revision Revisions of this file
GSwifi_httpd.cpp Show annotated file Show diff for this revision Revisions of this file
GSwifi_sock.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GSwifi.cpp	Tue Feb 26 03:31:20 2013 +0000
+++ b/GSwifi.cpp	Tue Feb 26 06:05:11 2013 +0000
@@ -500,11 +500,11 @@
         _reconnect_count = 0;
         _sec = sec;
         if (ssid) {
-            if (!_ssid) _ssid = new char[sizeof(ssid) + 1];
+            if (!_ssid) _ssid = new char[strlen(ssid) + 1];
             strcpy(_ssid, ssid);
         }
         if (pass) {
-            if (!_pass) _pass = new char[sizeof(pass) + 1];
+            if (!_pass) _pass = new char[strlen(pass) + 1];
             strcpy(_pass, pass);
         }
     }
@@ -923,6 +923,7 @@
           strncmp(buf, "Disassociated", 13) == 0 ||
           strncmp(buf, "Disassociation Event", 20) == 0 ||
           strncmp(buf, "UnExpected Warm Boot", 20) == 0 ||
+          strncmp(buf, "APP Reset-APP SW Reset", 22) == 0 ||
           strncmp(buf, "APP Reset-Wlan Except", 21) == 0 ) {
             _connect = false;
             for (i = 0; i < 16; i ++) {
@@ -961,7 +962,7 @@
         break;
     case GSRES_WPS:
         if (_gs_flg == 0 && strncmp(buf, "SSID=", 5) == 0) {
-            if (!_ssid) _ssid = new char[sizeof(strlen(&buf[5])) + 1];
+            if (!_ssid) _ssid = new char[strlen(&buf[5]) + 1];
             strcpy(_ssid, &buf[5]);
             _gs_flg ++;
         } else
@@ -969,7 +970,7 @@
             _gs_flg ++;
         } else
         if (_gs_flg == 2 && strncmp(buf, "PASSPHRASE=", 11) == 0) {
-            if (!_pass) _pass = new char[sizeof(strlen(&buf[11])) + 1];
+            if (!_pass) _pass = new char[strlen(&buf[11]) + 1];
             strcpy(_pass, &buf[11]);
             _gs_flg = -1;
         }
@@ -1020,7 +1021,7 @@
         }
         break;
     case GSRES_HTTP:
-        if (buf[0] >= '0' && buf[0] <= 'F') {
+        if (buf[0] >= '0' && buf[0] <= 'F' && buf[1] == 0) {
             _cid = x2i(buf[0]);
             _gs_flg = -1;
         }
--- a/GSwifi.h	Tue Feb 26 03:31:20 2013 +0000
+++ b/GSwifi.h	Tue Feb 26 06:05:11 2013 +0000
@@ -540,7 +540,7 @@
     int get_handler (char *uri);
     int httpd_request (int cid, GS_httpd *gshttpd, char *dir);
     char *mimetype (char *file);
-    int strnicmp (char *p1, char *p2, int n);
+    int strnicmp (const char *p1, const char *p2, int n);
 #endif
 
 private:
--- a/GSwifi_conf.h	Tue Feb 26 03:31:20 2013 +0000
+++ b/GSwifi_conf.h	Tue Feb 26 06:05:11 2013 +0000
@@ -15,9 +15,9 @@
 
 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
 //#define GS_DATA_SIZE 1500
-#define GS_DATA_SIZE 1000
+#define GS_DATA_SIZE 1024
 #elif defined(TARGET_LPC11U24)
-#define GS_DATA_SIZE 500
+#define GS_DATA_SIZE 512
 #endif
 
 #define GS_SYSLOG // log for stdout
--- a/GSwifi_httpd.cpp	Tue Feb 26 03:31:20 2013 +0000
+++ b/GSwifi_httpd.cpp	Tue Feb 26 06:05:11 2013 +0000
@@ -29,9 +29,9 @@
 #ifdef GS_USE_HTTPD
 
 #define MIMETABLE_NUM 9
-struct {
-    const char ext[5];
-    const char type[24];
+static const struct {
+    char ext[5];
+    char type[24];
 } mimetable[MIMETABLE_NUM] = {
     {"txt", "text/plain"},  // default
     {"html", "text/html"},
@@ -336,14 +336,14 @@
     for (i = 0; i < MIMETABLE_NUM; i ++) {
         j = strlen(mimetable[i].ext);
         if (file[strlen(file) - j - 1] == '.' &&
-          strnicmp(&file[strlen(file) - j], (char*)mimetable[i].ext, j) == NULL) {
+          strnicmp(&file[strlen(file) - j], mimetable[i].ext, j) == NULL) {
             return (char*)mimetable[i].type;
         }
     }
     return (char*)mimetable[0].type;
 }
 
-int GSwifi::strnicmp (char *p1, char *p2, int n) {
+int GSwifi::strnicmp (const char *p1, const char *p2, int n) {
     int i, r = -1;
     char c1, c2;
     
--- a/GSwifi_sock.cpp	Tue Feb 26 03:31:20 2013 +0000
+++ b/GSwifi_sock.cpp	Tue Feb 26 06:05:11 2013 +0000
@@ -26,6 +26,7 @@
 
 
 void GSwifi::newSock (int cid, GSTYPE type, GSPROTOCOL pro) {
+    DBG("newSock %d\r\n", cid);
     _gs_sock[cid].type = type;
     _gs_sock[cid].protocol = pro;
     _gs_sock[cid].connect = true;
@@ -36,6 +37,7 @@
     }
     _gs_sock[cid].lcid = 0;
     _gs_sock[cid].received = false;
+    _gs_sock[cid].onGsReceive.detach();
 }
 
 int GSwifi::open (Host &host, GSPROTOCOL pro) {