Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSSI getter fixed for ESP8266 #11304

Merged
merged 2 commits into from
Aug 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions components/wifi/esp8266-driver/ESP8266/ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ const char *ESP8266::netmask()

int8_t ESP8266::rssi()
{
int8_t rssi;
int8_t rssi = 0;
char bssid[18];

_smutex.lock();
Expand All @@ -438,17 +438,27 @@ int8_t ESP8266::rssi()
_smutex.unlock();
return 0;
}

set_timeout();
_smutex.unlock();

WiFiAccessPoint ap[1];
_scan_r.res = ap;
_scan_r.limit = 1;
_scan_r.cnt = 0;

_smutex.lock();
set_timeout(ESP8266_CONNECT_TIMEOUT);
if (!(_parser.send("AT+CWLAP=\"\",\"%s\",", bssid)
&& _parser.recv("+CWLAP:(%*d,\"%*[^\"]\",%hhd,", &rssi)
&& _parser.recv("OK\n"))) {
_smutex.unlock();
return 0;
rssi = 0;
} else if (_scan_r.cnt == 1) {
//All OK so read and return rssi
rssi = ap[0].get_rssi();
}

_scan_r.cnt = 0;
_scan_r.res = NULL;
set_timeout();
_smutex.unlock();

Expand Down Expand Up @@ -482,6 +492,7 @@ int ESP8266::scan(WiFiAccessPoint *res, unsigned limit, scan_mode mode, unsigned
}
}


int cnt = _scan_r.cnt;
_scan_r.res = NULL;

Expand Down