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_msg.cpp
- Revision:
- 22:d25a5a0d2497
- Parent:
- 16:105b56570533
--- a/GSwifi/GSwifi_msg.cpp Thu Jun 05 06:12:59 2014 +0000 +++ b/GSwifi/GSwifi_msg.cpp Tue Sep 24 06:24:37 2019 +0000 @@ -43,11 +43,16 @@ case 0x1b: // ESC _state.buf->flush(); _state.mode = MODE_ESCAPE; + _state.escape = false; + break; + case 0xf3: // SPI link ready indication + case 0xf5: // IDLE break; default: _state.buf->flush(); _state.buf->queue(c); _state.mode = MODE_CMDRESP; + _state.escape = false; break; } break; @@ -224,14 +229,30 @@ } else #endif if (_con[cid].buf != NULL) { +#ifdef CFG_SPI_DATAINTERFACE + if (_state.datainterface) { + if (_state.escape) { // dencode + _con[cid].buf->queue(c ^ 0x20); // xor + _state.escape = false; + } else + if (c == 0xfb) { + _state.escape = true; + } else { + _con[cid].buf->queue(c); + } + } else { + _con[cid].buf->queue(c); + } +#else _con[cid].buf->queue(c); +#endif if (_con[cid].func != NULL && _con[cid].buf->available() > CFG_DATA_SIZE - 16) { setRts(false); _con[cid].received = true; WARN("buf full"); } } - count ++; + if (!_state.escape) count ++; if (count >= len) { DBG("recv bulk %d %d/%d\r\n", cid, count, len); _con[cid].received = true; @@ -243,7 +264,7 @@ } } -#define MSG_TABLE_NUM 15 +#define MSG_TABLE_NUM 16 #define RES_TABLE_NUM 11 int GSwifi::parseMessage () { int i; @@ -267,6 +288,7 @@ {"Out of StandBy-Timer", &GSwifi::msgOutofStandby}, {"Out of StandBy-Alarm", &GSwifi::msgOutofStandby}, {"Out of Deep Sleep", &GSwifi::msgOutofDeepsleep}, + {"DataInterfaceReady", &GSwifi::msgDataInterfaceReady}, }; static const struct RES_TABLE { const Response res; @@ -422,6 +444,12 @@ _state.status = STAT_READY; } +void GSwifi::msgDataInterfaceReady (const char *buf) { + DBG("DataInterfaceReady\r\n"); + _state.datainterface = true; + _state.status = STAT_READY; +} + void GSwifi::resConnect (const char *buf) { int cid; @@ -474,14 +502,14 @@ if (_state.n == 0 && strstr(buf, "SubNet") && strstr(buf, "Gateway")) { _state.n ++; } else - if (_state.n == 1) { + if (_state.n == 1 && buf[0] == ' ') { tmp = buf + 1; tmp2 = strstr(tmp, ":"); strncpy(_state.ip, tmp, tmp2 - tmp); - tmp = tmp2 + 2; + tmp = tmp2 + 1; tmp2 = strstr(tmp, ":"); strncpy(_state.netmask, tmp, tmp2 - tmp); - tmp = tmp2 + 2; + tmp = tmp2 + 1; strncpy(_state.gateway, tmp, sizeof(_state.gateway)); _state.n ++; _state.res = RES_NULL;