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
GainSpan Wi-Fi library
The GS1011/GS2100 is an ultra low power 802.11b wireless module from GainSpan.
mbed RTOS supported.
- about this library: http://mbed.org/users/gsfan/notebook/GSwifiInterface/
- about Wi-Fi module: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
ゲインスパン Wi-Fi モジュール ライブラリ
ゲインスパン社の低電力 Wi-Fiモジュール(無線LAN) GS1011/GS2100 シリーズ用のライブラリです。
mbed RTOS に対応しています。(mbed2.0)
- このライブラリについて: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
- Wi-FIモジュールについて: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
- UARTコマンド、SPIデータインターフェースに対応しました。(2019/09)
Diff: GSwifi/GSwifi_sock.cpp
- Revision:
- 12:057089026a20
- Parent:
- 11:71d67fea5ace
- Child:
- 16:105b56570533
--- a/GSwifi/GSwifi_sock.cpp Fri Nov 15 04:20:14 2013 +0000 +++ b/GSwifi/GSwifi_sock.cpp Fri Nov 22 14:03:07 2013 +0000 @@ -22,7 +22,7 @@ { int i, flg = 0; - if (!isConnected() && _state.status == STAT_READY) return -1; + if (!isAssociated() || _state.status != STAT_READY) return -1; for (i = 0; i < strlen(host); i ++) { if ((host[i] < '0' || host[i] > '9') && host[i] != '.') { @@ -44,10 +44,10 @@ return 0; } -int GSwifi::open (Protocol proto, const char *ip, int port, int src) { +int GSwifi::open (Protocol proto, const char *ip, int port, int src, void(*func)(int)) { int cid; - if (!isConnected() && _state.status == STAT_READY) return -1; + if (!isAssociated() || _state.status != STAT_READY) return -1; _state.cid = -1; if (proto == PROTO_TCP) { @@ -59,13 +59,14 @@ cid = _state.cid; _con[cid].protocol = proto; _con[cid].type = TYPE_CLIENT; + _con[cid].func = func; return cid; } -int GSwifi::listen (Protocol proto, int port) { +int GSwifi::listen (Protocol proto, int port, void(*func)(int)) { int cid; - if (!isConnected() && _state.status == STAT_READY) return -1; + if (!isAssociated() || _state.status != STAT_READY) return -1; _state.cid = -1; if (proto == PROTO_TCP) { @@ -77,6 +78,7 @@ cid = _state.cid; _con[cid].protocol = proto; _con[cid].type = TYPE_SERVER; + _con[cid].func = func; return cid; } @@ -185,3 +187,15 @@ *port = _con[cid].port; return 0; } + +void GSwifi::initCon (int cid, bool connected) { + _con[cid].parent = -1; + _con[cid].func = NULL; + _con[cid].accept = false; + if (_con[cid].buf == NULL) { + _con[cid].buf = new CircBuffer<char>(CFG_DATA_SIZE); + if (_con[cid].buf == NULL) error("Can't allocate memory"); + } + _con[cid].buf->flush(); + _con[cid].connected = connected; +}