@@ -68,8 +68,11 @@ ESP8266Interface::ESP8266Interface()
68
68
memset (_cbs, 0 , sizeof (_cbs));
69
69
memset (ap_ssid, 0 , sizeof (ap_ssid));
70
70
memset (ap_pass, 0 , sizeof (ap_pass));
71
- memset (_country_code, 0 , sizeof (_country_code));
72
- strncpy (_country_code, MBED_CONF_ESP8266_COUNTRY_CODE, sizeof (_country_code));
71
+
72
+ _ch_info.track_ap = true ;
73
+ strncpy (_ch_info.country_code , MBED_CONF_ESP8266_COUNTRY_CODE, sizeof (_ch_info.country_code ));
74
+ _ch_info.channel_start = MBED_CONF_ESP8266_CHANNEL_START;
75
+ _ch_info.channels = MBED_CONF_ESP8266_CHANNELS;
73
76
74
77
_esp.sigio (this , &ESP8266Interface::event);
75
78
_esp.set_timeout ();
@@ -99,8 +102,11 @@ ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName r
99
102
memset (_cbs, 0 , sizeof (_cbs));
100
103
memset (ap_ssid, 0 , sizeof (ap_ssid));
101
104
memset (ap_pass, 0 , sizeof (ap_pass));
102
- memset (_country_code, 0 , sizeof (_country_code));
103
- strncpy (_country_code, MBED_CONF_ESP8266_COUNTRY_CODE, sizeof (_country_code));
105
+
106
+ _ch_info.track_ap = true ;
107
+ strncpy (_ch_info.country_code , MBED_CONF_ESP8266_COUNTRY_CODE, sizeof (_ch_info.country_code ));
108
+ _ch_info.channel_start = MBED_CONF_ESP8266_CHANNEL_START;
109
+ _ch_info.channels = MBED_CONF_ESP8266_CHANNELS;
104
110
105
111
_esp.sigio (this , &ESP8266Interface::event);
106
112
_esp.set_timeout ();
@@ -411,7 +417,7 @@ nsapi_error_t ESP8266Interface::_init(void)
411
417
if (!_esp.set_default_wifi_mode (ESP8266::WIFIMODE_STATION)) {
412
418
return NSAPI_ERROR_DEVICE_ERROR;
413
419
}
414
- if (!_esp.set_country_code_policy (true , _country_code, MBED_CONF_ESP8266_CHANNEL_START, MBED_CONF_ESP8266_CHANNELS )) {
420
+ if (!_esp.set_country_code_policy (true , _ch_info. country_code , _ch_info. channel_start , _ch_info. channels )) {
415
421
return NSAPI_ERROR_DEVICE_ERROR;
416
422
}
417
423
if (!_esp.cond_enable_tcp_passive_mode ()) {
@@ -862,7 +868,7 @@ nsapi_error_t ESP8266Interface::set_blocking(bool blocking)
862
868
return NSAPI_ERROR_OK;
863
869
}
864
870
865
- nsapi_error_t ESP8266Interface::set_country_code (const char *country_code, int len)
871
+ nsapi_error_t ESP8266Interface::set_country_code (bool track_ap, const char *country_code, int len, int channel_start, int channels )
866
872
{
867
873
for (int i = 0 ; i < len; i++) {
868
874
// Validation done by firmware
@@ -872,9 +878,14 @@ nsapi_error_t ESP8266Interface::set_country_code(const char *country_code, int l
872
878
}
873
879
}
874
880
881
+ _ch_info.track_ap = track_ap;
882
+
875
883
// Firmware takes only first three characters
876
- strncpy (_country_code, country_code, sizeof (_country_code));
877
- _country_code[sizeof (_country_code)-1 ] = ' \0 ' ;
884
+ strncpy (_ch_info.country_code , country_code, sizeof (_ch_info.country_code ));
885
+ _ch_info.country_code [sizeof (_ch_info.country_code )-1 ] = ' \0 ' ;
886
+
887
+ _ch_info.channel_start = channel_start;
888
+ _ch_info.channels = channels;
878
889
879
890
return NSAPI_ERROR_OK;
880
891
}
0 commit comments