Skip to content

Commit 341b261

Browse files
author
Marcin Tomczyk
committed
Need to change ESP8266 driver's support AT firmware version. Only AT version 1.6 0r above support AT+CWCOUNTRY command. Command AT+CWLAP format is different for version 1.6 and above
1 parent 149d53c commit 341b261

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

components/wifi/esp8266-driver/ESP8266/ESP8266.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,20 @@ int ESP8266::scan(WiFiAccessPoint *res, unsigned limit, scan_mode mode, unsigned
460460
_scan_r.limit = limit;
461461
_scan_r.cnt = 0;
462462

463-
if (!(_parser.send("AT+CWLAP=,,,%u,%u,%u", (mode == SCANMODE_ACTIVE ? 0 : 1), t_min, t_max) && _parser.recv("OK\n"))) {
463+
bool ret_parse_send = true;
464+
465+
if (FW_AT_LEAST_VERSION(_at_v.major, _at_v.minor, _at_v.patch, 0, ESP8266_AT_VERSION_WIFI_SCAN_CHANGE)) {
466+
ret_parse_send = _parser.send("AT+CWLAP=,,,%u,%u,%u", (mode == SCANMODE_ACTIVE ? 0 : 1), t_min, t_max);
467+
}
468+
else{
469+
ret_parse_send = _parser.send("AT+CWLAP");
470+
}
471+
472+
if (!(ret_parse_send && _parser.recv("OK\n"))) {
464473
tr_warning("scan(): AP info parsing aborted");
465474
// Lets be happy about partial success and not return NSAPI_ERROR_DEVICE_ERROR
466475
if (!_scan_r.cnt) {
467-
_scan_r.cnt = NSAPI_ERROR_DEVICE_ERROR;
476+
_scan_r.cnt = NSAPI_ERROR_DEVICE_ERROR;
468477
}
469478
}
470479

@@ -1225,6 +1234,11 @@ nsapi_connection_status_t ESP8266::connection_status() const
12251234

12261235
bool ESP8266::set_country_code_policy(bool track_ap, const char *country_code, int channel_start, int channels)
12271236
{
1237+
if(!(FW_AT_LEAST_VERSION(_at_v.major, _at_v.minor, _at_v.patch, 0, ESP8266_AT_VERSION_WIFI_SCAN_CHANGE)))
1238+
{
1239+
return true;
1240+
}
1241+
12281242
int t_ap = track_ap ? 0 : 1;
12291243

12301244
_smutex.lock();

0 commit comments

Comments
 (0)