Skip to content
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