浏览代码

fix power save boot loop in IDF v4.0 - release

Disabled power save none, as this causes a boot loop under the latest esp-idf v4.0 release
Sebastien 4 年之前
父节点
当前提交
72345e1394

+ 8 - 7
components/platform_console/cmd_system.c

@@ -37,7 +37,7 @@
 #endif
 static struct {
 	struct arg_str *scanmode;
-    struct arg_lit *disable_power_save;
+    //disable_ps    struct arg_lit *disable_power_save;
 	struct arg_end *end;
 } wifi_parms_arg;
 static struct {
@@ -606,7 +606,7 @@ static int do_configure_wifi(int argc, char **argv){
 		cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.");
 		return 1;
 	}
-	nerrors += enable_disable(f,"disable_ps",wifi_parms_arg.disable_power_save);
+	// disable_ps nerrors += enable_disable(f,"disable_ps",wifi_parms_arg.disable_power_save);
     
     if(wifi_parms_arg.scanmode->count>0){
         if(strcasecmp(wifi_parms_arg.scanmode->sval[0],"Comprehensive") == 0){
@@ -686,10 +686,11 @@ static int do_set_services(int argc, char **argv)
 cJSON * configure_wifi_cb(){
 	cJSON * values = cJSON_CreateObject();
 	char * p=NULL;
-	if ((p = config_alloc_get(NVS_TYPE_STR, "disable_ps")) != NULL) {
-		cJSON_AddBoolToObject(values,"disable_power_save",strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0);
-		FREE_AND_NULL(p);
-	}
+    // disable_ps 
+	// if ((p = config_alloc_get(NVS_TYPE_STR, "disable_ps")) != NULL) {
+	// 	cJSON_AddBoolToObject(values,"disable_power_save",strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0);
+	// 	FREE_AND_NULL(p);
+	// }
     if ((p = config_alloc_get(NVS_TYPE_STR, "wifi_smode")) != NULL) {
         cJSON_AddStringToObject(values,"scanmode",strcasecmp(p,"a") == 0 ?"Comprehensive":"Fast");
         FREE_AND_NULL(p);
@@ -752,7 +753,7 @@ static void register_set_services(){
 
 static void register_set_wifi_parms(){
 	wifi_parms_arg.scanmode = arg_str0(NULL, "scanmode", "Fast|Comprehensive","Sets the WiFi Scan Mode. Use Comprehensive where more than one AP has the same name on different channels. This will ensure that the AP with the strongest signal is chosen.");
-	wifi_parms_arg.disable_power_save = arg_lit0(NULL, "disable_power_save", "Disable Power Saving. This may help if the wifi connection is unstable.");
+    //disable_ps	wifi_parms_arg.disable_power_save = arg_lit0(NULL, "disable_power_save", "Disable Power Saving. This may help if the wifi connection is unstable.");
 	wifi_parms_arg.end=arg_end(2);
 	const esp_console_cmd_t cmd = {
         .command = CFG_TYPE_SYST("wifi"),

+ 12 - 12
components/wifi-manager/wifi_manager.c

@@ -272,18 +272,18 @@ void wifi_manager_init_wifi(){
     ESP_LOGD(TAG,   "Initializing wifi. Setting WiFi mode to WIFI_MODE_NULL");
     ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) );
     ESP_LOGD(TAG,   "Initializing wifi. Starting wifi");
-	char * disable_ps = config_alloc_get_default(NVS_TYPE_STR, "disable_ps", "n", 0);
-
-    if (gpio36_39_used || (disable_ps && strcasecmp(disable_ps,"y")==0)) {
-		if(gpio36_39_used){
-			ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!");
-		}
-		else {
-			ESP_LOGW(TAG, "wifi powersave config is disabled. Disabling WiFi PowerSave!");
-		}
-		esp_wifi_set_ps(WIFI_PS_NONE); 
-	}
-    FREE_AND_NULL(disable_ps);
+	// char * disable_ps = config_alloc_get_default(NVS_TYPE_STR, "disable_ps", "n", 0);
+
+    // if (gpio36_39_used || (disable_ps && strcasecmp(disable_ps,"y")==0)) {
+	// 	if(gpio36_39_used){
+	// 		ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!");
+	// 	}
+	// 	else {
+	// 		ESP_LOGW(TAG, "wifi powersave config is disabled. Disabling WiFi PowerSave!");
+	// 	}
+	// 	esp_wifi_set_ps(WIFI_PS_NONE); 
+	// }
+    // FREE_AND_NULL(disable_ps);
     ESP_ERROR_CHECK( esp_wifi_start() );
 
     taskYIELD();

+ 1 - 1
components/wifi-manager/wifi_manager.h

@@ -145,7 +145,7 @@ extern "C" {
  *  Value: WIFI_PS_MODEM for power save (wifi modem sleep periodically)
  *  Note: Power save is only effective when in STA only mode
  */
-#define DEFAULT_STA_POWER_SAVE 				WIFI_PS_NONE
+#define DEFAULT_STA_POWER_SAVE 				WIFI_PS_MIN_MODEM
 
 /**
  * @brief Defines the maximum length in bytes of a JSON representation of an access point.