private fork
Fork of GSwifiInterface by
Diff: GSwifi/GSwifi.cpp
- Revision:
- 13:189e04ac70bd
- Parent:
- 12:057089026a20
- Child:
- 15:086d1a33a197
--- a/GSwifi/GSwifi.cpp Fri Nov 22 14:03:07 2013 +0000 +++ b/GSwifi/GSwifi.cpp Tue Nov 26 09:06:35 2013 +0000 @@ -71,6 +71,7 @@ } cmdBDATA(true); if (cmdNMAC()) return -1; + cmdWREGDOMAIN(CFG_WREGDOMAIN); cmdWM(0); // infrastructure wait_ms(100); @@ -78,7 +79,7 @@ case SEC_NONE: case SEC_OPEN: case SEC_WEP: - cmdNDHCP(_state.dhcp, _state.name, 0); + cmdNDHCP(_state.dhcp, _state.name, DEFAULT_WAIT_RESP_TIMEOUT); cmdWAUTH(_state.sec); if (_state.sec != SEC_NONE) { cmdWWEP(1, _state.pass); @@ -93,7 +94,7 @@ break; case SEC_WPA_PSK: case SEC_WPA2_PSK: - cmdNDHCP(_state.dhcp, _state.name, 0); + cmdNDHCP(_state.dhcp, _state.name, DEFAULT_WAIT_RESP_TIMEOUT); cmdWAUTH(0); cmdWPAPSK(_state.ssid, _state.pass); wait_ms(100); @@ -165,6 +166,7 @@ } if (cmdNMAC()) return -1; cmdBDATA(true); + cmdWREGDOMAIN(CFG_WREGDOMAIN); cmdWM(1); // adhock wait_ms(100); @@ -214,6 +216,7 @@ } if (cmdNMAC()) return -1; cmdBDATA(true); + cmdWREGDOMAIN(CFG_WREGDOMAIN); cmdWM(2); // limitedap wait_ms(100); @@ -285,28 +288,32 @@ void GSwifi::poll () { #ifndef CFG_ENABLE_RTOS static int t = 0; + static Timer timer; if (_state.wm == WM_INFRASTRUCTURE && (! isAssociated()) && _state.ssid) { - if (t && time(NULL) > t) { + if (t == 0 || timer.read() > CFG_RECONNECT) { // Wi-Fi re-associate if (_state.initialized) { - if (!cmdWA(_state.ssid)) { + if (cmdWA(_state.ssid)) { + timer.reset(); + timer.start(); + t = 1; + } else { _state.associated = true; + timer.stop(); t = 0; - } else { - t = time(NULL) + CFG_RECONNECT; } } else { if (join()) { - t = 0; + timer.reset(); + timer.start(); + t = 1; } else { - t = time(NULL) + CFG_RECONNECT; + timer.stop(); + t = 0; } } } - } else { - if (t == 0) - t = time(NULL) + CFG_RECONNECT; } #else if (_state.wm == WM_INFRASTRUCTURE && (! isAssociated()) && _state.ssid) { @@ -349,7 +356,7 @@ INFO("disassociated"); while (!_wifi->isAssociated()){ _wifi->poll(); - Thread::wait(CFG_TIMEOUT); + Thread::wait(CFG_RECONNECT * 1000); } } }