@@ -2121,7 +2121,7 @@ void WiFiManager::handleReset() {
2121
2121
// }
2122
2122
void WiFiManager::handleErase (boolean opt) {
2123
2123
#ifdef WM_DEBUG_LEVEL
2124
- DEBUG_WM (DEBUG_VERBOSE ,F (" <- HTTP Erase" ));
2124
+ DEBUG_WM (DEBUG_NOTIFY ,F (" <- HTTP Erase" ));
2125
2125
#endif
2126
2126
handleRequest ();
2127
2127
String page = getHTTPHead (FPSTR (S_titleerase)); // @token titleerase
@@ -3152,15 +3152,38 @@ String WiFiManager::getModeString(uint8_t mode){
3152
3152
3153
3153
bool WiFiManager::WiFiSetCountry (){
3154
3154
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
3156
3172
#ifdef ESP32
3157
3173
// @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!
3159
3177
else if (_wificountry == " US" ) ret = esp_wifi_set_country (&WM_COUNTRY_US) == ESP_OK;
3160
3178
else if (_wificountry == " JP" ) ret = esp_wifi_set_country (&WM_COUNTRY_JP) == ESP_OK;
3161
3179
else if (_wificountry == " CN" ) ret = esp_wifi_set_country (&WM_COUNTRY_CN) == ESP_OK;
3162
3180
#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);
3164
3187
#endif
3165
3188
3166
3189
#elif defined(ESP8266) && !defined(WM_NOCOUNTRY)
@@ -3174,7 +3197,7 @@ bool WiFiManager::WiFiSetCountry(){
3174
3197
#endif
3175
3198
3176
3199
#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);
3178
3201
#endif
3179
3202
#ifdef WM_DEBUG_LEVEL
3180
3203
else DEBUG_WM (DEBUG_ERROR,F (" [ERROR] esp_wifi_set_country failed" ));
0 commit comments