Skip to content

Commit

Permalink
0.5.104
Browse files Browse the repository at this point in the history
* improved wifi connection #652
  • Loading branch information
lumapu committed Mar 19, 2023
1 parent a6b8794 commit 25695fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* removed `#` character from ePaper
* fixed saving pinout for `Nokia-Display`
* removed `Reset` Pin for monochrome displays
* improved wifi connection #652

## 0.5.103
* merged MI improvements, thx @rejoe2 #778
Expand Down
14 changes: 8 additions & 6 deletions src/wifi/ahoywifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ void ahoywifi::tickWifiLoop() {
}
mCnt++;

uint8_t timeout = 10; // seconds
uint8_t timeout = (mStaConn == DISCONNECTED) ? 10 : 20; // seconds
if (mStaConn == CONNECTED) // connected but no ip
timeout = 20;


if(!mScanActive && mBSSIDList.empty() && ((mCnt % timeout) == 0)) { // start scanning APs with the given SSID
if(!mScanActive && mBSSIDList.empty() && (mStaConn == DISCONNECTED)) { // start scanning APs with the given SSID
DBGPRINT(F("scanning APs with SSID "));
DBGPRINTLN(String(mConfig->sys.stationSsid));
mScanCnt = 0;
Expand All @@ -115,8 +114,9 @@ void ahoywifi::tickWifiLoop() {
mCnt = timeout - 2;
}
if((mCnt % timeout) == 0) { // try to reconnect after x sec without connection
if(mStaConn != CONNECTED)
mStaConn = CONNECTING;
mStaConn = CONNECTING;
WiFi.disconnect();

if(mBSSIDList.size() > 0) { // get first BSSID in list
DBGPRINT(F("try to connect to AP with BSSID:"));
uint8_t bssid[6];
Expand All @@ -126,9 +126,11 @@ void ahoywifi::tickWifiLoop() {
DBGPRINT(" " + String(bssid[j], HEX));
}
DBGPRINTLN("");
WiFi.disconnect();
WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd, 0, &bssid[0]);
}
else
mStaConn = DISCONNECTED;

mCnt = 0;
}
}
Expand Down

0 comments on commit 25695fc

Please sign in to comment.