diff --git a/WiFiManager.cpp b/WiFiManager.cpp index d10fc33..4a41b98 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3457,8 +3457,14 @@ bool WiFiManager::WiFiSetCountry(){ // If an invalid country code is passed, ESP_ERR_WIFI_ARG will be returned // This also uses 802.11d mode, which matches the STA to the country code of the AP it connects to (meaning // that the country code will be overridden if connecting to a "foreign" AP) - else err = esp_wifi_set_country_code(_wificountry.c_str(), true); - + else { + #ifndef WM_NOCOUNTRY + err = esp_wifi_set_country_code(_wificountry.c_str(), true); + #else + DEBUG_WM(DEBUG_ERROR,"[ERROR] esp wifi set country is not available"); + err = true; + #endif + } #ifdef WM_DEBUG_LEVEL if(err){ if(err == ESP_ERR_WIFI_NOT_INIT) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_NOT_INIT"); diff --git a/WiFiManager.h b/WiFiManager.h index df540d0..4c057ee 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -638,10 +638,18 @@ class WiFiManager #define WM_ARDUINOEVENTS #else #define WM_NOSOFTAPSSID + #define WM_NOCOUNTRY #endif + #else + #define WM_NOCOUNTRY #endif + #ifdef WM_NOCOUNTRY + #warning "ESP32 set country unavailable" + #endif + + #ifdef WM_ARDUINOEVENTS void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info); #else diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index f37c8de..e627b06 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -219,7 +219,7 @@ void setup() { // setting wifi country seems to improve OSX soft ap connectivity, // may help others as well, default is CN which has different channels - // wm.setCountry("US"); // crashing on esp32 2.0 + wm.setCountry("US"); // crashing on esp32 2.0 // set Hostname