From 4d6bac193a1464f3159f2c45b2309c538a6078a6 Mon Sep 17 00:00:00 2001 From: Luc Date: Fri, 21 Jun 2019 18:43:49 +0200 Subject: [PATCH] Fix open network connection (no password) --- esp3d/command.cpp | 2 +- esp3d/config.cpp | 9 ++++++++- esp3d/config.h | 2 +- esp3d/wificonf.cpp | 6 +++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/esp3d/command.cpp b/esp3d/command.cpp index bacedfb4..99901092 100644 --- a/esp3d/command.cpp +++ b/esp3d/command.cpp @@ -1357,7 +1357,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (! (styp == "B" || styp == "S" || styp == "A" || styp == "I" || styp == "F") ) { response = false; } - if (sval.length() == 0) { + if ((sval.length() == 0) && !((pos==EP_AP_PASSWORD) || (pos==EP_STA_PASSWORD))){ response = false; } diff --git a/esp3d/config.cpp b/esp3d/config.cpp index 4ee44399..f9ef7558 100644 --- a/esp3d/config.cpp +++ b/esp3d/config.cpp @@ -692,10 +692,17 @@ bool CONFIG::write_string (int pos, const char * byte_buffer) maxsize = EEPROM_SIZE; break; } - if ( (size_buffer == 0 ) || pos + size_buffer + 1 > EEPROM_SIZE || size_buffer > maxsize || byte_buffer == NULL) { + if ( pos + size_buffer + 1 > EEPROM_SIZE || size_buffer > maxsize ) { LOG ("Error write string\r\n") return false; } + + if (!((pos == EP_STA_PASSWORD) || (pos == EP_AP_PASSWORD))) { + if((size_buffer == 0 ) || (byte_buffer == NULL )){ + LOG ("Error write string\r\n") + return false; + } + } //copy the value(s) EEPROM.begin (EEPROM_SIZE); for (int i = 0; i < size_buffer; i++) { diff --git a/esp3d/config.h b/esp3d/config.h index 8dbed12c..290d7a20 100644 --- a/esp3d/config.h +++ b/esp3d/config.h @@ -19,7 +19,7 @@ */ //version and sources location -#define FW_VERSION "2.1.0.b28" +#define FW_VERSION "2.1.0.b29" #define REPOSITORY "https://github.com/luc-github/ESP3D" //Customize ESP3D //////////////////////////////////////////////////////////////////////// diff --git a/esp3d/wificonf.cpp b/esp3d/wificonf.cpp index c6a10ce2..e97cee9a 100644 --- a/esp3d/wificonf.cpp +++ b/esp3d/wificonf.cpp @@ -467,7 +467,11 @@ bool WIFI_CONFIG::Setup (bool force_ap) #else esp_wifi_set_protocol (ESP_IF_WIFI_STA, bflag); #endif - WiFi.begin (sbuf, pwd); + if (strlen(pwd) > 0){ + WiFi.begin (sbuf, pwd); + } else { + WiFi.begin (sbuf); + } delay (100); #ifdef ARDUINO_ARCH_ESP8266 WiFi.setSleepMode ( (WiFiSleepType_t) sleep_mode);