Skip to content

Commit e071e3a

Browse files
committed
debugging testing country esp32
1 parent e394283 commit e071e3a

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

WiFiManager.cpp

+28-5
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ void WiFiManager::handleReset() {
21212121
// }
21222122
void WiFiManager::handleErase(boolean opt) {
21232123
#ifdef WM_DEBUG_LEVEL
2124-
DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP Erase"));
2124+
DEBUG_WM(DEBUG_NOTIFY,F("<- HTTP Erase"));
21252125
#endif
21262126
handleRequest();
21272127
String page = getHTTPHead(FPSTR(S_titleerase)); // @token titleerase
@@ -3152,15 +3152,38 @@ String WiFiManager::getModeString(uint8_t mode){
31523152

31533153
bool WiFiManager::WiFiSetCountry(){
31543154
if(_wificountry == "") return false; // skip not set
3155-
bool ret = false;
3155+
3156+
#ifdef WM_DEBUG_LEVEL
3157+
DEBUG_WM(DEBUG_VERBOSE,F("WiFiSetCountry to"),_wificountry);
3158+
#endif
3159+
3160+
/*
3161+
* @return
3162+
* - ESP_OK: succeed
3163+
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by eps_wifi_init
3164+
* - ESP_ERR_WIFI_IF: invalid interface
3165+
* - ESP_ERR_WIFI_ARG: invalid argument
3166+
* - others: refer to error codes in esp_err.h
3167+
*/
3168+
3169+
3170+
esp_err_t ret = false;
3171+
// ret = esp_wifi_set_bandwidth(WIFI_IF_AP,WIFI_BW_HT20); // WIFI_BW_HT40
31563172
#ifdef ESP32
31573173
// @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( might be now! )
3158-
if(WiFi.getMode() == WIFI_MODE_NULL); // exception if wifi not init!
3174+
if(WiFi.getMode() == WIFI_MODE_NULL){
3175+
DEBUG_WM(DEBUG_ERROR,"[ERROR] cannot set country, wifi not init");
3176+
} // exception if wifi not init!
31593177
else if(_wificountry == "US") ret = esp_wifi_set_country(&WM_COUNTRY_US) == ESP_OK;
31603178
else if(_wificountry == "JP") ret = esp_wifi_set_country(&WM_COUNTRY_JP) == ESP_OK;
31613179
else if(_wificountry == "CN") ret = esp_wifi_set_country(&WM_COUNTRY_CN) == ESP_OK;
31623180
#ifdef WM_DEBUG_LEVEL
3163-
else DEBUG_WM(DEBUG_ERROR,"[ERROR] country code not found");
3181+
else{
3182+
DEBUG_WM(DEBUG_ERROR,"[ERROR] country code not found");
3183+
}
3184+
if(ret == ESP_ERR_WIFI_NOT_INIT) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_NOT_INIT");
3185+
else if(ret == ESP_ERR_INVALID_ARG) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_ARG");
3186+
else if (ret != ERR_OK)DEBUG_WM(DEBUG_ERROR,"[ERROR] unknown error",(String)ret);
31643187
#endif
31653188

31663189
#elif defined(ESP8266) && !defined(WM_NOCOUNTRY)
@@ -3174,7 +3197,7 @@ bool WiFiManager::WiFiSetCountry(){
31743197
#endif
31753198

31763199
#ifdef WM_DEBUG_LEVEL
3177-
if(ret) DEBUG_WM(DEBUG_VERBOSE,F("esp_wifi_set_country: "),_wificountry);
3200+
if(ret) DEBUG_WM(DEBUG_VERBOSE,F("[OK] esp_wifi_set_country: "),_wificountry);
31783201
#endif
31793202
#ifdef WM_DEBUG_LEVEL
31803203
else DEBUG_WM(DEBUG_ERROR,F("[ERROR] esp_wifi_set_country failed"));

0 commit comments

Comments
 (0)