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
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/
ゲインスパン Wi-Fi モジュール ライブラリ
ゲインスパン社の低電力 Wi-Fiモジュール(無線LAN) GS1011 シリーズ用のライブラリです。
解説: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
Diff: GSwifi.h
- Revision:
- 35:515ec79792d3
- Parent:
- 33:b5a5a1e6325f
- Child:
- 36:a70b11e1560f
--- a/GSwifi.h Fri Mar 29 14:58:07 2013 +0000 +++ b/GSwifi.h Fri Jun 21 06:08:37 2013 +0000 @@ -30,6 +30,7 @@ #include "host.h" #include "ipaddr.h" #include "GSwifi_conf.h" +#include <stdlib.h> #include <ctype.h> @@ -142,7 +143,7 @@ GSFunctionPointer onGsReceive; }; -#ifdef GS_USE_HTTPD +#ifdef GS_ENABLE_HTTPD enum GSHTTPDMODE { GSHTTPDMODE_REQUEST, GSHTTPDMODE_HEAD, @@ -165,7 +166,7 @@ int length; // content-length int keepalive; Host host; -#ifdef GS_USE_WEBSOCKET +#ifdef GS_ENABLE_WEBSOCKET int websocket; char *websocket_key; int websocket_flg; @@ -181,7 +182,7 @@ char *dir; onHttpdCgiFunc onHttpCgi; }; -#endif // GS_USE_HTTPD +#endif // GS_ENABLE_HTTPD // ----- GSwifi.cpp ----- /** @@ -193,10 +194,6 @@ */ GSwifi (PinName p_tx, PinName p_rx, PinName p_cts, PinName p_rts, PinName p_reset, PinName p_alarm = NC, int baud = GS_BAUD); /** - * reset module - */ - void reset (); - /** * send command */ int command (const char *cmd, GSRESPONCE res, int timeout = GS_TIMEOUT); @@ -218,7 +215,7 @@ * @retval 0 success * @retval -1 failure */ - int connect (GSSECURITY sec, const char *ssid, const char *pass, int dhcp = 1, int reconnect = 0); + int connect (GSSECURITY sec, const char *ssid, const char *pass, int dhcp = 1, int reconnect = 0, char *name = NULL); /** * adhock * @param sec GSSEC_OPEN or GSSEC_WEP @@ -254,7 +251,7 @@ /** * use DHCP */ - int setAddress (); + int setAddress (char *name = NULL); /** * use static ip address */ @@ -424,6 +421,7 @@ */ bool isConnected (int cid); +#ifdef GS_ENABLE_HTTP // ----- GSwifi_http.cpp ----- /** * http request (GET method) @@ -463,8 +461,9 @@ * url decode */ int urldecode (char *str, char *buf, int len); +#endif -#ifdef GS_USE_SMTP +#ifdef GS_ENABLE_SMTP // ----- GSwifi_smtp.cpp ----- /** * send mail (smtp) @@ -481,7 +480,7 @@ int mail (Host &host, const char *to, const char *from, const char *subject, const char *mesg, const char *user = NULL, const char *pwd = NULL); #endif -#ifdef GS_USE_HTTPD +#ifdef GS_ENABLE_HTTPD // ----- GSwifi_httpd.cpp ----- /** * start http server @@ -511,6 +510,9 @@ #endif protected: + void reset (); + int autobaud (int flg); + void parseResponse (); void parseCmdResponse (char *buf); @@ -534,11 +536,11 @@ int wait_ws (int cid, int code); -#ifdef GS_USE_SMTP +#ifdef GS_ENABLE_SMTP int wait_smtp (int cid, int code); #endif -#ifdef GS_USE_HTTPD +#ifdef GS_ENABLE_HTTPD int get_handler (char *uri); int httpd_request (int cid, GS_httpd *gshttpd, char *dir); char *mimetype (char *file); @@ -547,6 +549,7 @@ private: Serial _gs; + int _baud; bool _rts; DigitalInOut _reset; DigitalInOut *_alarm; @@ -555,9 +558,9 @@ volatile bool _gs_ok, _gs_failure; volatile int _gs_flg; volatile GSRESPONCE _gs_res; - GSMODE _gs_mode; - bool _escape; - int _cid, _rssi; + volatile GSMODE _gs_mode; + volatile bool _escape; + volatile int _cid, _rssi; IpAddr _ipaddr, _netmask, _gateway, _nameserver, _resolv; Host _from, _to; char _mac[6]; @@ -567,14 +570,15 @@ GSSECURITY _sec; char *_ssid, *_pass; int _reconnect, _reconnect_count; + time_t _reconnect_time; -#ifdef GS_USE_HTTPD +#ifdef GS_ENABLE_HTTPD struct GS_httpd _httpd[16]; struct GS_httpd_handler _handler[10]; int _handler_count; void poll_httpd (int cid, int len); -#ifdef GS_USE_WEBSOCKET +#ifdef GS_ENABLE_WEBSOCKET void poll_websocket (int cid, int len); void send_websocket_accept (int cid); #endif