From 13c4a2e6fcdb992b3d15cbc949a6aeb567a8d2b8 Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Thu, 9 Jan 2020 15:16:31 +0100 Subject: [PATCH] Astyle + fix reset_settings warning --- src/command.cpp | 2436 ++++++++++++++++++++++------------------ src/esp3dlib.cpp | 24 +- src/esp3dlib.h | 4 +- src/esp3dlibconfig.cpp | 38 +- src/esp3dlibconfig.h | 13 +- src/espcom.cpp | 99 +- src/espcom.h | 16 +- src/nofile.h | 608 +++++----- src/sd_ESP32.cpp | 254 +++-- src/sd_ESP32.h | 11 +- src/serial2socket.cpp | 136 ++- src/serial2socket.h | 7 +- src/web_server.cpp | 483 ++++---- src/web_server.h | 7 +- src/wificonfig.cpp | 185 +-- src/wificonfig.h | 5 +- src/wifiservices.cpp | 83 +- src/wifiservices.h | 5 +- 18 files changed, 2420 insertions(+), 1994 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index f231a81..154a3d4 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -82,642 +82,789 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen //manage parameters String parameter; switch (cmd) { - case 0: - espresponse->println ("[List of ESP3D commands]"); - espresponse->println ("[ESP] - display this help"); - espresponse->println ("[ESP100](SSID) - display/set STA SSID"); - espresponse->println ("[ESP101](Password) - set STA password"); - espresponse->println ("[ESP102](Mode) - display/set STA IP mode (DHCP/STATIC)"); - espresponse->println ("[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW "); - espresponse->println ("[ESP105](SSID) - display/set AP SSID"); - espresponse->println ("[ESP106](Password) - set AP password"); - espresponse->println ("[ESP107](IP) - display/set AP IP"); - espresponse->println ("[ESP108](Chanel) - display/set AP chanel"); - espresponse->println ("[ESP110](State) - display/set radio state which can be STA, AP, OFF"); - espresponse->println ("[ESP111]display current IP"); - espresponse->println ("[ESP112](Hostname) - display/set Hostname"); - espresponse->println ("[ESP120](State) - display/set HTTP state which can be ON, OFF"); - espresponse->println ("[ESP121](Port) - display/set HTTP port "); - espresponse->println ("[ESP200] - display SD Card Status"); - espresponse->println ("[ESP400] - display ESP3D settings in JSON"); - espresponse->println ("[ESP401]P=(position) T=(type) V=(value) - Set specific setting"); - espresponse->println ("[ESP410] - display available AP list (limited to 30) in JSON"); - espresponse->println ("[ESP420] - display ESP3D current status"); - espresponse->println ("[ESP444](Cmd) - set ESP3D state (RESET/RESTART)"); + case 0: + espresponse->println ("[List of ESP3D commands]"); + espresponse->println ("[ESP] - display this help"); + espresponse->println ("[ESP100](SSID) - display/set STA SSID"); + espresponse->println ("[ESP101](Password) - set STA password"); + espresponse->println ("[ESP102](Mode) - display/set STA IP mode (DHCP/STATIC)"); + espresponse->println ("[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW "); + espresponse->println ("[ESP105](SSID) - display/set AP SSID"); + espresponse->println ("[ESP106](Password) - set AP password"); + espresponse->println ("[ESP107](IP) - display/set AP IP"); + espresponse->println ("[ESP108](Chanel) - display/set AP chanel"); + espresponse->println ("[ESP110](State) - display/set radio state which can be STA, AP, OFF"); + espresponse->println ("[ESP111]display current IP"); + espresponse->println ("[ESP112](Hostname) - display/set Hostname"); + espresponse->println ("[ESP120](State) - display/set HTTP state which can be ON, OFF"); + espresponse->println ("[ESP121](Port) - display/set HTTP port "); + espresponse->println ("[ESP200] - display SD Card Status"); + espresponse->println ("[ESP400] - display ESP3D settings in JSON"); + espresponse->println ("[ESP401]P=(position) T=(type) V=(value) - Set specific setting"); + espresponse->println ("[ESP410] - display available AP list (limited to 30) in JSON"); + espresponse->println ("[ESP420] - display ESP3D current status"); + espresponse->println ("[ESP444](Cmd) - set ESP3D state (RESET/RESTART)"); #ifdef AUTHENTICATION_FEATURE - espresponse->println ("[ESP550](Password) - set admin password"); - espresponse->println ("[ESP555](Password) - set user password"); + espresponse->println ("[ESP550](Password) - set admin password"); + espresponse->println ("[ESP555](Password) - set user password"); #endif //AUTHENTICATION_FEATURE - espresponse->println ("[ESP710]FORMAT - Format ESP Filesystem"); - espresponse->println ("[ESP800] - display FW Informations"); - break; - - //STA SSID - //[ESP100][pwd=] - case 100: - { -#ifdef AUTHENTICATION_FEATURE - if (auth_type == LEVEL_GUEST) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif //AUTHENTICATION_FEATURE - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - String defV = DEFAULT_STA_SSID; - espresponse->println(prefs.getString(STA_SSID_ENTRY, defV).c_str()); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - if (!WiFiConfig::isSSIDValid (parameter.c_str() ) ) { - if(espresponse)espresponse->println ("Error: Incorrect SSID!"); - response = false; - } else { - Preferences prefs; - prefs.begin(NAMESPACE, false); - if (prefs.putString(STA_SSID_ENTRY, parameter) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } - } - break; - //STA Password - //[ESP101] - case 101: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if (!WiFiConfig::isPasswordValid (parameter.c_str() ) ) { - if(espresponse)espresponse->println ("Error: Incorrect password!"); - response = false; - return false; - } else { - Preferences prefs; - prefs.begin(NAMESPACE, false); - if (prefs.putString(STA_PWD_ENTRY, parameter) != parameter.length()){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } - break; - //Get/Change STA IP mode (DHCP/STATIC) - //[ESP102] - case 102: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - int8_t resp = prefs.getChar(STA_IP_MODE_ENTRY, DEFAULT_STA_IP_MODE); - if (resp == DHCP_MODE) espresponse->println("DHCP"); - else if (resp == STATIC_MODE) espresponse->println("STATIC"); - else espresponse->println("???"); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter.toUpperCase(); - if (!((parameter == "STATIC") || (parameter == "DHCP"))) { - if(espresponse)espresponse->println ("Error: only STATIC or DHCP mode supported!"); - response = false; - return false; - } else { - Preferences prefs; - prefs.begin(NAMESPACE, false); - int8_t bbuf = (parameter == "DHCP")?DHCP_MODE:STATIC_MODE; - if (prefs.putChar(STA_IP_MODE_ENTRY, bbuf) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } - } - break; - //Get/Change STA IP/Mask/GW - //[ESP103]IP= MSK= GW= - case 103: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - //IP - String defV = DEFAULT_STA_IP; - int32_t IP = prefs.getInt(STA_IP_ENTRY, WiFiConfig::IP_int_from_string(defV)); - //GW - defV = DEFAULT_STA_GW; - int32_t GW = prefs.getInt(STA_GW_ENTRY, WiFiConfig::IP_int_from_string(defV)); - //MK - defV = DEFAULT_STA_MK; - int32_t MK = prefs.getInt(STA_MK_ENTRY, WiFiConfig::IP_int_from_string(defV)); - defV = "IP:" + WiFiConfig::IP_string_from_int(IP) + ", GW:" + WiFiConfig::IP_string_from_int(GW) + ", MSK:" + WiFiConfig::IP_string_from_int(MK); - espresponse->println(defV.c_str()); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif + espresponse->println ("[ESP710]FORMAT - Format ESP Filesystem"); + espresponse->println ("[ESP800] - display FW Informations"); + break; - String IP = get_param (cmd_params, "IP=", false); - String GW = get_param (cmd_params, "GW=", false); - String MSK = get_param (cmd_params, "MSK=", false); - Serial.println(IP); - Serial.println(GW); - if ( !WiFiConfig::isValidIP(IP.c_str())) { - if(espresponse)espresponse->println ("Error: Incorrect IP!"); - response = false; - return false; - } - if ( !WiFiConfig::isValidIP(GW.c_str())) { - if(espresponse)espresponse->println ("Error: Incorrect Gateway!"); - response = false; - return false; - } - if ( !WiFiConfig::isValidIP(MSK.c_str())) { - if(espresponse)espresponse->println ("Error: Incorrect Mask!"); - response = false; - return false; - } - Preferences prefs; - prefs.begin(NAMESPACE, false); - if ((prefs.putInt(STA_IP_ENTRY, WiFiConfig::IP_int_from_string(IP)) == 0) || - (prefs.putInt(STA_GW_ENTRY, WiFiConfig::IP_int_from_string(GW)) == 0) || - (prefs.putInt(STA_MK_ENTRY, WiFiConfig::IP_int_from_string(MSK)) == 0)){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } + //STA SSID + //[ESP100][pwd=] + case 100: { +#ifdef AUTHENTICATION_FEATURE + if (auth_type == LEVEL_GUEST) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); } - break; - //Change AP SSID - //[ESP105] - case 105: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - String defV = DEFAULT_AP_SSID; - espresponse->println(prefs.getString(AP_SSID_ENTRY, defV).c_str()); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - if (!WiFiConfig::isSSIDValid (parameter.c_str() ) ) { - if(espresponse)espresponse->println ("Error: Incorrect SSID!"); - response = false; - } - Preferences prefs; - prefs.begin(NAMESPACE, false); - if (prefs.putString(AP_SSID_ENTRY, parameter) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } - break; - //Change AP Password - //[ESP106] - case 106: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if (!WiFiConfig::isPasswordValid (parameter.c_str() ) ) { - if(espresponse)espresponse->println ("Error: Incorrect password!"); - response = false; - return false; - } + return false; + } +#endif //AUTHENTICATION_FEATURE + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { Preferences prefs; - prefs.begin(NAMESPACE, false); - if (prefs.putString(AP_PWD_ENTRY, parameter) != parameter.length()){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); + prefs.begin(NAMESPACE, true); + String defV = DEFAULT_STA_SSID; + espresponse->println(prefs.getString(STA_SSID_ENTRY, defV).c_str()); prefs.end(); - - } - break; - //Change AP IP - //[ESP107] - case 107: - { + } else { //set #ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - //IP - String defV = DEFAULT_AP_IP; - int32_t IP = prefs.getInt(AP_IP_ENTRY, WiFiConfig::IP_int_from_string(defV)); - espresponse->println(WiFiConfig::IP_string_from_int(IP).c_str()); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - if ( !WiFiConfig::isValidIP(parameter.c_str())) { - if(espresponse)espresponse->println ("Error: Incorrect IP!"); - response = false; - return false; + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); } - Preferences prefs; - prefs.begin(NAMESPACE, false); - if (prefs.putInt(AP_IP_ENTRY, WiFiConfig::IP_int_from_string(parameter)) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } - break; - //Change AP channel - //[ESP108] - case 108: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - int8_t channel = prefs.getChar(AP_CHANNEL_ENTRY, DEFAULT_AP_CHANNEL); - espresponse->println(String(channel).c_str()); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - int8_t bbuf = parameter.toInt(); - if ((bbuf > MAX_CHANNEL) || (bbuf < MIN_CHANNEL)) { - if(espresponse)espresponse->println ("Error: Incorrect channel!"); - response = false; - return false; - } - Preferences prefs; - prefs.begin(NAMESPACE, false); - if (prefs.putChar(AP_CHANNEL_ENTRY, bbuf) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } - break; - //Set radio state at boot which can be STA, AP, OFF - //[ESP110] - case 110: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - int8_t wifiMode = prefs.getChar(ESP_RADIO_MODE, DEFAULT_RADIO_MODE); - if (wifiMode == ESP_RADIO_OFF) espresponse->println("OFF"); - else if (wifiMode == ESP_WIFI_AP) espresponse->println("AP"); - else if (wifiMode == ESP_WIFI_STA) espresponse->println("STA"); - else espresponse->println("??"); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter.toUpperCase(); - if (!( - (parameter == "STA") || (parameter == "AP") || - (parameter == "OFF"))) { - - if(espresponse)espresponse->println ("Error: only " - "STA or AP or " - "OFF mode supported!"); - response = false; - return false; - } else { - Preferences prefs; - prefs.begin(NAMESPACE, false); - int8_t bbuf = ESP_RADIO_OFF; - - if(parameter == "STA")bbuf = ESP_WIFI_STA; - if(parameter == "AP")bbuf = ESP_WIFI_AP; - if (prefs.putChar(ESP_RADIO_MODE, bbuf) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } - } - break; - //Get current IP - //[ESP111] - case 111: - { - if (!espresponse) return false; - String currentIP = cmd_params; - if (WiFi.getMode() == WIFI_STA) { - currentIP += WiFi.localIP().toString(); - } else { - currentIP += WiFi.softAPIP().toString(); - } - espresponse->println (currentIP.c_str()); - } - break; - - //Get/Set hostname - //[ESP112] - case 112: { -#ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); return false; - } + } #endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //Get hostname - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - String defV = DEFAULT_HOSTNAME; - espresponse->println(prefs.getString(HOSTNAME_ENTRY, defV).c_str()); - prefs.end(); - } else { //set host name -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - if (!WiFiConfig::isHostnameValid (parameter.c_str() ) ) { - if(espresponse)espresponse->println ("Error: Incorrect hostname!"); + if (!WiFiConfig::isSSIDValid (parameter.c_str() ) ) { + if(espresponse) { + espresponse->println ("Error: Incorrect SSID!"); + } response = false; - } else { + } else { Preferences prefs; prefs.begin(NAMESPACE, false); - if (prefs.putString(HOSTNAME_ENTRY, parameter) == 0){ + if (prefs.putString(STA_SSID_ENTRY, parameter) == 0) { response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); } + prefs.end(); } } - break; - //Set HTTP state which can be ON, OFF - //[ESP120]pwd= - case 120: - { + } + break; + //STA Password + //[ESP101] + case 101: { #ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - int8_t Mode = prefs.getChar(HTTP_ENABLE_ENTRY, DEFAULT_HTTP_STATE); - espresponse->println((Mode == 0)?"OFF":"ON"); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - parameter.toUpperCase(); - if (!((parameter == "ON") || (parameter == "OFF"))) { - if(espresponse)espresponse->println ("Error: only ON or OFF mode supported!"); - response = false; - return false; - } else { - Preferences prefs; - prefs.begin(NAMESPACE, false); - int8_t bbuf = (parameter == "ON")?1:0; - if (prefs.putChar(HTTP_ENABLE_ENTRY, bbuf) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - } + if (auth_type != LEVEL_ADMIN) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); } - break; - //Set HTTP port - //[ESP121]pwd= - case 121: - { -#ifdef ENABLE_AUTHENTICATION - if (auth_type == LEVEL_GUEST) { - if(espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } + return false; + } #endif - parameter = get_param (cmd_params, "", true); - if ((parameter.length() == 0) && !espresponse) return false; - //get - if (parameter.length() == 0) { - Preferences prefs; - prefs.begin(NAMESPACE, true); - int port = prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT); - espresponse->println(String(port).c_str()); - prefs.end(); - } else { //set -#ifdef ENABLE_AUTHENTICATION - if (auth_type != LEVEL_ADMIN) { - if (espresponse)espresponse->println ("Error: Wrong authentication!"); - return false; - } -#endif - int ibuf = parameter.toInt(); - if ((ibuf > MAX_HTTP_PORT) || (ibuf < MIN_HTTP_PORT)) { - if(espresponse)espresponse->println ("Error: Incorrect port!"); - response = false; - return false; - } - Preferences prefs; - prefs.begin(NAMESPACE, false); - - if (prefs.putUShort(HTTP_PORT_ENTRY, ibuf) == 0){ - response = false; - if(espresponse)espresponse->println ("Error: Set failed!"); - } else if(espresponse)espresponse->println ("ok"); - prefs.end(); - } - + parameter = get_param (cmd_params, "", true); + if (!WiFiConfig::isPasswordValid (parameter.c_str() ) ) { + if(espresponse) { + espresponse->println ("Error: Incorrect password!"); } - break; - //Get SD Card Status - //[ESP200] - case 200: - { - if (!espresponse) return false; - String resp = "No SD card"; -#if defined(SDSUPPORT) - ESP_SD card; - int8_t state = card.card_status(); - if (state == -1)resp="Busy"; - else if (state == 1)resp="SD card detected"; - else resp="No SD card"; -#endif - espresponse->println (resp.c_str()); - } - break; - //Get full ESP3D settings - //[ESP400] - case 400: - { - String v; - String defV; + response = false; + return false; + } else { Preferences prefs; - if (!espresponse) return false; -#ifdef AUTHENTICATION_FEATURE - if (auth_type == LEVEL_GUEST) return false; + prefs.begin(NAMESPACE, false); + if (prefs.putString(STA_PWD_ENTRY, parameter) != parameter.length()) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + break; + //Get/Change STA IP mode (DHCP/STATIC) + //[ESP102] + case 102: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } #endif - int8_t vi; - espresponse->print("{\"EEPROM\":["); + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; prefs.begin(NAMESPACE, true); - //1 - Hostname - defV = DEFAULT_HOSTNAME; - v = prefs.getString(HOSTNAME_ENTRY, defV); - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (HOSTNAME_ENTRY); - espresponse->print ("\",\"T\":\"S\",\"V\":\""); - espresponse->print (v.c_str()); - espresponse->print ("\",\"H\":\"Hostname\" ,\"S\":\""); - espresponse->print (String(MAX_HOSTNAME_LENGTH).c_str()); - espresponse->print ("\", \"M\":\""); - espresponse->print (String(MIN_HOSTNAME_LENGTH).c_str()); - espresponse->print ("\"}"); - espresponse->print (","); - - //2 - http protocol mode - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (HTTP_ENABLE_ENTRY); - espresponse->print ("\",\"T\":\"B\",\"V\":\""); - vi = prefs.getChar(HTTP_ENABLE_ENTRY, 1); - espresponse->print (String(vi).c_str()); - espresponse->print ("\",\"H\":\"HTTP protocol\",\"O\":[{\"Enabled\":\"1\"},{\"Disabled\":\"0\"}]}"); - espresponse->print (","); - - //3 - http port - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (HTTP_PORT_ENTRY); - espresponse->print ("\",\"T\":\"I\",\"V\":\""); - espresponse->print (String(prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT)).c_str()); - espresponse->print ("\",\"H\":\"HTTP Port\",\"S\":\""); - espresponse->print (String(MAX_HTTP_PORT).c_str()); - espresponse->print ("\",\"M\":\""); - espresponse->print (String(MIN_HTTP_PORT).c_str()); - espresponse->print ("\"}"); - espresponse->print (","); - - //TODO - //4 - telnet protocol mode - /* espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (TELNET_ENABLE_ENTRY); - espresponse->print ("\",\"T\":\"B\",\"V\":\""); - vi = prefs.getChar(TELNET_ENABLE_ENTRY, 0); - espresponse->print (String(vi).c_str()); - espresponse->print ("\",\"H\":\"Telnet protocol\",\"O\":[{\"Enabled\":\"1\"},{\"Disabled\":\"0\"}]}"); - espresponse->print (",");*/ - - //5 - telnet Port + int8_t resp = prefs.getChar(STA_IP_MODE_ENTRY, DEFAULT_STA_IP_MODE); + if (resp == DHCP_MODE) { + espresponse->println("DHCP"); + } else if (resp == STATIC_MODE) { + espresponse->println("STATIC"); + } else { + espresponse->println("???"); + } + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter.toUpperCase(); + if (!((parameter == "STATIC") || (parameter == "DHCP"))) { + if(espresponse) { + espresponse->println ("Error: only STATIC or DHCP mode supported!"); + } + response = false; + return false; + } else { + Preferences prefs; + prefs.begin(NAMESPACE, false); + int8_t bbuf = (parameter == "DHCP")?DHCP_MODE:STATIC_MODE; + if (prefs.putChar(STA_IP_MODE_ENTRY, bbuf) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + } + break; + //Get/Change STA IP/Mask/GW + //[ESP103]IP= MSK= GW= + case 103: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + espresponse->println ("Error: Wrong authentication!"); + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + //IP + String defV = DEFAULT_STA_IP; + int32_t IP = prefs.getInt(STA_IP_ENTRY, WiFiConfig::IP_int_from_string(defV)); + //GW + defV = DEFAULT_STA_GW; + int32_t GW = prefs.getInt(STA_GW_ENTRY, WiFiConfig::IP_int_from_string(defV)); + //MK + defV = DEFAULT_STA_MK; + int32_t MK = prefs.getInt(STA_MK_ENTRY, WiFiConfig::IP_int_from_string(defV)); + defV = "IP:" + WiFiConfig::IP_string_from_int(IP) + ", GW:" + WiFiConfig::IP_string_from_int(GW) + ", MSK:" + WiFiConfig::IP_string_from_int(MK); + espresponse->println(defV.c_str()); + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + + String IP = get_param (cmd_params, "IP=", false); + String GW = get_param (cmd_params, "GW=", false); + String MSK = get_param (cmd_params, "MSK=", false); + Serial.println(IP); + Serial.println(GW); + if ( !WiFiConfig::isValidIP(IP.c_str())) { + if(espresponse) { + espresponse->println ("Error: Incorrect IP!"); + } + response = false; + return false; + } + if ( !WiFiConfig::isValidIP(GW.c_str())) { + if(espresponse) { + espresponse->println ("Error: Incorrect Gateway!"); + } + response = false; + return false; + } + if ( !WiFiConfig::isValidIP(MSK.c_str())) { + if(espresponse) { + espresponse->println ("Error: Incorrect Mask!"); + } + response = false; + return false; + } + Preferences prefs; + prefs.begin(NAMESPACE, false); + if ((prefs.putInt(STA_IP_ENTRY, WiFiConfig::IP_int_from_string(IP)) == 0) || + (prefs.putInt(STA_GW_ENTRY, WiFiConfig::IP_int_from_string(GW)) == 0) || + (prefs.putInt(STA_MK_ENTRY, WiFiConfig::IP_int_from_string(MSK)) == 0)) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + break; + //Change AP SSID + //[ESP105] + case 105: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + String defV = DEFAULT_AP_SSID; + espresponse->println(prefs.getString(AP_SSID_ENTRY, defV).c_str()); + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + if (!WiFiConfig::isSSIDValid (parameter.c_str() ) ) { + if(espresponse) { + espresponse->println ("Error: Incorrect SSID!"); + } + response = false; + } + Preferences prefs; + prefs.begin(NAMESPACE, false); + if (prefs.putString(AP_SSID_ENTRY, parameter) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + break; + //Change AP Password + //[ESP106] + case 106: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if (!WiFiConfig::isPasswordValid (parameter.c_str() ) ) { + if(espresponse) { + espresponse->println ("Error: Incorrect password!"); + } + response = false; + return false; + } + Preferences prefs; + prefs.begin(NAMESPACE, false); + if (prefs.putString(AP_PWD_ENTRY, parameter) != parameter.length()) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + + } + break; + //Change AP IP + //[ESP107] + case 107: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + //IP + String defV = DEFAULT_AP_IP; + int32_t IP = prefs.getInt(AP_IP_ENTRY, WiFiConfig::IP_int_from_string(defV)); + espresponse->println(WiFiConfig::IP_string_from_int(IP).c_str()); + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + if ( !WiFiConfig::isValidIP(parameter.c_str())) { + if(espresponse) { + espresponse->println ("Error: Incorrect IP!"); + } + response = false; + return false; + } + Preferences prefs; + prefs.begin(NAMESPACE, false); + if (prefs.putInt(AP_IP_ENTRY, WiFiConfig::IP_int_from_string(parameter)) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + break; + //Change AP channel + //[ESP108] + case 108: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + int8_t channel = prefs.getChar(AP_CHANNEL_ENTRY, DEFAULT_AP_CHANNEL); + espresponse->println(String(channel).c_str()); + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + int8_t bbuf = parameter.toInt(); + if ((bbuf > MAX_CHANNEL) || (bbuf < MIN_CHANNEL)) { + if(espresponse) { + espresponse->println ("Error: Incorrect channel!"); + } + response = false; + return false; + } + Preferences prefs; + prefs.begin(NAMESPACE, false); + if (prefs.putChar(AP_CHANNEL_ENTRY, bbuf) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + break; + //Set radio state at boot which can be STA, AP, OFF + //[ESP110] + case 110: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + int8_t wifiMode = prefs.getChar(ESP_RADIO_MODE, DEFAULT_RADIO_MODE); + if (wifiMode == ESP_RADIO_OFF) { + espresponse->println("OFF"); + } else if (wifiMode == ESP_WIFI_AP) { + espresponse->println("AP"); + } else if (wifiMode == ESP_WIFI_STA) { + espresponse->println("STA"); + } else { + espresponse->println("??"); + } + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter.toUpperCase(); + if (!( + (parameter == "STA") || (parameter == "AP") || + (parameter == "OFF"))) { + + if(espresponse)espresponse->println ("Error: only " + "STA or AP or " + "OFF mode supported!"); + response = false; + return false; + } else { + Preferences prefs; + prefs.begin(NAMESPACE, false); + int8_t bbuf = ESP_RADIO_OFF; + + if(parameter == "STA") { + bbuf = ESP_WIFI_STA; + } + if(parameter == "AP") { + bbuf = ESP_WIFI_AP; + } + if (prefs.putChar(ESP_RADIO_MODE, bbuf) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + } + break; + //Get current IP + //[ESP111] + case 111: { + if (!espresponse) { + return false; + } + String currentIP = cmd_params; + if (WiFi.getMode() == WIFI_STA) { + currentIP += WiFi.localIP().toString(); + } else { + currentIP += WiFi.softAPIP().toString(); + } + espresponse->println (currentIP.c_str()); + } + break; + + //Get/Set hostname + //[ESP112] + case 112: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //Get hostname + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + String defV = DEFAULT_HOSTNAME; + espresponse->println(prefs.getString(HOSTNAME_ENTRY, defV).c_str()); + prefs.end(); + } else { //set host name +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + if (!WiFiConfig::isHostnameValid (parameter.c_str() ) ) { + if(espresponse) { + espresponse->println ("Error: Incorrect hostname!"); + } + response = false; + } else { + Preferences prefs; + prefs.begin(NAMESPACE, false); + if (prefs.putString(HOSTNAME_ENTRY, parameter) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + } + break; + //Set HTTP state which can be ON, OFF + //[ESP120]pwd= + case 120: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + int8_t Mode = prefs.getChar(HTTP_ENABLE_ENTRY, DEFAULT_HTTP_STATE); + espresponse->println((Mode == 0)?"OFF":"ON"); + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter.toUpperCase(); + if (!((parameter == "ON") || (parameter == "OFF"))) { + if(espresponse) { + espresponse->println ("Error: only ON or OFF mode supported!"); + } + response = false; + return false; + } else { + Preferences prefs; + prefs.begin(NAMESPACE, false); + int8_t bbuf = (parameter == "ON")?1:0; + if (prefs.putChar(HTTP_ENABLE_ENTRY, bbuf) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + } + } + break; + //Set HTTP port + //[ESP121]pwd= + case 121: { +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + if(espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + parameter = get_param (cmd_params, "", true); + if ((parameter.length() == 0) && !espresponse) { + return false; + } + //get + if (parameter.length() == 0) { + Preferences prefs; + prefs.begin(NAMESPACE, true); + int port = prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT); + espresponse->println(String(port).c_str()); + prefs.end(); + } else { //set +#ifdef ENABLE_AUTHENTICATION + if (auth_type != LEVEL_ADMIN) { + if (espresponse) { + espresponse->println ("Error: Wrong authentication!"); + } + return false; + } +#endif + int ibuf = parameter.toInt(); + if ((ibuf > MAX_HTTP_PORT) || (ibuf < MIN_HTTP_PORT)) { + if(espresponse) { + espresponse->println ("Error: Incorrect port!"); + } + response = false; + return false; + } + Preferences prefs; + prefs.begin(NAMESPACE, false); + + if (prefs.putUShort(HTTP_PORT_ENTRY, ibuf) == 0) { + response = false; + if(espresponse) { + espresponse->println ("Error: Set failed!"); + } + } else if(espresponse) { + espresponse->println ("ok"); + } + prefs.end(); + } + + } + break; + //Get SD Card Status + //[ESP200] + case 200: { + if (!espresponse) { + return false; + } + String resp = "No SD card"; +#if defined(SDSUPPORT) + ESP_SD card; + int8_t state = card.card_status(); + if (state == -1) { + resp="Busy"; + } else if (state == 1) { + resp="SD card detected"; + } else { + resp="No SD card"; + } +#endif + espresponse->println (resp.c_str()); + } + break; + //Get full ESP3D settings + //[ESP400] + case 400: { + String v; + String defV; + Preferences prefs; + if (!espresponse) { + return false; + } +#ifdef AUTHENTICATION_FEATURE + if (auth_type == LEVEL_GUEST) { + return false; + } +#endif + int8_t vi; + espresponse->print("{\"EEPROM\":["); + prefs.begin(NAMESPACE, true); + //1 - Hostname + defV = DEFAULT_HOSTNAME; + v = prefs.getString(HOSTNAME_ENTRY, defV); + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (HOSTNAME_ENTRY); + espresponse->print ("\",\"T\":\"S\",\"V\":\""); + espresponse->print (v.c_str()); + espresponse->print ("\",\"H\":\"Hostname\" ,\"S\":\""); + espresponse->print (String(MAX_HOSTNAME_LENGTH).c_str()); + espresponse->print ("\", \"M\":\""); + espresponse->print (String(MIN_HOSTNAME_LENGTH).c_str()); + espresponse->print ("\"}"); + espresponse->print (","); + + //2 - http protocol mode + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (HTTP_ENABLE_ENTRY); + espresponse->print ("\",\"T\":\"B\",\"V\":\""); + vi = prefs.getChar(HTTP_ENABLE_ENTRY, 1); + espresponse->print (String(vi).c_str()); + espresponse->print ("\",\"H\":\"HTTP protocol\",\"O\":[{\"Enabled\":\"1\"},{\"Disabled\":\"0\"}]}"); + espresponse->print (","); + + //3 - http port + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (HTTP_PORT_ENTRY); + espresponse->print ("\",\"T\":\"I\",\"V\":\""); + espresponse->print (String(prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT)).c_str()); + espresponse->print ("\",\"H\":\"HTTP Port\",\"S\":\""); + espresponse->print (String(MAX_HTTP_PORT).c_str()); + espresponse->print ("\",\"M\":\""); + espresponse->print (String(MIN_HTTP_PORT).c_str()); + espresponse->print ("\"}"); + espresponse->print (","); + + //TODO + //4 - telnet protocol mode + /* espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (TELNET_ENABLE_ENTRY); + espresponse->print ("\",\"T\":\"B\",\"V\":\""); + vi = prefs.getChar(TELNET_ENABLE_ENTRY, 0); + espresponse->print (String(vi).c_str()); + espresponse->print ("\",\"H\":\"Telnet protocol\",\"O\":[{\"Enabled\":\"1\"},{\"Disabled\":\"0\"}]}"); + espresponse->print (",");*/ + + //5 - telnet Port /* espresponse->print ("{\"F\":\"network\",\"P\":\""); espresponse->print (TELNET_PORT_ENTRY); espresponse->print ("\",\"T\":\"I\",\"V\":\""); @@ -728,255 +875,264 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen espresponse->print (String(MIN_TELNET_PORT).c_str()); espresponse->print ("\"}"); espresponse->print (",");*/ - - //6 - wifi mode - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (ESP_RADIO_MODE); - espresponse->print ("\",\"T\":\"B\",\"V\":\""); - vi = prefs.getChar(ESP_RADIO_MODE, DEFAULT_RADIO_MODE); - espresponse->print (String(vi).c_str()); - espresponse->print ("\",\"H\":\"Wifi mode\",\"O\":[{\"STA\":\"1\"},{\"AP\":\"2\"},{\"None\":\"0\"}]}"); - espresponse->print (","); - //7 - STA SSID - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (STA_SSID_ENTRY); - espresponse->print ("\",\"T\":\"S\",\"V\":\""); - defV = DEFAULT_STA_SSID; - espresponse->print (prefs.getString(STA_SSID_ENTRY, defV).c_str()); - espresponse->print ("\",\"S\":\""); - espresponse->print (String(MAX_SSID_LENGTH).c_str()); - espresponse->print ("\",\"H\":\"Station SSID\",\"M\":\""); - espresponse->print (String(MIN_SSID_LENGTH).c_str()); + //6 - wifi mode + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (ESP_RADIO_MODE); + espresponse->print ("\",\"T\":\"B\",\"V\":\""); + vi = prefs.getChar(ESP_RADIO_MODE, DEFAULT_RADIO_MODE); + espresponse->print (String(vi).c_str()); + espresponse->print ("\",\"H\":\"Wifi mode\",\"O\":[{\"STA\":\"1\"},{\"AP\":\"2\"},{\"None\":\"0\"}]}"); + espresponse->print (","); + + //7 - STA SSID + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (STA_SSID_ENTRY); + espresponse->print ("\",\"T\":\"S\",\"V\":\""); + defV = DEFAULT_STA_SSID; + espresponse->print (prefs.getString(STA_SSID_ENTRY, defV).c_str()); + espresponse->print ("\",\"S\":\""); + espresponse->print (String(MAX_SSID_LENGTH).c_str()); + espresponse->print ("\",\"H\":\"Station SSID\",\"M\":\""); + espresponse->print (String(MIN_SSID_LENGTH).c_str()); + espresponse->print ("\"}"); + espresponse->print (","); + + //8 - STA password + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (STA_PWD_ENTRY); + espresponse->print ("\",\"T\":\"S\",\"V\":\""); + espresponse->print (HIDDEN_PASSWORD); + espresponse->print ("\",\"S\":\""); + espresponse->print (String(MAX_PASSWORD_LENGTH).c_str()); + espresponse->print ("\",\"H\":\"Station Password\",\"M\":\""); + espresponse->print (String(MIN_PASSWORD_LENGTH).c_str()); + espresponse->print ("\"}"); + espresponse->print (","); + + // 9 - STA IP mode + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (STA_IP_MODE_ENTRY); + espresponse->print ("\",\"T\":\"B\",\"V\":\""); + espresponse->print (String(prefs.getChar(STA_IP_MODE_ENTRY, DEFAULT_STA_IP_MODE)).c_str()); + espresponse->print ("\",\"H\":\"Station IP Mode\",\"O\":[{\"DHCP\":\"0\"},{\"Static\":\"1\"}]}"); + espresponse->print (","); + + //10-STA static IP + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (STA_IP_ENTRY); + espresponse->print ("\",\"T\":\"A\",\"V\":\""); + espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(STA_IP_ENTRY, 0)).c_str()); + espresponse->print ("\",\"H\":\"Station Static IP\"}"); + espresponse->print (","); + + //11-STA static Gateway + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (STA_GW_ENTRY); + espresponse->print ("\",\"T\":\"A\",\"V\":\""); + espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(STA_GW_ENTRY, 0)).c_str()); + espresponse->print ("\",\"H\":\"Station Static Gateway\"}"); + espresponse->print (","); + + //12-STA static Mask + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (STA_MK_ENTRY); + espresponse->print ("\",\"T\":\"A\",\"V\":\""); + espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(STA_MK_ENTRY, 0)).c_str()); + espresponse->print ("\",\"H\":\"Station Static Mask\"}"); + espresponse->print (","); + + //13 - AP SSID + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (AP_SSID_ENTRY); + espresponse->print ("\",\"T\":\"S\",\"V\":\""); + defV = DEFAULT_AP_SSID; + espresponse->print (prefs.getString(AP_SSID_ENTRY, defV).c_str()); + espresponse->print ("\",\"S\":\""); + espresponse->print (String(MAX_SSID_LENGTH).c_str()); + espresponse->print ("\",\"H\":\"AP SSID\",\"M\":\""); + espresponse->print (String(MIN_SSID_LENGTH).c_str()); + espresponse->print ("\"}"); + espresponse->print (","); + + //14 - AP password + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (AP_PWD_ENTRY); + espresponse->print ("\",\"T\":\"S\",\"V\":\""); + espresponse->print (HIDDEN_PASSWORD); + espresponse->print ("\",\"S\":\""); + espresponse->print (String(MAX_PASSWORD_LENGTH).c_str()); + espresponse->print ("\",\"H\":\"AP Password\",\"M\":\""); + espresponse->print (String(MIN_PASSWORD_LENGTH).c_str()); + espresponse->print ("\"}"); + espresponse->print (","); + + //15 - AP static IP + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (AP_IP_ENTRY); + espresponse->print ("\",\"T\":\"A\",\"V\":\""); + defV = DEFAULT_AP_IP; + espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(AP_IP_ENTRY, WiFiConfig::IP_int_from_string(defV))).c_str()); + espresponse->print ("\",\"H\":\"AP Static IP\"}"); + espresponse->print (","); + + //16 - AP Channel + espresponse->print ("{\"F\":\"network\",\"P\":\""); + espresponse->print (AP_CHANNEL_ENTRY); + espresponse->print ("\",\"T\":\"B\",\"V\":\""); + espresponse->print (String(prefs.getChar(AP_CHANNEL_ENTRY, DEFAULT_AP_CHANNEL)).c_str()); + espresponse->print ("\",\"H\":\"AP Channel\",\"O\":["); + for (int i = MIN_CHANNEL; i <= MAX_CHANNEL ; i++) { + espresponse->print ("{\""); + espresponse->print (String(i).c_str()); + espresponse->print ("\":\""); + espresponse->print (String(i).c_str()); espresponse->print ("\"}"); - espresponse->print (","); - - //8 - STA password - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (STA_PWD_ENTRY); - espresponse->print ("\",\"T\":\"S\",\"V\":\""); - espresponse->print (HIDDEN_PASSWORD); - espresponse->print ("\",\"S\":\""); - espresponse->print (String(MAX_PASSWORD_LENGTH).c_str()); - espresponse->print ("\",\"H\":\"Station Password\",\"M\":\""); - espresponse->print (String(MIN_PASSWORD_LENGTH).c_str()); - espresponse->print ("\"}"); - espresponse->print (","); - - // 9 - STA IP mode - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (STA_IP_MODE_ENTRY); - espresponse->print ("\",\"T\":\"B\",\"V\":\""); - espresponse->print (String(prefs.getChar(STA_IP_MODE_ENTRY, DEFAULT_STA_IP_MODE)).c_str()); - espresponse->print ("\",\"H\":\"Station IP Mode\",\"O\":[{\"DHCP\":\"0\"},{\"Static\":\"1\"}]}"); - espresponse->print (","); - - //10-STA static IP - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (STA_IP_ENTRY); - espresponse->print ("\",\"T\":\"A\",\"V\":\""); - espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(STA_IP_ENTRY, 0)).c_str()); - espresponse->print ("\",\"H\":\"Station Static IP\"}"); - espresponse->print (","); - - //11-STA static Gateway - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (STA_GW_ENTRY); - espresponse->print ("\",\"T\":\"A\",\"V\":\""); - espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(STA_GW_ENTRY, 0)).c_str()); - espresponse->print ("\",\"H\":\"Station Static Gateway\"}"); - espresponse->print (","); - - //12-STA static Mask - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (STA_MK_ENTRY); - espresponse->print ("\",\"T\":\"A\",\"V\":\""); - espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(STA_MK_ENTRY, 0)).c_str()); - espresponse->print ("\",\"H\":\"Station Static Mask\"}"); - espresponse->print (","); - - //13 - AP SSID - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (AP_SSID_ENTRY); - espresponse->print ("\",\"T\":\"S\",\"V\":\""); - defV = DEFAULT_AP_SSID; - espresponse->print (prefs.getString(AP_SSID_ENTRY, defV).c_str()); - espresponse->print ("\",\"S\":\""); - espresponse->print (String(MAX_SSID_LENGTH).c_str()); - espresponse->print ("\",\"H\":\"AP SSID\",\"M\":\""); - espresponse->print (String(MIN_SSID_LENGTH).c_str()); - espresponse->print ("\"}"); - espresponse->print (","); - - //14 - AP password - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (AP_PWD_ENTRY); - espresponse->print ("\",\"T\":\"S\",\"V\":\""); - espresponse->print (HIDDEN_PASSWORD); - espresponse->print ("\",\"S\":\""); - espresponse->print (String(MAX_PASSWORD_LENGTH).c_str()); - espresponse->print ("\",\"H\":\"AP Password\",\"M\":\""); - espresponse->print (String(MIN_PASSWORD_LENGTH).c_str()); - espresponse->print ("\"}"); - espresponse->print (","); - - //15 - AP static IP - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (AP_IP_ENTRY); - espresponse->print ("\",\"T\":\"A\",\"V\":\""); - defV = DEFAULT_AP_IP; - espresponse->print (WiFiConfig::IP_string_from_int(prefs.getInt(AP_IP_ENTRY, WiFiConfig::IP_int_from_string(defV))).c_str()); - espresponse->print ("\",\"H\":\"AP Static IP\"}"); - espresponse->print (","); - - //16 - AP Channel - espresponse->print ("{\"F\":\"network\",\"P\":\""); - espresponse->print (AP_CHANNEL_ENTRY); - espresponse->print ("\",\"T\":\"B\",\"V\":\""); - espresponse->print (String(prefs.getChar(AP_CHANNEL_ENTRY, DEFAULT_AP_CHANNEL)).c_str()); - espresponse->print ("\",\"H\":\"AP Channel\",\"O\":["); - for (int i = MIN_CHANNEL; i <= MAX_CHANNEL ; i++) { - espresponse->print ("{\""); - espresponse->print (String(i).c_str()); - espresponse->print ("\":\""); - espresponse->print (String(i).c_str()); - espresponse->print ("\"}"); - if (i < MAX_CHANNEL) { - espresponse->print (","); - } + if (i < MAX_CHANNEL) { + espresponse->print (","); } - espresponse->print ("]}"); - - espresponse->println ("]}"); - prefs.end(); - } - break; - //Set EEPROM setting - //[ESP401]P= T= V= pwd= - case 401: - { + } + espresponse->print ("]}"); + + espresponse->println ("]}"); + prefs.end(); + } + break; + //Set EEPROM setting + //[ESP401]P= T= V= pwd= + case 401: { #ifdef AUTHENTICATION_FEATURE - if (auth_type != LEVEL_ADMIN) return false; + if (auth_type != LEVEL_ADMIN) { + return false; + } #endif - //check validity of parameters - String spos = get_param (cmd_params, "P=", false); - String styp = get_param (cmd_params, "T=", false); - String sval = get_param (cmd_params, "V=", true); - spos.trim(); - sval.trim(); - if (spos.length() == 0) { - response = false; - } - if (! (styp == "B" || styp == "S" || styp == "A" || styp == "I" || styp == "F") ) { - response = false; - } - if ((sval.length() == 0) && !((spos==AP_PWD_ENTRY) || (spos==STA_PWD_ENTRY))){ - response = false; - } + //check validity of parameters + String spos = get_param (cmd_params, "P=", false); + String styp = get_param (cmd_params, "T=", false); + String sval = get_param (cmd_params, "V=", true); + spos.trim(); + sval.trim(); + if (spos.length() == 0) { + response = false; + } + if (! (styp == "B" || styp == "S" || styp == "A" || styp == "I" || styp == "F") ) { + response = false; + } + if ((sval.length() == 0) && !((spos==AP_PWD_ENTRY) || (spos==STA_PWD_ENTRY))) { + response = false; + } - if (response) { - Preferences prefs; - prefs.begin(NAMESPACE, false); - //Byte value - if ((styp == "B") || (styp == "F")){ - int8_t bbuf = sval.toInt(); - if (prefs.putChar(spos.c_str(), bbuf) ==0 ) { - response = false; - } else { - //dynamique refresh is better than restart the board - if (spos == ESP_RADIO_MODE){ - //TODO - } - if (spos == AP_CHANNEL_ENTRY) { - //TODO - } - if (spos == HTTP_ENABLE_ENTRY) { - //TODO - } - if (spos == TELNET_ENABLE_ENTRY) { - //TODO - } + if (response) { + Preferences prefs; + prefs.begin(NAMESPACE, false); + //Byte value + if ((styp == "B") || (styp == "F")) { + int8_t bbuf = sval.toInt(); + if (prefs.putChar(spos.c_str(), bbuf) ==0 ) { + response = false; + } else { + //dynamique refresh is better than restart the board + if (spos == ESP_RADIO_MODE) { + //TODO + } + if (spos == AP_CHANNEL_ENTRY) { + //TODO + } + if (spos == HTTP_ENABLE_ENTRY) { + //TODO + } + if (spos == TELNET_ENABLE_ENTRY) { + //TODO } } - //Integer value - if (styp == "I") { - int16_t ibuf = sval.toInt(); - if (prefs.putUShort(spos.c_str(), ibuf) == 0) { - response = false; - } else { - if (spos == HTTP_PORT_ENTRY){ - //TODO - } - if (spos == TELNET_PORT_ENTRY){ - //TODO - //Serial.println(ibuf); - } - } - - } - //String value - if (styp == "S") { - if (prefs.putString(spos.c_str(), sval) == 0) { - response = false; - } else { - if (spos == HOSTNAME_ENTRY){ - //TODO - } - if (spos == STA_SSID_ENTRY){ - //TODO - } - if (spos == STA_PWD_ENTRY){ - //TODO - } - if (spos == AP_SSID_ENTRY){ - //TODO - } - if (spos == AP_PWD_ENTRY){ - //TODO - } - } - - } - //IP address - if (styp == "A") { - if (prefs.putInt(spos.c_str(), WiFiConfig::IP_int_from_string(sval)) == 0) { - response = false; - } else { - if (spos == STA_IP_ENTRY){ - //TODO - } - if (spos == STA_GW_ENTRY){ - //TODO - } - if (spos == STA_MK_ENTRY){ - //TODO - } - if (spos == AP_IP_ENTRY){ - //TODO - } - } - } - prefs.end(); - } - if (!response) { - if (espresponse) espresponse->println ("Error: Incorrect Command"); - } else { - if (espresponse) espresponse->println ("ok"); } + //Integer value + if (styp == "I") { + int16_t ibuf = sval.toInt(); + if (prefs.putUShort(spos.c_str(), ibuf) == 0) { + response = false; + } else { + if (spos == HTTP_PORT_ENTRY) { + //TODO + } + if (spos == TELNET_PORT_ENTRY) { + //TODO + //Serial.println(ibuf); + } + } } - break; + //String value + if (styp == "S") { + if (prefs.putString(spos.c_str(), sval) == 0) { + response = false; + } else { + if (spos == HOSTNAME_ENTRY) { + //TODO + } + if (spos == STA_SSID_ENTRY) { + //TODO + } + if (spos == STA_PWD_ENTRY) { + //TODO + } + if (spos == AP_SSID_ENTRY) { + //TODO + } + if (spos == AP_PWD_ENTRY) { + //TODO + } + } + + } + //IP address + if (styp == "A") { + if (prefs.putInt(spos.c_str(), WiFiConfig::IP_int_from_string(sval)) == 0) { + response = false; + } else { + if (spos == STA_IP_ENTRY) { + //TODO + } + if (spos == STA_GW_ENTRY) { + //TODO + } + if (spos == STA_MK_ENTRY) { + //TODO + } + if (spos == AP_IP_ENTRY) { + //TODO + } + } + } + prefs.end(); + } + if (!response) { + if (espresponse) { + espresponse->println ("Error: Incorrect Command"); + } + } else { + if (espresponse) { + espresponse->println ("ok"); + } + } + + } + break; //Get available AP list (limited to 30) - //output is JSON + //output is JSON //[ESP410] case 410: { - if (!espresponse)return false; + if (!espresponse) { + return false; + } #ifdef AUTHENTICATION_FEATURE - if (auth_type == LEVEL_GUEST) return false; + if (auth_type == LEVEL_GUEST) { + return false; + } #endif espresponse->print("{\"AP_LIST\":["); int n = WiFi.scanNetworks(); - if (n > 0) { + if (n > 0) { for (int i = 0; i < n; ++i) { if (i > 0) { espresponse->print (","); @@ -986,250 +1142,271 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen espresponse->print ("\",\"SIGNAL\":\""); espresponse->print (String(WiFiConfig::getSignal (WiFi.RSSI (i) )).c_str()); espresponse->print ("\",\"IS_PROTECTED\":\""); - + if (WiFi.encryptionType (i) == WIFI_AUTH_OPEN) { espresponse->print ("0"); } else { espresponse->print ("1"); } espresponse->print ("\"}"); - Esp3DLibConfig::wait(0); - } - WiFi.scanDelete(); + Esp3DLibConfig::wait(0); } - espresponse->println ("]}"); - //Ugly fix for the AP mode - if (WiFi.getMode() == WIFI_AP_STA) { - WiFi.enableSTA (false); + WiFi.scanDelete(); + } + espresponse->println ("]}"); + //Ugly fix for the AP mode + if (WiFi.getMode() == WIFI_AP_STA) { + WiFi.enableSTA (false); } } break; - //Get ESP current status - case 420: - { + //Get ESP current status + case 420: { #ifdef AUTHENTICATION_FEATURE - if (auth_type == LEVEL_GUEST) return false; + if (auth_type == LEVEL_GUEST) { + return false; + } #endif - if (!espresponse)return false; - Preferences prefs; - prefs.begin(NAMESPACE, true); - espresponse->print ("Chip ID: "); - espresponse->print (String ( (uint16_t) (ESP.getEfuseMac() >> 32) ).c_str()); + if (!espresponse) { + return false; + } + Preferences prefs; + prefs.begin(NAMESPACE, true); + espresponse->print ("Chip ID: "); + espresponse->print (String ( (uint16_t) (ESP.getEfuseMac() >> 32) ).c_str()); + espresponse->print ("\n"); + espresponse->print ("CPU Frequency: "); + espresponse->print (String (ESP.getCpuFreqMHz() ).c_str()); + espresponse->print ("Mhz"); + espresponse->print ("\n"); + espresponse->print ("CPU Temperature: "); + espresponse->print (String (temperatureRead(), 1).c_str()); + espresponse->print ("C"); + espresponse->print ("\n"); + espresponse->print ("Free memory: "); + espresponse->print (ESPResponseStream::formatBytes (ESP.getFreeHeap()).c_str()); + espresponse->print ("\n"); + espresponse->print ("SDK: "); + espresponse->print (ESP.getSdkVersion()); + espresponse->print ("\n"); + espresponse->print ("Flash Size: "); + espresponse->print (ESPResponseStream::formatBytes (ESP.getFlashChipSize()).c_str()); + espresponse->print ("\n"); + espresponse->print ("Available Size for update: "); + //Not OTA on 2Mb board per spec + if (ESP.getFlashChipSize() > 0x20000) { + espresponse->print (ESPResponseStream::formatBytes (0x140000).c_str()); + } else { + espresponse->print (ESPResponseStream::formatBytes (0x0).c_str()); + } + espresponse->print ("\n"); + espresponse->print ("Available Size for SPIFFS: "); + espresponse->print (ESPResponseStream::formatBytes (SPIFFS.totalBytes()).c_str()); + espresponse->print ("\n"); + espresponse->print ("Baud rate: "); + espresponse->print (String(ESPResponseStream::baudRate()).c_str()); + espresponse->print ("\n"); + espresponse->print ("Sleep mode: "); + if (WiFi.getSleep()) { + espresponse->print ("Modem"); + } else { + espresponse->print ("None"); + } + espresponse->print ("\n"); + espresponse->print ("Web port: "); + espresponse->print (String( prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT)).c_str()); + espresponse->print ("\n"); + /*espresponse->print ("Data port: "); + //if (_data_port!=0)espresponse->print (String(_data_port).c_str()); + //else + espresponse->print ("Disabled"); + espresponse->print ("\n");*/ + espresponse->print ("Hostname: "); + String defV = DEFAULT_HOSTNAME; + espresponse->print ( prefs.getString(HOSTNAME_ENTRY, defV).c_str()); + espresponse->print ("\n"); + espresponse->print ("Active Mode: "); + if (WiFi.getMode() == WIFI_STA) { + espresponse->print ("STA ("); + espresponse->print ( WiFi.macAddress().c_str()); + espresponse->print (")"); espresponse->print ("\n"); - espresponse->print ("CPU Frequency: "); - espresponse->print (String (ESP.getCpuFreqMHz() ).c_str()); - espresponse->print ("Mhz"); - espresponse->print ("\n"); - espresponse->print ("CPU Temperature: "); - espresponse->print (String (temperatureRead(), 1).c_str()); - espresponse->print ("C"); - espresponse->print ("\n"); - espresponse->print ("Free memory: "); - espresponse->print (ESPResponseStream::formatBytes (ESP.getFreeHeap()).c_str()); - espresponse->print ("\n"); - espresponse->print ("SDK: "); - espresponse->print (ESP.getSdkVersion()); - espresponse->print ("\n"); - espresponse->print ("Flash Size: "); - espresponse->print (ESPResponseStream::formatBytes (ESP.getFlashChipSize()).c_str()); - espresponse->print ("\n"); - espresponse->print ("Available Size for update: "); - //Not OTA on 2Mb board per spec - if (ESP.getFlashChipSize() > 0x20000) { - espresponse->print (ESPResponseStream::formatBytes (0x140000).c_str()); - } else { - espresponse->print (ESPResponseStream::formatBytes (0x0).c_str()); - } - espresponse->print ("\n"); - espresponse->print ("Available Size for SPIFFS: "); - espresponse->print (ESPResponseStream::formatBytes (SPIFFS.totalBytes()).c_str()); - espresponse->print ("\n"); - espresponse->print ("Baud rate: "); - espresponse->print (String(ESPResponseStream::baudRate()).c_str()); - espresponse->print ("\n"); - espresponse->print ("Sleep mode: "); - if (WiFi.getSleep())espresponse->print ("Modem"); - else espresponse->print ("None"); - espresponse->print ("\n"); - espresponse->print ("Web port: "); - espresponse->print (String( prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT)).c_str()); - espresponse->print ("\n"); - /*espresponse->print ("Data port: "); - //if (_data_port!=0)espresponse->print (String(_data_port).c_str()); - //else - espresponse->print ("Disabled"); - espresponse->print ("\n");*/ - espresponse->print ("Hostname: "); - String defV = DEFAULT_HOSTNAME; - espresponse->print ( prefs.getString(HOSTNAME_ENTRY, defV).c_str()); - espresponse->print ("\n"); - espresponse->print ("Active Mode: "); - if (WiFi.getMode() == WIFI_STA) { - espresponse->print ("STA ("); - espresponse->print ( WiFi.macAddress().c_str()); - espresponse->print (")"); - espresponse->print ("\n"); - espresponse->print ("Connected to: "); - if (WiFi.isConnected()){ //in theory no need but ... - espresponse->print (WiFi.SSID().c_str()); - espresponse->print ("\n"); - espresponse->print ("Signal: "); - espresponse->print ( String(WiFiConfig::getSignal (WiFi.RSSI())).c_str()); - espresponse->print ("%"); - espresponse->print ("\n"); - uint8_t PhyMode; - esp_wifi_get_protocol (ESP_IF_WIFI_STA, &PhyMode); - espresponse->print ("Phy Mode: "); - if (PhyMode == (WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N)) espresponse->print ("11n"); - else if (PhyMode == (WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G)) espresponse->print ("11g"); - else if (PhyMode == (WIFI_PROTOCOL_11B )) espresponse->print ("11b"); - else espresponse->print ("???"); - espresponse->print ("\n"); - espresponse->print ("Channel: "); - espresponse->print (String (WiFi.channel()).c_str()); - espresponse->print ("\n"); - espresponse->print ("IP Mode: "); - tcpip_adapter_dhcp_status_t dhcp_status; - tcpip_adapter_dhcpc_get_status (TCPIP_ADAPTER_IF_STA, &dhcp_status); - if (dhcp_status == TCPIP_ADAPTER_DHCP_STARTED)espresponse->print ("DHCP"); - else espresponse->print ("Static"); - espresponse->print ("\n"); - espresponse->print ("IP: "); - espresponse->print (WiFi.localIP().toString().c_str()); - espresponse->print ("\n"); - espresponse->print ("Gateway: "); - espresponse->print (WiFi.gatewayIP().toString().c_str()); - espresponse->print ("\n"); - espresponse->print ("Mask: "); - espresponse->print (WiFi.subnetMask().toString().c_str()); - espresponse->print ("\n"); - espresponse->print ("DNS: "); - espresponse->print (WiFi.dnsIP().toString().c_str()); - espresponse->print ("\n"); - } //this is web command so connection => no command - espresponse->print ("Disabled Mode: "); - espresponse->print ("AP ("); - espresponse->print (WiFi.softAPmacAddress().c_str()); - espresponse->print (")"); - espresponse->print ("\n"); - } else if (WiFi.getMode() == WIFI_AP) { - espresponse->print ("AP ("); - espresponse->print (WiFi.softAPmacAddress().c_str()); - espresponse->print (")"); - espresponse->print ("\n"); - wifi_config_t conf; - esp_wifi_get_config (ESP_IF_WIFI_AP, &conf); - espresponse->print ("SSID: "); - espresponse->print ((const char*) conf.ap.ssid); - espresponse->print ("\n"); - espresponse->print ("Visible: "); - espresponse->print ( (conf.ap.ssid_hidden == 0) ? "Yes" : "No"); - espresponse->print ("\n"); - espresponse->print ("Authentication: "); - if (conf.ap.authmode == WIFI_AUTH_OPEN) { - espresponse->print ("None"); - } else if (conf.ap.authmode == WIFI_AUTH_WEP) { - espresponse->print ("WEP"); - } else if (conf.ap.authmode == WIFI_AUTH_WPA_PSK) { - espresponse->print ("WPA"); - } else if (conf.ap.authmode == WIFI_AUTH_WPA2_PSK) { - espresponse->print ("WPA2"); - } else { - espresponse->print ("WPA/WPA2"); - } + espresponse->print ("Connected to: "); + if (WiFi.isConnected()) { //in theory no need but ... + espresponse->print (WiFi.SSID().c_str()); espresponse->print ("\n"); - espresponse->print ("Max Connections: "); - espresponse->print (String(conf.ap.max_connection).c_str()); + espresponse->print ("Signal: "); + espresponse->print ( String(WiFiConfig::getSignal (WiFi.RSSI())).c_str()); + espresponse->print ("%"); espresponse->print ("\n"); - espresponse->print ("DHCP Server: "); + uint8_t PhyMode; + esp_wifi_get_protocol (ESP_IF_WIFI_STA, &PhyMode); + espresponse->print ("Phy Mode: "); + if (PhyMode == (WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N)) { + espresponse->print ("11n"); + } else if (PhyMode == (WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G)) { + espresponse->print ("11g"); + } else if (PhyMode == (WIFI_PROTOCOL_11B )) { + espresponse->print ("11b"); + } else { + espresponse->print ("???"); + } + espresponse->print ("\n"); + espresponse->print ("Channel: "); + espresponse->print (String (WiFi.channel()).c_str()); + espresponse->print ("\n"); + espresponse->print ("IP Mode: "); tcpip_adapter_dhcp_status_t dhcp_status; - tcpip_adapter_dhcps_get_status (TCPIP_ADAPTER_IF_AP, &dhcp_status); - if (dhcp_status == TCPIP_ADAPTER_DHCP_STARTED)espresponse->print ("Started"); - else espresponse->print ("Stopped"); + tcpip_adapter_dhcpc_get_status (TCPIP_ADAPTER_IF_STA, &dhcp_status); + if (dhcp_status == TCPIP_ADAPTER_DHCP_STARTED) { + espresponse->print ("DHCP"); + } else { + espresponse->print ("Static"); + } espresponse->print ("\n"); espresponse->print ("IP: "); - espresponse->print (WiFi.softAPIP().toString().c_str()); + espresponse->print (WiFi.localIP().toString().c_str()); espresponse->print ("\n"); - tcpip_adapter_ip_info_t ip_AP; - tcpip_adapter_get_ip_info (TCPIP_ADAPTER_IF_AP, &ip_AP); espresponse->print ("Gateway: "); - espresponse->print (IPAddress (ip_AP.gw.addr).toString().c_str()); + espresponse->print (WiFi.gatewayIP().toString().c_str()); espresponse->print ("\n"); espresponse->print ("Mask: "); - espresponse->print (IPAddress (ip_AP.netmask.addr).toString().c_str()); + espresponse->print (WiFi.subnetMask().toString().c_str()); espresponse->print ("\n"); - espresponse->print ("Connected clients: "); - wifi_sta_list_t station; - tcpip_adapter_sta_list_t tcpip_sta_list; - esp_wifi_ap_get_sta_list (&station); - tcpip_adapter_get_sta_list (&station, &tcpip_sta_list); - espresponse->print (String(station.num).c_str()); + espresponse->print ("DNS: "); + espresponse->print (WiFi.dnsIP().toString().c_str()); espresponse->print ("\n"); - for (int i = 0; i < station.num; i++) { - espresponse->print (ESPResponseStream::mac2str(tcpip_sta_list.sta[i].mac)); - espresponse->print (" "); - espresponse->print ( IPAddress (tcpip_sta_list.sta[i].ip.addr).toString().c_str()); - espresponse->print ("\n"); - } - espresponse->print ("Disabled Mode: "); - espresponse->print ("STA ("); - espresponse->print (WiFi.macAddress().c_str()); - espresponse->print (")"); - espresponse->print ("\n"); - } else if (WiFi.getMode() == WIFI_AP_STA) //we should not be in this state but just in case .... - { - espresponse->print ("Mixed"); - espresponse->print ("\n"); - espresponse->print ("STA ("); - espresponse->print (WiFi.macAddress().c_str()); - espresponse->print (")"); - espresponse->print ("\n"); - espresponse->print ("AP ("); - espresponse->print (WiFi.softAPmacAddress().c_str()); - espresponse->print (")"); - espresponse->print ("\n"); - - } else { //we should not be there if no wifi .... - espresponse->print ("Wifi Off"); - espresponse->print ("\n"); - } - prefs.end(); - //TODO to complete - espresponse->print ("FW version: Marlin "); - espresponse->print (SHORT_BUILD_VERSION); - espresponse->print (" (ESP3D:"); - espresponse->print (LIB_VERSION); - espresponse->println (")"); - } - break; - //Set ESP mode - //cmd is RESTART, RESET - //[ESP444] - case 444: - parameter = get_param(cmd_params,"", true); -#ifdef AUTHENTICATION_FEATURE - if (auth_type != LEVEL_ADMIN) { - response = false; - } else -#endif - { - if (parameter=="RESTART") { - Esp3DCom::echo("Restart ongoing"); - Esp3DLibConfig::restart_ESP(); - } else - if (parameter=="RESET") { - Esp3DCom::echo("Reset"); - Esp3DLibConfig::reset_settings(); - } else response = false; - } - if (!response) { - if (espresponse)espresponse->println ("Error: Incorrect Command, only RESET or RESTART"); + } //this is web command so connection => no command + espresponse->print ("Disabled Mode: "); + espresponse->print ("AP ("); + espresponse->print (WiFi.softAPmacAddress().c_str()); + espresponse->print (")"); + espresponse->print ("\n"); + } else if (WiFi.getMode() == WIFI_AP) { + espresponse->print ("AP ("); + espresponse->print (WiFi.softAPmacAddress().c_str()); + espresponse->print (")"); + espresponse->print ("\n"); + wifi_config_t conf; + esp_wifi_get_config (ESP_IF_WIFI_AP, &conf); + espresponse->print ("SSID: "); + espresponse->print ((const char*) conf.ap.ssid); + espresponse->print ("\n"); + espresponse->print ("Visible: "); + espresponse->print ( (conf.ap.ssid_hidden == 0) ? "Yes" : "No"); + espresponse->print ("\n"); + espresponse->print ("Authentication: "); + if (conf.ap.authmode == WIFI_AUTH_OPEN) { + espresponse->print ("None"); + } else if (conf.ap.authmode == WIFI_AUTH_WEP) { + espresponse->print ("WEP"); + } else if (conf.ap.authmode == WIFI_AUTH_WPA_PSK) { + espresponse->print ("WPA"); + } else if (conf.ap.authmode == WIFI_AUTH_WPA2_PSK) { + espresponse->print ("WPA2"); } else { - if (espresponse)espresponse->println ("ok"); + espresponse->print ("WPA/WPA2"); } - break; + espresponse->print ("\n"); + espresponse->print ("Max Connections: "); + espresponse->print (String(conf.ap.max_connection).c_str()); + espresponse->print ("\n"); + espresponse->print ("DHCP Server: "); + tcpip_adapter_dhcp_status_t dhcp_status; + tcpip_adapter_dhcps_get_status (TCPIP_ADAPTER_IF_AP, &dhcp_status); + if (dhcp_status == TCPIP_ADAPTER_DHCP_STARTED) { + espresponse->print ("Started"); + } else { + espresponse->print ("Stopped"); + } + espresponse->print ("\n"); + espresponse->print ("IP: "); + espresponse->print (WiFi.softAPIP().toString().c_str()); + espresponse->print ("\n"); + tcpip_adapter_ip_info_t ip_AP; + tcpip_adapter_get_ip_info (TCPIP_ADAPTER_IF_AP, &ip_AP); + espresponse->print ("Gateway: "); + espresponse->print (IPAddress (ip_AP.gw.addr).toString().c_str()); + espresponse->print ("\n"); + espresponse->print ("Mask: "); + espresponse->print (IPAddress (ip_AP.netmask.addr).toString().c_str()); + espresponse->print ("\n"); + espresponse->print ("Connected clients: "); + wifi_sta_list_t station; + tcpip_adapter_sta_list_t tcpip_sta_list; + esp_wifi_ap_get_sta_list (&station); + tcpip_adapter_get_sta_list (&station, &tcpip_sta_list); + espresponse->print (String(station.num).c_str()); + espresponse->print ("\n"); + for (int i = 0; i < station.num; i++) { + espresponse->print (ESPResponseStream::mac2str(tcpip_sta_list.sta[i].mac)); + espresponse->print (" "); + espresponse->print ( IPAddress (tcpip_sta_list.sta[i].ip.addr).toString().c_str()); + espresponse->print ("\n"); + } + espresponse->print ("Disabled Mode: "); + espresponse->print ("STA ("); + espresponse->print (WiFi.macAddress().c_str()); + espresponse->print (")"); + espresponse->print ("\n"); + } else if (WiFi.getMode() == WIFI_AP_STA) { //we should not be in this state but just in case .... + espresponse->print ("Mixed"); + espresponse->print ("\n"); + espresponse->print ("STA ("); + espresponse->print (WiFi.macAddress().c_str()); + espresponse->print (")"); + espresponse->print ("\n"); + espresponse->print ("AP ("); + espresponse->print (WiFi.softAPmacAddress().c_str()); + espresponse->print (")"); + espresponse->print ("\n"); + + } else { //we should not be there if no wifi .... + espresponse->print ("Wifi Off"); + espresponse->print ("\n"); + } + prefs.end(); + //TODO to complete + espresponse->print ("FW version: Marlin "); + espresponse->print (SHORT_BUILD_VERSION); + espresponse->print (" (ESP3D:"); + espresponse->print (LIB_VERSION); + espresponse->println (")"); + } + break; + //Set ESP mode + //cmd is RESTART, RESET + //[ESP444] + case 444: + parameter = get_param(cmd_params,"", true); #ifdef AUTHENTICATION_FEATURE - //Change / Reset admin password + if (auth_type != LEVEL_ADMIN) { + response = false; + } else +#endif + { + if (parameter=="RESTART") { + Esp3DCom::echo("Restart ongoing"); + Esp3DLibConfig::restart_ESP(); + } else if (parameter=="RESET") { + Esp3DCom::echo("Reset"); + Esp3DLibConfig::reset_settings(); + } else { + response = false; + } + } + if (!response) { + if (espresponse) { + espresponse->println ("Error: Incorrect Command, only RESET or RESTART"); + } + } else { + if (espresponse) { + espresponse->println ("ok"); + } + } + break; +#ifdef AUTHENTICATION_FEATURE + //Change / Reset admin password //[ESP550] case 550: { if (auth_type == LEVEL_ADMIN) { @@ -1238,12 +1415,14 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen Preferences prefs; parameter = DEFAULT_ADMIN_PWD; prefs.begin(NAMESPACE, false); - if (prefs.putString(ADMIN_PWD_ENTRY, parameter) != parameter.length()){ + if (prefs.putString(ADMIN_PWD_ENTRY, parameter) != parameter.length()) { response = false; espresponse->println ("error"); - } else espresponse->println ("ok"); + } else { + espresponse->println ("ok"); + } prefs.end(); - + } else { if (isLocalPasswordValid (parameter.c_str() ) ) { Preferences prefs; @@ -1251,7 +1430,9 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen if (prefs.putString(ADMIN_PWD_ENTRY, parameter) != parameter.length()) { response = false; espresponse->println ("error"); - } else espresponse->println ("ok"); + } else { + espresponse->println ("ok"); + } prefs.end(); } else { espresponse->println ("error"); @@ -1273,12 +1454,14 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen Preferences prefs; parameter = DEFAULT_USER_PWD; prefs.begin(NAMESPACE, false); - if (prefs.putString(USER_PWD_ENTRY, parameter) != parameter.length()){ + if (prefs.putString(USER_PWD_ENTRY, parameter) != parameter.length()) { response = false; espresponse->println ("error"); - } else espresponse->println ("ok"); + } else { + espresponse->println ("ok"); + } prefs.end(); - + } else { if (isLocalPasswordValid (parameter.c_str() ) ) { Preferences prefs; @@ -1286,7 +1469,9 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen if (prefs.putString(USER_PWD_ENTRY, parameter) != parameter.length()) { response = false; espresponse->println ("error"); - } else espresponse->println ("ok"); + } else { + espresponse->println ("ok"); + } prefs.end(); } else { espresponse->println ("error"); @@ -1303,7 +1488,9 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen //[ESP700] case 700: { //read local file #ifdef AUTHENTICATION_FEATURE - if (auth_type == LEVEL_GUEST) return false; + if (auth_type == LEVEL_GUEST) { + return false; + } #endif cmd_params.trim() ; if ( (cmd_params.length() > 0) && (cmd_params[0] != '/') ) { @@ -1331,25 +1518,31 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen } //if command is a valid number then execute command if(cmd_part1.toInt()!=0) { - if (!execute_internal_command(cmd_part1.toInt(),cmd_part2, auth_type, espresponse)) response = false; + if (!execute_internal_command(cmd_part1.toInt(),cmd_part2, auth_type, espresponse)) { + response = false; + } } //if not is not a valid [ESPXXX] command ignore it } } else { - if (currentline.length() > 0){ + if (currentline.length() > 0) { currentline+="\n"; Serial2Socket.push(currentline.c_str()); //GCodeQueue::enqueue_one_now(currentline.c_str()); } Esp3DLibConfig::wait (1); } - Esp3DLibConfig::wait (1); + Esp3DLibConfig::wait (1); } } currentfile.close(); - if (espresponse)espresponse->println ("ok"); + if (espresponse) { + espresponse->println ("ok"); + } } else { - if (espresponse)espresponse->println ("error"); + if (espresponse) { + espresponse->println ("error"); + } response = false; } break; @@ -1358,7 +1551,9 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen //[ESP710]FORMAT pwd= case 710: #ifdef AUTHENTICATION_FEATURE - if (auth_type != LEVEL_ADMIN) return false; + if (auth_type != LEVEL_ADMIN) { + return false; + } #endif parameter = get_param (cmd_params, "", true); #ifdef AUTHENTICATION_FEATURE @@ -1370,51 +1565,64 @@ bool COMMAND::execute_internal_command (int cmd, String cmd_params, level_authen #endif { if (parameter == "FORMAT") { - if (espresponse)espresponse->print ("Formating"); + if (espresponse) { + espresponse->print ("Formating"); + } SPIFFS.format(); - if (espresponse)espresponse->println ("...Done"); + if (espresponse) { + espresponse->println ("...Done"); + } } else { - if (espresponse)espresponse->println ("error"); + if (espresponse) { + espresponse->println ("error"); + } response = false; } } break; - //get fw version / fw target / hostname / authentication - //[ESP800] - case 800: - { - if (!espresponse)return false; - Preferences prefs; - prefs.begin(NAMESPACE, true); - String resp; - resp = "FW version:"; - resp += SHORT_BUILD_VERSION; - resp += " # FW target:marlin-embedded # FW HW:"; - #if defined(SDSUPPORT) - resp += "Direct SD"; - #else - resp += "No SD"; - #endif - resp += " # primary sd:/sd # secondary sd:none # authentication:"; - #ifdef AUTHENTICATION_FEATURE - resp += "yes"; - #else - resp += "no"; - #endif - resp += " # webcommunication: Sync: "; - resp += String(prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT) + 1); - resp += "# hostname:"; - String defV = DEFAULT_HOSTNAME; - resp += prefs.getString(HOSTNAME_ENTRY, defV);; - prefs.end(); - if (WiFi.getMode() == WIFI_AP)resp += "(AP mode)"; - if (espresponse)espresponse->println (resp.c_str()); - } - break; - default: - if (espresponse)espresponse->println ("Error: Incorrect Command"); - response = false; - break; + //get fw version / fw target / hostname / authentication + //[ESP800] + case 800: { + if (!espresponse) { + return false; + } + Preferences prefs; + prefs.begin(NAMESPACE, true); + String resp; + resp = "FW version:"; + resp += SHORT_BUILD_VERSION; + resp += " # FW target:marlin-embedded # FW HW:"; +#if defined(SDSUPPORT) + resp += "Direct SD"; +#else + resp += "No SD"; +#endif + resp += " # primary sd:/sd # secondary sd:none # authentication:"; +#ifdef AUTHENTICATION_FEATURE + resp += "yes"; +#else + resp += "no"; +#endif + resp += " # webcommunication: Sync: "; + resp += String(prefs.getUShort(HTTP_PORT_ENTRY, DEFAULT_WEBSERVER_PORT) + 1); + resp += "# hostname:"; + String defV = DEFAULT_HOSTNAME; + resp += prefs.getString(HOSTNAME_ENTRY, defV);; + prefs.end(); + if (WiFi.getMode() == WIFI_AP) { + resp += "(AP mode)"; + } + if (espresponse) { + espresponse->println (resp.c_str()); + } + } + break; + default: + if (espresponse) { + espresponse->println ("Error: Incorrect Command"); + } + response = false; + break; } return response; } diff --git a/src/esp3dlib.cpp b/src/esp3dlib.cpp index d633019..5540a38 100644 --- a/src/esp3dlib.cpp +++ b/src/esp3dlib.cpp @@ -67,10 +67,10 @@ void Esp3DLib::init() //Parse command bool Esp3DLib::parse(char * cmd) { - String scmd = cmd; - int ESPpos = scmd.indexOf ("[ESP"); + String scmd = cmd; + int ESPpos = scmd.indexOf ("[ESP"); if (ESPpos > -1) { - int ESPpos2 = scmd.indexOf("]",ESPpos); + int ESPpos2 = scmd.indexOf("]",ESPpos); if (ESPpos2>-1) { //Split in command and parameters String cmd_part1=scmd.substring(ESPpos+4,ESPpos2); @@ -81,17 +81,19 @@ bool Esp3DLib::parse(char * cmd) } //if command is a valid number then execute command if(cmd_part1.toInt() >=0) { - ESPResponseStream response(SERIAL_PIPE); + ESPResponseStream response(SERIAL_PIPE); level_authenticate_type auth_type = LEVEL_ADMIN; //we do not care serial authentication COMMAND::execute_internal_command (cmd_part1.toInt(), cmd_part2, auth_type, &response); return true; } else { - return false; - } - } else return false; - } else { - return false; - } - + return false; + } + } else { + return false; + } + } else { + return false; + } + } #endif //ESP3D_WIFISUPPORT diff --git a/src/esp3dlib.h b/src/esp3dlib.h index 811fe2b..a3fe86d 100644 --- a/src/esp3dlib.h +++ b/src/esp3dlib.h @@ -29,7 +29,7 @@ class Esp3DLib { public: - /** + /** * Constructor. */ Esp3DLib(); @@ -40,7 +40,7 @@ public: /** * Parser for commmand. * @param[in] cmd - the string to parse - * + * * @return true - if it is seen as ESP command. * @return false - if not ESP command. */ diff --git a/src/esp3dlibconfig.cpp b/src/esp3dlibconfig.cpp index c97625a..22a2140 100644 --- a/src/esp3dlibconfig.cpp +++ b/src/esp3dlibconfig.cpp @@ -36,28 +36,31 @@ bool Esp3DLibConfig::restart_ESP_module = false; /* * delay is to avoid sometimes and may not enough neither */ -void Esp3DLibConfig::wait(uint32_t milliseconds){ +void Esp3DLibConfig::wait(uint32_t milliseconds) +{ uint32_t timeout = millis(); vTaskDelay(1 / portTICK_RATE_MS); // Yield to other tasks esp_task_wdt_reset(); //for a wait 0; //wait feeding WDT while ( (millis() - timeout) < milliseconds) { - esp_task_wdt_reset(); - vTaskDelay(1 / portTICK_RATE_MS); // Yield to other tasks + esp_task_wdt_reset(); + vTaskDelay(1 / portTICK_RATE_MS); // Yield to other tasks } } /** * Restart ESP */ -void Esp3DLibConfig::restart_ESP(){ +void Esp3DLibConfig::restart_ESP() +{ restart_ESP_module=true; } /** * Handle not critical actions that must be done in sync environement */ -void Esp3DLibConfig::handle() { +void Esp3DLibConfig::handle() +{ //in case of restart requested if (restart_ESP_module) { ESP.restart(); @@ -65,35 +68,35 @@ void Esp3DLibConfig::handle() { } } -void Esp3DLibConfig::reset_settings() +bool Esp3DLibConfig::reset_settings() { - Preferences prefs; + Preferences prefs; prefs.begin(NAMESPACE, false); String sval; int8_t bbuf; int16_t ibuf; bool error = false; sval = DEFAULT_HOSTNAME; - if (prefs.putString(HOSTNAME_ENTRY, sval) == 0){ + if (prefs.putString(HOSTNAME_ENTRY, sval) == 0) { error = true; } sval = DEFAULT_STA_SSID; - if (prefs.putString(STA_SSID_ENTRY, sval) == 0){ + if (prefs.putString(STA_SSID_ENTRY, sval) == 0) { error = true; } sval = DEFAULT_STA_PWD; - if (prefs.putString(STA_PWD_ENTRY, sval) != sval.length()){ + if (prefs.putString(STA_PWD_ENTRY, sval) != sval.length()) { error = true; } sval = DEFAULT_AP_SSID; - if (prefs.putString(AP_SSID_ENTRY, sval) == 0){ + if (prefs.putString(AP_SSID_ENTRY, sval) == 0) { error = true; } sval = DEFAULT_AP_PWD; - if (prefs.putString(AP_PWD_ENTRY, sval) != sval.length()){ + if (prefs.putString(AP_PWD_ENTRY, sval) != sval.length()) { error = true; } - + bbuf = DEFAULT_AP_CHANNEL; if (prefs.putChar(AP_CHANNEL_ENTRY, bbuf) ==0 ) { error = true; @@ -101,11 +104,11 @@ void Esp3DLibConfig::reset_settings() bbuf = DEFAULT_STA_IP_MODE; if (prefs.putChar(STA_IP_MODE_ENTRY, bbuf) ==0 ) { error = true; - } + } bbuf = DEFAULT_HTTP_STATE; if (prefs.putChar(HTTP_ENABLE_ENTRY, bbuf) ==0 ) { error = true; - } + } /*bbuf = DEFAULT_TELNET_STATE; if (prefs.putChar(TELNET_ENABLE_ENTRY, bbuf) ==0 ) { error = true; @@ -113,7 +116,7 @@ void Esp3DLibConfig::reset_settings() bbuf = DEFAULT_RADIO_MODE; if (prefs.putChar(ESP_RADIO_MODE, bbuf) ==0 ) { error = true; - } + } ibuf = DEFAULT_WEBSERVER_PORT; if (prefs.putUShort(HTTP_PORT_ENTRY, ibuf) == 0) { error = true; @@ -137,8 +140,9 @@ void Esp3DLibConfig::reset_settings() sval = DEFAULT_AP_IP; if (prefs.putInt(AP_IP_ENTRY, WiFiConfig::IP_int_from_string(sval)) == 0) { error = true; - } + } prefs.end(); + return error; } #endif // ESP3D_WIFISUPPORT diff --git a/src/esp3dlibconfig.h b/src/esp3dlibconfig.h index 2145af2..dcb349f 100644 --- a/src/esp3dlibconfig.h +++ b/src/esp3dlibconfig.h @@ -25,7 +25,7 @@ #undef DISABLED #undef _BV //version -#define LIB_VERSION "0.9.0" +#define LIB_VERSION "1.0.0" //Editable configuration part @@ -33,13 +33,13 @@ //#define AUTHENTICATION_FEATURE //HTTP_FEATURE: enable Web Server -//Rely on Configuration_adv.h +//Rely on Configuration_adv.h #ifdef WEBSUPPORT #define HTTP_FEATURE #endif //WEBSUPPORT //OTA_FEATURE: this feature is arduino update over the air -//Rely on Configuration_adv.h +//Rely on Configuration_adv.h #ifdef OTASUPPORT #define OTA_FEATURE #endif //OTASUPPORT @@ -121,13 +121,14 @@ #ifndef ESP3DLIBCONFIG_H #define ESP3DLIBCONFIG_H -class Esp3DLibConfig { +class Esp3DLibConfig +{ public: static void wait(uint32_t milliseconds); static void restart_ESP(); static void handle(); - static void reset_settings(); + static bool reset_settings(); private: - static bool restart_ESP_module; + static bool restart_ESP_module; }; #endif //ESP3DLIBCONFIG_H diff --git a/src/espcom.cpp b/src/espcom.cpp index 1229fca..6914e88 100644 --- a/src/espcom.cpp +++ b/src/espcom.cpp @@ -30,73 +30,80 @@ #endif //HTTP_FEATURE void Esp3DCom::echo(const char * data) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("", data); + SERIAL_ECHO_START(); + SERIAL_ECHOLNPAIR("", data); } long ESPResponseStream::baudRate() { - long br = flushableSerial.baudRate(); - //workaround for ESP32 - if (br == 115201) { - br = 115200; - } - if (br == 230423) { - br = 230400; - } - return br; + long br = flushableSerial.baudRate(); + //workaround for ESP32 + if (br == 115201) { + br = 115200; + } + if (br == 230423) { + br = 230400; + } + return br; } #if defined(HTTP_FEATURE) -ESPResponseStream::ESPResponseStream(WebServer * webserver){ +ESPResponseStream::ESPResponseStream(WebServer * webserver) +{ _header_sent=false; _webserver = webserver; _pipe = WEB_PIPE; } #endif //HTTP_FEATURE -ESPResponseStream::ESPResponseStream(tpipe pipe){ - _pipe = pipe; +ESPResponseStream::ESPResponseStream(tpipe pipe) +{ + _pipe = pipe; } -void ESPResponseStream::println(const char *data){ +void ESPResponseStream::println(const char *data) +{ print(data); print("\n"); } -void ESPResponseStream::print(const char *data){ +void ESPResponseStream::print(const char *data) +{ #if defined(HTTP_FEATURE) - if (_pipe == WEB_PIPE){ - if (!_header_sent) { - _webserver->setContentLength(CONTENT_LENGTH_UNKNOWN); - _webserver->sendHeader("Content-Type","text/html"); - _webserver->sendHeader("Cache-Control","no-cache"); - _webserver->send(200); - _header_sent = true; - } - _buffer+=data; - if (_buffer.length() > 1200) { - //send data - _webserver->sendContent(_buffer); - //reset buffer - _buffer = ""; - } - } + if (_pipe == WEB_PIPE) { + if (!_header_sent) { + _webserver->setContentLength(CONTENT_LENGTH_UNKNOWN); + _webserver->sendHeader("Content-Type","text/html"); + _webserver->sendHeader("Cache-Control","no-cache"); + _webserver->send(200); + _header_sent = true; + } + _buffer+=data; + if (_buffer.length() > 1200) { + //send data + _webserver->sendContent(_buffer); + //reset buffer + _buffer = ""; + } + } #endif //HTTP_FEATURE - if (_pipe == SERIAL_PIPE) { - SERIAL_ECHOPAIR_F("", data); - } + if (_pipe == SERIAL_PIPE) { + SERIAL_ECHOPAIR_F("", data); + } } -void ESPResponseStream::flush(){ +void ESPResponseStream::flush() +{ #if defined(HTTP_FEATURE) - if (_pipe == WEB_PIPE){ - if(_header_sent) { - //send data - if(_buffer.length() > 0)_webserver->sendContent(_buffer); - //close connection - _webserver->sendContent(""); - } - _header_sent = false; - _buffer = ""; - } + if (_pipe == WEB_PIPE) { + if(_header_sent) { + //send data + if(_buffer.length() > 0) { + _webserver->sendContent(_buffer); + } + //close connection + _webserver->sendContent(""); + } + _header_sent = false; + _buffer = ""; + } #endif //HTTP_FEATURE } diff --git a/src/espcom.h b/src/espcom.h index 0c7101d..2de95b0 100644 --- a/src/espcom.h +++ b/src/espcom.h @@ -28,7 +28,7 @@ typedef enum { LEVEL_ADMIN = 2 } level_authenticate_type; -//communication pipes +//communication pipes typedef enum { NO_PIPE = 0, SERIAL_PIPE = 2, @@ -46,12 +46,16 @@ typedef enum { #if defined(HTTP_FEATURE) class WebServer; #endif //HTTP_FEATURE -class ESPResponseStream{ - public: +class ESPResponseStream +{ +public: void print(const char *data); void println(const char *data); void flush(); - tpipe pipe(){return _pipe;}; + tpipe pipe() + { + return _pipe; + }; ESPResponseStream(tpipe pipe); #if defined(HTTP_FEATURE) ESPResponseStream(WebServer * webserver); @@ -59,12 +63,12 @@ class ESPResponseStream{ static char * mac2str (uint8_t mac [8]); static String formatBytes (uint32_t bytes); static long baudRate(); - private: +private: #if defined(HTTP_FEATURE) bool _header_sent; WebServer * _webserver; #endif //HTTP_FEATURE - tpipe _pipe; + tpipe _pipe; String _buffer; }; diff --git a/src/nofile.h b/src/nofile.h index f10f2d8..d6e6532 100644 --- a/src/nofile.h +++ b/src/nofile.h @@ -22,308 +22,308 @@ //bin2c Conversion Tool v0.14.0 - Windows - [FINAL]. #define PAGE_NOFILES_SIZE 4862 const char PAGE_NOFILES [] PROGMEM = { - 0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xED, 0x5C, 0x7D, 0x93, 0xDA, 0x46, - 0x93, 0xFF, 0x2A, 0xB2, 0x52, 0x36, 0x70, 0x2B, 0x40, 0x12, 0xAF, 0x8B, 0x16, 0xF2, 0x24, 0xB1, - 0x7D, 0xF1, 0x95, 0x13, 0xBB, 0xBC, 0xEB, 0x7B, 0xAE, 0x2A, 0x4E, 0xB9, 0x84, 0x34, 0x80, 0xCE, - 0x42, 0xD2, 0x49, 0xC3, 0xEE, 0x62, 0xC2, 0x77, 0xBF, 0xEE, 0x79, 0x91, 0x46, 0x42, 0xB0, 0xEC, - 0x26, 0x79, 0xF2, 0xFC, 0x91, 0x60, 0x23, 0x98, 0x99, 0xEE, 0xE9, 0xE9, 0xE9, 0xFE, 0x75, 0x4F, - 0x0F, 0xCE, 0xD5, 0x8A, 0xAE, 0xC3, 0xD9, 0xD5, 0x8A, 0xB8, 0xFE, 0xEC, 0x2A, 0xA3, 0xDB, 0x90, - 0xCC, 0xB0, 0x65, 0xB7, 0x88, 0x23, 0xDA, 0x5E, 0xB8, 0xEB, 0x20, 0xDC, 0x4E, 0x32, 0x37, 0xCA, - 0xDA, 0x19, 0x49, 0x83,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A, 0x65, 0x0B, 0xD8, 0x1B, 0x81, 0x7A, 0x76, 0x8A, 0x58, + 0xD8, 0x08, 0xE4, 0xD9, 0x09, 0x95, 0xAA, 0x16, 0xB0, 0x21, 0x24, 0x39, 0x77, 0x41, 0xE4, 0xC7, + 0x77, 0x35, 0xD1, 0xE2, 0xF8, 0xED, 0x89, 0x73, 0xD5, 0x15, 0xD7, 0xD3, 0x57, 0x5D, 0xF1, 0x83, + 0x19, 0xF6, 0xFF, 0xCC, 0xF9, 0x7F, 0xE5, 0xCC, 0x32, 0xCA, 0x3A, 0x47, 0x00, 0x00 }; diff --git a/src/sd_ESP32.cpp b/src/sd_ESP32.cpp index f0c2792..f0517e2 100644 --- a/src/sd_ESP32.cpp +++ b/src/sd_ESP32.cpp @@ -34,56 +34,82 @@ dir_t dir_info; SdVolume sd_volume; -ESP_SD::ESP_SD(){ +ESP_SD::ESP_SD() +{ _size = 0; _pos = 0; _readonly=true; //ugly Workaround to not expose SdFile class which conflict with Native ESP32 SD class _sdfile = new SdFile; } -ESP_SD::~ESP_SD(){ -if (((SdFile *)_sdfile)->isOpen())close(); -if (_sdfile) delete (SdFile *) _sdfile; +ESP_SD::~ESP_SD() +{ + if (((SdFile *)_sdfile)->isOpen()) { + close(); + } + if (_sdfile) { + delete (SdFile *) _sdfile; + } } -bool ESP_SD::isopen(){ +bool ESP_SD::isopen() +{ return (((SdFile *)_sdfile)->isOpen()); } -int8_t ESP_SD::card_status(){ -if (!IS_SD_INSERTED() || !card.isMounted()) return 0; //No sd -if ( card.isPrinting() || card.isFileOpen() ) return -1; // busy -return 1; //ok +int8_t ESP_SD::card_status() +{ + if (!IS_SD_INSERTED() || !card.isMounted()) { + return 0; //No sd + } + if ( card.isPrinting() || card.isFileOpen() ) { + return -1; // busy + } + return 1; //ok } -bool ESP_SD::open(const char * path, bool readonly ){ - if (path == NULL) return false; +bool ESP_SD::open(const char * path, bool readonly ) +{ + if (path == NULL) { + return false; + } String fullpath=path; String pathname = fullpath.substring(0,fullpath.lastIndexOf("/")); String filename = makeshortname(fullpath.substring(fullpath.lastIndexOf("/")+1)); - if (pathname.length() == 0)pathname="/"; - if (!openDir(pathname))return false; + if (pathname.length() == 0) { + pathname="/"; + } + if (!openDir(pathname)) { + return false; + } _pos = 0; _readonly = readonly; return ((SdFile *)_sdfile)->open(&workDir, filename.c_str(), readonly?O_READ:(O_CREAT | O_APPEND | O_WRITE | O_TRUNC)); } -uint32_t ESP_SD::size(){ +uint32_t ESP_SD::size() +{ if(((SdFile *)_sdfile)->isOpen()) { _size = ((SdFile *)_sdfile)->fileSize(); } return _size ; } -uint32_t ESP_SD::available(){ - if(!((SdFile *)_sdfile)->isOpen() || !_readonly) return 0; +uint32_t ESP_SD::available() +{ + if(!((SdFile *)_sdfile)->isOpen() || !_readonly) { + return 0; + } _size = ((SdFile *)_sdfile)->fileSize(); - if (_size == 0) return 0; - + if (_size == 0) { + return 0; + } + return _size - _pos ; } -void ESP_SD::close(){ +void ESP_SD::close() +{ if(((SdFile *)_sdfile)->isOpen()) { ((SdFile *)_sdfile)->sync(); _size = ((SdFile *)_sdfile)->fileSize(); @@ -91,95 +117,136 @@ void ESP_SD::close(){ } } -int16_t ESP_SD::write(const uint8_t * data, uint16_t len){ +int16_t ESP_SD::write(const uint8_t * data, uint16_t len) +{ return ((SdFile *)_sdfile)->write(data, len); } -int16_t ESP_SD::write(const uint8_t byte){ +int16_t ESP_SD::write(const uint8_t byte) +{ return ((SdFile *)_sdfile)->write(&byte, 1); } -bool ESP_SD::exists(const char * path){ +bool ESP_SD::exists(const char * path) +{ bool response = open(path); - if (response) close(); + if (response) { + close(); + } return response; } -bool ESP_SD::remove(const char * path){ - if (path == NULL) return false; +bool ESP_SD::remove(const char * path) +{ + if (path == NULL) { + return false; + } String fullpath=path; String pathname = fullpath.substring(0,fullpath.lastIndexOf("/")); String filename = makeshortname(fullpath.substring(fullpath.lastIndexOf("/")+1)); - if (pathname.length() == 0)pathname="/"; - if (!openDir(pathname))return false; + if (pathname.length() == 0) { + pathname="/"; + } + if (!openDir(pathname)) { + return false; + } SdFile file; return file.remove(&workDir, filename.c_str()); } -bool ESP_SD::dir_exists(const char * path){ - return openDir(path); +bool ESP_SD::dir_exists(const char * path) +{ + return openDir(path); } -bool ESP_SD::rmdir(const char * path){ - if (path == NULL) return false; +bool ESP_SD::rmdir(const char * path) +{ + if (path == NULL) { + return false; + } String fullpath=path; - if (fullpath=="/") return false; - if (!openDir(fullpath))return false; + if (fullpath=="/") { + return false; + } + if (!openDir(fullpath)) { + return false; + } return workDir.rmRfStar(); } -bool ESP_SD::mkdir(const char * path){ - if (path == NULL) return false; +bool ESP_SD::mkdir(const char * path) +{ + if (path == NULL) { + return false; + } String fullpath=path; String pathname = fullpath.substring(0,fullpath.lastIndexOf("/")); String filename = makeshortname(fullpath.substring(fullpath.lastIndexOf("/")+1)); - if (pathname.length() == 0)pathname="/"; - if (!openDir(pathname))return false; + if (pathname.length() == 0) { + pathname="/"; + } + if (!openDir(pathname)) { + return false; + } SdFile file; return file.mkdir(&workDir, filename.c_str()); } -int16_t ESP_SD::read(){ - if (!_readonly) return 0; +int16_t ESP_SD::read() +{ + if (!_readonly) { + return 0; + } int16_t v = ((SdFile *)_sdfile)->read(); - if (v!=-1)_pos++; + if (v!=-1) { + _pos++; + } return v; - + } -uint16_t ESP_SD::read(uint8_t * buf, uint16_t nbyte){ - if (!_readonly) return 0; +uint16_t ESP_SD::read(uint8_t * buf, uint16_t nbyte) +{ + if (!_readonly) { + return 0; + } int16_t v = ((SdFile *)_sdfile)->read(buf, nbyte); - if (v!=-1)_pos+=v; + if (v!=-1) { + _pos+=v; + } return v; } -String ESP_SD::get_path_part(String data, int index){ - int found = 0; - int strIndex[] = {0, -1}; - int maxIndex; - String no_res; - String s = data; - s.trim(); - if (s.length() == 0) return no_res; - maxIndex = s.length()-1; - if ((s[0] == '/') && (s.length() > 1)){ - String s2 = &s[1]; - s = s2; +String ESP_SD::get_path_part(String data, int index) +{ + int found = 0; + int strIndex[] = {0, -1}; + int maxIndex; + String no_res; + String s = data; + s.trim(); + if (s.length() == 0) { + return no_res; } - for(int i=0; i<=maxIndex && found<=index; i++){ - if(s.charAt(i)=='/' || i==maxIndex){ - found++; - strIndex[0] = strIndex[1]+1; - strIndex[1] = (i == maxIndex) ? i+1 : i; + maxIndex = s.length()-1; + if ((s[0] == '/') && (s.length() > 1)) { + String s2 = &s[1]; + s = s2; + } + for(int i=0; i<=maxIndex && found<=index; i++) { + if(s.charAt(i)=='/' || i==maxIndex) { + found++; + strIndex[0] = strIndex[1]+1; + strIndex[1] = (i == maxIndex) ? i+1 : i; + } } - } - return found>index ? s.substring(strIndex[0], strIndex[1]) : no_res; + return found>index ? s.substring(strIndex[0], strIndex[1]) : no_res; } -String ESP_SD::makeshortname(String longname, uint8_t index){ +String ESP_SD::makeshortname(String longname, uint8_t index) +{ String s = longname; String part_name; String part_ext; @@ -206,14 +273,17 @@ String ESP_SD::makeshortname(String longname, uint8_t index){ part_name = part_name.substring(0,6); part_name += "~" + String(index); } - //remove the possible " " for the trick + //remove the possible " " for the trick part_name.replace(" ",""); //create full short name - if (part_ext.length() > 0) part_name+="." + part_ext; + if (part_ext.length() > 0) { + part_name+="." + part_ext; + } return part_name; } -String ESP_SD::makepath83(String longpath){ +String ESP_SD::makepath83(String longpath) +{ String path; String tmp; int index = 0; @@ -229,24 +299,29 @@ String ESP_SD::makepath83(String longpath){ } -uint32_t ESP_SD::card_total_space(){ - +uint32_t ESP_SD::card_total_space() +{ + return (512.00) * (sd_volume.clusterCount()) * (sd_volume.blocksPerCluster()); } -uint32_t ESP_SD::card_used_space(){ +uint32_t ESP_SD::card_used_space() +{ return (512.00) * (sd_volume.clusterCount() - sd_volume.freeClusterCount() ) * (sd_volume.blocksPerCluster()); } -bool ESP_SD::openDir(String path){ +bool ESP_SD::openDir(String path) +{ static SdFile root; static String name; int index = 0; //SdFile *parent; - if(root.isOpen())root.close(); + if(root.isOpen()) { + root.close(); + } if (!sd_volume.init(&(card.getSd2Card()))) { return false; } - if (!root.openRoot(&sd_volume)){ + if (!root.openRoot(&sd_volume)) { return false; } root.rewind(); @@ -255,34 +330,37 @@ bool ESP_SD::openDir(String path){ name = get_path_part(path,index); while ((name.length() > 0) && (name!="/")) { SdFile newDir; - if (!newDir.open(&root, name.c_str(), O_READ)) { + if (!newDir.open(&root, name.c_str(), O_READ)) { return false; - } - workDir=newDir; - //parent = &workDir; - index++; - if (index > MAX_DIR_DEPTH) { + } + workDir=newDir; + //parent = &workDir; + index++; + if (index > MAX_DIR_DEPTH) { return false; - } - name = get_path_part(path,index); - } + } + name = get_path_part(path,index); + } return true; } //TODO may be add date and use a struct for all info -bool ESP_SD::readDir(char name[13], uint32_t * size, bool * isFile){ +bool ESP_SD::readDir(char name[13], uint32_t * size, bool * isFile) +{ if ((name == NULL) || (size==NULL)) { return false; - } + } * size = 0; name[0]= 0; * isFile = false; - - if ((workDir.readDir(&dir_info, NULL)) > 0){ + + if ((workDir.readDir(&dir_info, NULL)) > 0) { workDir.dirName(dir_info,name); * size = dir_info.fileSize; - if (DIR_IS_FILE(&dir_info))* isFile = true; + if (DIR_IS_FILE(&dir_info)) { + * isFile = true; + } return true; - } + } return false; } diff --git a/src/sd_ESP32.h b/src/sd_ESP32.h index 777852a..1af7528 100644 --- a/src/sd_ESP32.h +++ b/src/sd_ESP32.h @@ -19,11 +19,12 @@ * along with this program. If not, see . * */ - + #ifndef _ESP_SD_H_ #define _ESP_SD_H_ -class ESP_SD{ - public: +class ESP_SD +{ +public: ESP_SD(); ~ESP_SD(); int8_t card_status(); @@ -48,12 +49,12 @@ class ESP_SD{ bool openDir(String path); bool readDir(char name[13], uint32_t * size, bool * isFile); bool * isFile; - private: +private: void * _sdfile; uint32_t _size; uint32_t _pos; bool _readonly; String get_path_part(String data, int index); - + }; #endif diff --git a/src/serial2socket.cpp b/src/serial2socket.cpp index 9ca683a..d45a091 100644 --- a/src/serial2socket.cpp +++ b/src/serial2socket.cpp @@ -29,35 +29,43 @@ Serial_2_Socket Serial2Socket; -Serial_2_Socket::Serial_2_Socket(){ +Serial_2_Socket::Serial_2_Socket() +{ _web_socket = NULL; _TXbufferSize = 0; _RXbufferSize = 0; _RXbufferpos = 0; } -Serial_2_Socket::~Serial_2_Socket(){ - if (_web_socket) detachWS(); +Serial_2_Socket::~Serial_2_Socket() +{ + if (_web_socket) { + detachWS(); + } _TXbufferSize = 0; _RXbufferSize = 0; _RXbufferpos = 0; } -void Serial_2_Socket::begin(long speed){ +void Serial_2_Socket::begin(long speed) +{ _TXbufferSize = 0; _RXbufferSize = 0; _RXbufferpos = 0; } -void Serial_2_Socket::end(){ +void Serial_2_Socket::end() +{ _TXbufferSize = 0; _RXbufferSize = 0; _RXbufferpos = 0; } -long Serial_2_Socket::baudRate(){ - return 0; +long Serial_2_Socket::baudRate() +{ + return 0; } -bool Serial_2_Socket::attachWS(void * web_socket){ +bool Serial_2_Socket::attachWS(void * web_socket) +{ if (web_socket) { _web_socket = web_socket; _TXbufferSize=0; @@ -66,97 +74,125 @@ bool Serial_2_Socket::attachWS(void * web_socket){ return false; } -bool Serial_2_Socket::detachWS(){ - _web_socket = NULL; - return true; +bool Serial_2_Socket::detachWS() +{ + _web_socket = NULL; + return true; } Serial_2_Socket::operator bool() const { return true; } -int Serial_2_Socket::available(){ +int Serial_2_Socket::available() +{ return _RXbufferSize; } size_t Serial_2_Socket::write(uint8_t c) { - if(!_web_socket) return 0; + if(!_web_socket) { + return 0; + } write(&c,1); return 1; } size_t Serial_2_Socket::write(const uint8_t *buffer, size_t size) { - if((buffer == NULL) ||(!_web_socket)) { - if(buffer == NULL)log_i("[SOCKET]No buffer"); - if(!_web_socket)log_i("[SOCKET]No socket"); - return 0; + if((buffer == NULL) ||(!_web_socket)) { + if(buffer == NULL) { + log_i("[SOCKET]No buffer"); } + if(!_web_socket) { + log_i("[SOCKET]No socket"); + } + return 0; + } #if defined(ENABLE_SERIAL2SOCKET_OUT) - if (_TXbufferSize==0)_lastflush = millis(); - //send full line - if (_TXbufferSize + size > TXBUFFERSIZE) flush(); - //need periodic check to force to flush in case of no end - for (int i = 0; i < size;i++){ - _TXbuffer[_TXbufferSize] = buffer[i]; - _TXbufferSize++; - } - log_i("[SOCKET]buffer size %d",_TXbufferSize); - handle_flush(); + if (_TXbufferSize==0) { + _lastflush = millis(); + } + //send full line + if (_TXbufferSize + size > TXBUFFERSIZE) { + flush(); + } + //need periodic check to force to flush in case of no end + for (int i = 0; i < size; i++) { + _TXbuffer[_TXbufferSize] = buffer[i]; + _TXbufferSize++; + } + log_i("[SOCKET]buffer size %d",_TXbufferSize); + handle_flush(); #endif return size; } -int Serial_2_Socket::peek(void){ - if (_RXbufferSize > 0)return _RXbuffer[_RXbufferpos]; - else return -1; +int Serial_2_Socket::peek(void) +{ + if (_RXbufferSize > 0) { + return _RXbuffer[_RXbufferpos]; + } else { + return -1; + } } -bool Serial_2_Socket::push (const char * data){ +bool Serial_2_Socket::push (const char * data) +{ #if defined(ENABLE_SERIAL2SOCKET_IN) int data_size = strlen(data); - if ((data_size + _RXbufferSize) <= RXBUFFERSIZE){ + if ((data_size + _RXbufferSize) <= RXBUFFERSIZE) { int current = _RXbufferpos + _RXbufferSize; - if (current > RXBUFFERSIZE) current = current - RXBUFFERSIZE; - for (int i = 0; i < data_size; i++){ - if (current > (RXBUFFERSIZE-1)) current = 0; - _RXbuffer[current] = data[i]; - current ++; + if (current > RXBUFFERSIZE) { + current = current - RXBUFFERSIZE; + } + for (int i = 0; i < data_size; i++) { + if (current > (RXBUFFERSIZE-1)) { + current = 0; + } + _RXbuffer[current] = data[i]; + current ++; } _RXbufferSize+=strlen(data); return true; } return false; #else - return true; + return true; #endif } -int Serial_2_Socket::read(void){ +int Serial_2_Socket::read(void) +{ if (_RXbufferSize > 0) { int v = _RXbuffer[_RXbufferpos]; _RXbufferpos++; - if (_RXbufferpos > (RXBUFFERSIZE-1))_RXbufferpos = 0; + if (_RXbufferpos > (RXBUFFERSIZE-1)) { + _RXbufferpos = 0; + } _RXbufferSize--; return v; - } else return -1; + } else { + return -1; + } } -void Serial_2_Socket::handle_flush() { +void Serial_2_Socket::handle_flush() +{ if (_TXbufferSize > 0) { if ((_TXbufferSize>=TXBUFFERSIZE) || ((millis()- _lastflush) > FLUSHTIMEOUT)) { - log_i("[SOCKET]need flush, buffer size %d",_TXbufferSize); - flush(); - } + log_i("[SOCKET]need flush, buffer size %d",_TXbufferSize); + flush(); } + } } -void Serial_2_Socket::flush(void){ - if (_TXbufferSize > 0){ - log_i("[SOCKET]flush data, buffer size %d",_TXbufferSize); - ((WebSocketsServer *)_web_socket)->broadcastBIN(_TXbuffer,_TXbufferSize); - //refresh timout +void Serial_2_Socket::flush(void) +{ + if (_TXbufferSize > 0) { + log_i("[SOCKET]flush data, buffer size %d",_TXbufferSize); + ((WebSocketsServer *)_web_socket)->broadcastBIN(_TXbuffer,_TXbufferSize); + //refresh timout _lastflush = millis(); //reset buffer _TXbufferSize = 0; diff --git a/src/serial2socket.h b/src/serial2socket.h index 30a2cb0..f66326a 100644 --- a/src/serial2socket.h +++ b/src/serial2socket.h @@ -26,8 +26,9 @@ #define TXBUFFERSIZE 1200 #define RXBUFFERSIZE 128 #define FLUSHTIMEOUT 500 -class Serial_2_Socket: public Print{ - public: +class Serial_2_Socket: public Print +{ +public: Serial_2_Socket(); ~Serial_2_Socket(); size_t write(uint8_t c); @@ -65,7 +66,7 @@ class Serial_2_Socket: public Print{ operator bool() const; bool attachWS(void * web_socket); bool detachWS(); - private: +private: uint32_t _lastflush; void * _web_socket; uint8_t _TXbuffer[TXBUFFERSIZE]; diff --git a/src/web_server.cpp b/src/web_server.cpp index 3c3a968..47aa0d8 100644 --- a/src/web_server.cpp +++ b/src/web_server.cpp @@ -100,19 +100,23 @@ auth_ip * Web_Server::_head = NULL; uint8_t Web_Server::_nb_ip = 0; #define MAX_AUTH_IP 10 #endif -Web_Server::Web_Server(){ - +Web_Server::Web_Server() +{ + } -Web_Server::~Web_Server(){ +Web_Server::~Web_Server() +{ end(); } -long Web_Server::get_client_ID() { +long Web_Server::get_client_ID() +{ return _id_connection; } -bool Web_Server::begin(){ - +bool Web_Server::begin() +{ + bool no_error = true; _setupdone = false; Preferences prefs; @@ -124,7 +128,9 @@ bool Web_Server::begin(){ String defV = DEFAULT_HOSTNAME; _hostname = prefs.getString(HOSTNAME_ENTRY, defV); prefs.end(); - if (penabled == 0) return false; + if (penabled == 0) { + return false; + } //create instance _webserver= new WebServer(_port); #ifdef AUTHENTICATION_FEATURE @@ -138,37 +144,37 @@ bool Web_Server::begin(){ _socket_server->begin(); _socket_server->onEvent(handle_Websocket_Event); - + //Websocket output - Serial2Socket.attachWS(_socket_server); - + Serial2Socket.attachWS(_socket_server); + //Web server handlers //trick to catch command line on "/" before file being processed _webserver->on("/",HTTP_ANY, handle_root); - + //Page not found handler _webserver->onNotFound (handle_not_found); - + //need to be there even no authentication to say to UI no authentication _webserver->on("/login", HTTP_ANY, handle_login); - + //web commands _webserver->on ("/command", HTTP_ANY, handle_web_command); _webserver->on ("/command_silent", HTTP_ANY, handle_web_command_silent); - + //SPIFFS _webserver->on ("/files", HTTP_ANY, handleFileList, SPIFFSFileupload); - + //web update _webserver->on ("/updatefw", HTTP_ANY, handleUpdate, WebUpdateUpload); - -#if defined(SDSUPPORT) + +#if defined(SDSUPPORT) //Direct SD management _webserver->on("/upload", HTTP_ANY, handle_direct_SDFileList,SDFile_direct_upload); #endif - + #ifdef CAPTIVE_PORTAL_FEATURE - if(WiFi.getMode() == WIFI_AP){ + if(WiFi.getMode() == WIFI_AP) { // if DNSServer is started with "*" for domain name, it will reply with // provided IP to all DNS request dnsServer.start(DNS_PORT, "*", WiFi.softAPIP()); @@ -176,12 +182,12 @@ bool Web_Server::begin(){ _webserver->on ("/gconnectivitycheck.gstatic.com", HTTP_ANY, handle_root); //do not forget the / at the end _webserver->on ("/fwlink/", HTTP_ANY, handle_root); - } + } #endif //CAPTIVE_PORTAL_FEATURE - + #ifdef SSDP_FEATURE //SSDP service presentation - if(WiFi.getMode() == WIFI_STA){ + if(WiFi.getMode() == WIFI_STA) { _webserver->on ("/description.xml", HTTP_GET, handle_SSDP); //Add specific for SSDP SSDP.setSchemaURL ("description.xml"); @@ -196,7 +202,7 @@ bool Web_Server::begin(){ SSDP.setManufacturer (ESP_MANUFACTURER_NAME); SSDP.setManufacturerURL (ESP_MANUFACTURER_URL); */ - + //Start SSDP Esp3DCom::echo("SSDP service started"); SSDP.begin(); @@ -207,15 +213,16 @@ bool Web_Server::begin(){ _webserver->begin(); #ifdef MDNS_FEATURE //add mDNS - if(WiFi.getMode() == WIFI_STA){ + if(WiFi.getMode() == WIFI_STA) { MDNS.addService("http","tcp",_port); } #endif //MDNS_FEATURE _setupdone = true; - return no_error; + return no_error; } -void Web_Server::end(){ +void Web_Server::end() +{ _setupdone = false; #ifdef SSDP_FEATURE SSDP.end(); @@ -254,7 +261,7 @@ void Web_Server::handle_root() if(SPIFFS.exists(pathWithGz)) { path = pathWithGz; } - File file = SPIFFS.open(path, FILE_READ); + File file = SPIFFS.open(path, FILE_READ); _webserver->streamFile(file, contentType); file.close(); return; @@ -284,7 +291,9 @@ void Web_Server:: handle_not_found() ESP_SD SD_card; if (SD_card.card_status() == 1) { if (SD_card.exists(pathWithGz.c_str()) || SD_card.exists(path.c_str())) { - if (!SD_card.exists(path.c_str())) path = pathWithGz; + if (!SD_card.exists(path.c_str())) { + path = pathWithGz; + } if(SD_card.open(path.c_str())) { uint8_t buf[1200]; _webserver->setContentLength(SD_card.size()); @@ -292,23 +301,23 @@ void Web_Server:: handle_not_found() _webserver->send(200, "application/octet-stream", ""); WiFiClient c = _webserver->client(); - int16_t len = SD_card.read( buf, 1200); + int16_t len = SD_card.read( buf, 1200); while(len > 0) { c.write(buf, len); len = SD_card.read( buf, 1200); - Esp3DLibConfig::wait(0); - handle(); + Esp3DLibConfig::wait(0); + handle(); } - SD_card.close(); - return; + SD_card.close(); + return; } } } - - String content = "cannot find "; - content+=path; - _webserver->send(404,"text/plain",content.c_str()); - return; + + String content = "cannot find "; + content+=path; + _webserver->send(404,"text/plain",content.c_str()); + return; } else #endif if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) { @@ -352,7 +361,7 @@ void Web_Server:: handle_not_found() File file = SPIFFS.open(path, FILE_READ); _webserver->streamFile(file, contentType); file.close(); - + } else { //if not template use default page contentType = PAGE_404; @@ -470,7 +479,7 @@ void Web_Server::handle_web_command () //if command is a valid number then execute command if (cmd_part1.toInt() >= 0) { ESPResponseStream espresponse(_webserver); - //commmand is web only + //commmand is web only COMMAND::execute_internal_command (cmd_part1.toInt(), cmd_part2, auth_level, &espresponse); //flush espresponse.flush(); @@ -487,7 +496,7 @@ void Web_Server::handle_web_command () String res = "Ok"; uint8_t sindex = 0; scmd = get_Splited_Value(cmd,'\n', sindex); - while ( scmd != "" ){ + while ( scmd != "" ) { scmd+="\n"; Serial2Socket.push(scmd.c_str()); //GCodeQueue::enqueue_one_now(scmd.c_str()); @@ -500,15 +509,15 @@ void Web_Server::handle_web_command () //Handle web command query and send answer////////////////////////////// void Web_Server::handle_web_command_silent () { - //to save time if already disconnected - //if (_webserver->hasArg ("PAGEID") ) { - // if (_webserver->arg ("PAGEID").length() > 0 ) { - // if (_webserver->arg ("PAGEID").toInt() != _id_connection) { - // _webserver->send (200, "text/plain", "Invalid command"); - // return; - // } - // } - //} + //to save time if already disconnected + //if (_webserver->hasArg ("PAGEID") ) { + // if (_webserver->arg ("PAGEID").length() > 0 ) { + // if (_webserver->arg ("PAGEID").toInt() != _id_connection) { + // _webserver->send (200, "text/plain", "Invalid command"); + // return; + // } + // } + //} level_authenticate_type auth_level = is_authenticated(); String cmd = ""; if (_webserver->hasArg ("plain") || _webserver->hasArg ("commandText") ) { @@ -542,9 +551,12 @@ void Web_Server::handle_web_command_silent () } //if command is a valid number then execute command if (cmd_part1.toInt() >= 0) { - //commmand is web only - if(COMMAND::execute_internal_command (cmd_part1.toInt(), cmd_part2, auth_level, NULL)) _webserver->send (200, "text/plain", "ok"); - else _webserver->send (200, "text/plain", "error"); + //commmand is web only + if(COMMAND::execute_internal_command (cmd_part1.toInt(), cmd_part2, auth_level, NULL)) { + _webserver->send (200, "text/plain", "ok"); + } else { + _webserver->send (200, "text/plain", "error"); + } } //if not is not a valid [ESPXXX] command } @@ -558,7 +570,7 @@ void Web_Server::handle_web_command_silent () uint8_t sindex = 0; scmd = get_Splited_Value(cmd,'\n', sindex); String res = "Ok"; - while (scmd != "" ){ + while (scmd != "" ) { scmd+="\n"; Serial2Socket.push(scmd.c_str()); //GCodeQueue::enqueue_one_now(scmd.c_str()); @@ -586,7 +598,7 @@ void Web_Server::handle_login() if (pos!= -1) { int pos2 = cookie.indexOf(";",pos); sessionID = cookie.substring(pos+strlen("ESPSESSIONID="),pos2); - } + } ClearAuthIP(_webserver->client().remoteIP(), sessionID.c_str()); _webserver->sendHeader("Set-Cookie","ESPSESSIONID=0"); _webserver->sendHeader("Cache-Control","no-cache"); @@ -597,10 +609,15 @@ void Web_Server::handle_login() } level_authenticate_type auth_level = is_authenticated(); - if (auth_level == LEVEL_GUEST) auths = "guest"; - else if (auth_level == LEVEL_USER) auths = "user"; - else if (auth_level == LEVEL_ADMIN) auths = "admin"; - else auths = "???"; + if (auth_level == LEVEL_GUEST) { + auths = "guest"; + } else if (auth_level == LEVEL_USER) { + auths = "user"; + } else if (auth_level == LEVEL_ADMIN) { + auths = "admin"; + } else { + auths = "???"; + } //check is it is a submission or a query if (_webserver->hasArg("SUBMIT")) { @@ -644,15 +661,18 @@ void Web_Server::handle_login() String newpassword = _webserver->arg("NEWPASSWORD"); if (isLocalPasswordValid(newpassword.c_str())) { String spos; - if(sUser == DEFAULT_ADMIN_LOGIN) spos = ADMIN_PWD_ENTRY; - else spos = USER_PWD_ENTRY; - + if(sUser == DEFAULT_ADMIN_LOGIN) { + spos = ADMIN_PWD_ENTRY; + } else { + spos = USER_PWD_ENTRY; + } + Preferences prefs; prefs.begin(NAMESPACE, false); if (prefs.putString(spos.c_str(), newpassword) != newpassword.length()) { - msg_alert_error = true; - smsg = "Error: Cannot apply changes"; - code = 500; + msg_alert_error = true; + smsg = "Error: Cannot apply changes"; + code = 500; } prefs.end(); } else { @@ -661,77 +681,79 @@ void Web_Server::handle_login() code = 500; } } - if ((code == 200) || (code == 500)) { - level_authenticate_type current_auth_level; - if(sUser == DEFAULT_ADMIN_LOGIN) { - current_auth_level = LEVEL_ADMIN; - } else if(sUser == DEFAULT_USER_LOGIN){ - current_auth_level = LEVEL_USER; - } else { - current_auth_level = LEVEL_GUEST; - } - //create Session - if ((current_auth_level != auth_level) || (auth_level== LEVEL_GUEST)) { - auth_ip * current_auth = new auth_ip; - current_auth->level = current_auth_level; - current_auth->ip=_webserver->client().remoteIP(); - strcpy(current_auth->sessionID,create_session_ID()); - strcpy(current_auth->userID,sUser.c_str()); - current_auth->last_time=millis(); - if (AddAuthIP(current_auth)) { - String tmps ="ESPSESSIONID="; - tmps+=current_auth->sessionID; - _webserver->sendHeader("Set-Cookie",tmps); - _webserver->sendHeader("Cache-Control","no-cache"); - switch(current_auth->level) { + if ((code == 200) || (code == 500)) { + level_authenticate_type current_auth_level; + if(sUser == DEFAULT_ADMIN_LOGIN) { + current_auth_level = LEVEL_ADMIN; + } else if(sUser == DEFAULT_USER_LOGIN) { + current_auth_level = LEVEL_USER; + } else { + current_auth_level = LEVEL_GUEST; + } + //create Session + if ((current_auth_level != auth_level) || (auth_level== LEVEL_GUEST)) { + auth_ip * current_auth = new auth_ip; + current_auth->level = current_auth_level; + current_auth->ip=_webserver->client().remoteIP(); + strcpy(current_auth->sessionID,create_session_ID()); + strcpy(current_auth->userID,sUser.c_str()); + current_auth->last_time=millis(); + if (AddAuthIP(current_auth)) { + String tmps ="ESPSESSIONID="; + tmps+=current_auth->sessionID; + _webserver->sendHeader("Set-Cookie",tmps); + _webserver->sendHeader("Cache-Control","no-cache"); + switch(current_auth->level) { case LEVEL_ADMIN: auths = "admin"; break; - case LEVEL_USER: + case LEVEL_USER: auths = "user"; break; default: auths = "guest"; break; } - } else { - delete current_auth; - msg_alert_error=true; - code = 500; - smsg = "Error: Too many connections"; + } else { + delete current_auth; + msg_alert_error=true; + code = 500; + smsg = "Error: Too many connections"; + } } } - } - if (code == 200) smsg = "Ok"; + if (code == 200) { + smsg = "Ok"; + } - //build JSON - String buffer2send = "{\"status\":\"" + smsg + "\",\"authentication_lvl\":\""; - buffer2send += auths; - buffer2send += "\"}"; - _webserver->send(code, "application/json", buffer2send); + //build JSON + String buffer2send = "{\"status\":\"" + smsg + "\",\"authentication_lvl\":\""; + buffer2send += auths; + buffer2send += "\"}"; + _webserver->send(code, "application/json", buffer2send); } else { - if (auth_level != LEVEL_GUEST) { - String cookie = _webserver->header("Cookie"); - int pos = cookie.indexOf("ESPSESSIONID="); - String sessionID; - if (pos!= -1) { - int pos2 = cookie.indexOf(";",pos); - sessionID = cookie.substring(pos+strlen("ESPSESSIONID="),pos2); - auth_ip * current_auth_info = GetAuth(_webserver->client().remoteIP(), sessionID.c_str()); - if (current_auth_info != NULL){ + if (auth_level != LEVEL_GUEST) { + String cookie = _webserver->header("Cookie"); + int pos = cookie.indexOf("ESPSESSIONID="); + String sessionID; + if (pos!= -1) { + int pos2 = cookie.indexOf(";",pos); + sessionID = cookie.substring(pos+strlen("ESPSESSIONID="),pos2); + auth_ip * current_auth_info = GetAuth(_webserver->client().remoteIP(), sessionID.c_str()); + if (current_auth_info != NULL) { sUser = current_auth_info->userID; } + } } - } - String buffer2send = "{\"status\":\"200\",\"authentication_lvl\":\""; - buffer2send += auths; - buffer2send += "\",\"user\":\""; - buffer2send += sUser; - buffer2send +="\"}"; - _webserver->send(code, "application/json", buffer2send); + String buffer2send = "{\"status\":\"200\",\"authentication_lvl\":\""; + buffer2send += auths; + buffer2send += "\",\"user\":\""; + buffer2send += sUser; + buffer2send +="\"}"; + _webserver->send(code, "application/json", buffer2send); } #else - _webserver->sendHeader("Cache-Control","no-cache"); + _webserver->sendHeader("Cache-Control","no-cache"); _webserver->send(200, "application/json", "{\"status\":\"Ok\",\"authentication_lvl\":\"admin\"}"); #endif } @@ -929,7 +951,7 @@ void Web_Server::handleFileList () //SPIFFS files uploader handle void Web_Server::SPIFFSFileupload () { - //get authentication status + //get authentication status level_authenticate_type auth_level= is_authenticated(); //Guest cannot upload - only admin if (auth_level == LEVEL_GUEST) { @@ -940,20 +962,23 @@ void Web_Server::SPIFFSFileupload () } static String filename; static File fsUploadFile = (File)0; - + HTTPUpload& upload = _webserver->upload(); //Upload start //************** if(upload.status == UPLOAD_FILE_START) { String upload_filename = upload.filename; - if (upload_filename[0] != '/') filename = "/" + upload_filename; - else filename = upload.filename; + if (upload_filename[0] != '/') { + filename = "/" + upload_filename; + } else { + filename = upload.filename; + } //according User or Admin the root is different as user is isolate to /user when admin has full access if(auth_level != LEVEL_ADMIN) { upload_filename = filename; filename = "/user" + upload_filename; } - + if (SPIFFS.exists (filename) ) { SPIFFS.remove (filename); } @@ -996,7 +1021,7 @@ void Web_Server::SPIFFSFileupload () if(fsUploadFile) { //close it fsUploadFile.close(); - //check size + //check size String sizeargname = upload.filename + "S"; fsUploadFile = SPIFFS.open (filename, FILE_READ); uint32_t filesize = fsUploadFile.size(); @@ -1006,7 +1031,7 @@ void Web_Server::SPIFFSFileupload () _upload_status = UPLOAD_STATUS_FAILED; SPIFFS.remove (filename); } - } + } if (_upload_status == UPLOAD_STATUS_ONGOING) { _upload_status = UPLOAD_STATUS_SUCCESSFUL; } else { @@ -1018,25 +1043,27 @@ void Web_Server::SPIFFSFileupload () _webserver->client().stop(); if (SPIFFS.exists (filename) ) { SPIFFS.remove (filename); - } + } Esp3DCom::echo("Upload error"); } //Upload cancelled //************** } else { - if (_upload_status == UPLOAD_STATUS_ONGOING) { - _upload_status = UPLOAD_STATUS_CANCELLED; - } - if(fsUploadFile)fsUploadFile.close(); - if (SPIFFS.exists (filename) ) { - SPIFFS.remove (filename); - } - Esp3DCom::echo("Upload error"); + if (_upload_status == UPLOAD_STATUS_ONGOING) { + _upload_status = UPLOAD_STATUS_CANCELLED; + } + if(fsUploadFile) { + fsUploadFile.close(); + } + if (SPIFFS.exists (filename) ) { + SPIFFS.remove (filename); + } + Esp3DCom::echo("Upload error"); } Esp3DLibConfig::wait(0); } -//Web Update handler +//Web Update handler void Web_Server::handleUpdate () { level_authenticate_type auth_level = is_authenticated(); @@ -1072,7 +1099,7 @@ void Web_Server::WebUpdateUpload () Esp3DCom::echo("Upload rejected"); return; } - + //get current file ID HTTPUpload& upload = _webserver->upload(); //Upload start @@ -1137,7 +1164,7 @@ void Web_Server::handle_direct_SDFileList() _webserver->send(401, "application/json", "{\"status\":\"Authentication failed!\"}"); return; } - + String path="/"; String sstatus="Ok"; @@ -1148,7 +1175,7 @@ void Web_Server::handle_direct_SDFileList() bool list_files = true; ESP_SD card; int8_t state = card.card_status(); - if (state != 1){ + if (state != 1) { _webserver->sendHeader("Cache-Control","no-cache"); _webserver->send(200, "application/json", "{\"status\":\"No SD Card\"}"); return; @@ -1161,7 +1188,7 @@ void Web_Server::handle_direct_SDFileList() //to have a clean path path.trim(); path.replace("//","/"); - + //check if query need some action if(_webserver->hasArg("action")) { //delete a file @@ -1171,7 +1198,7 @@ void Web_Server::handle_direct_SDFileList() filename = path + shortname; shortname.replace("/",""); filename.replace("//","/"); - + if(!card.exists(filename.c_str())) { sstatus = shortname + " does not exist!"; } else { @@ -1209,7 +1236,7 @@ void Web_Server::handle_direct_SDFileList() //create a directory if( _webserver->arg("action")=="createdir" && _webserver->hasArg("filename")) { String filename; - String shortname = _webserver->arg("filename"); + String shortname = _webserver->arg("filename"); filename = path + shortname; shortname.replace("/",""); filename.replace("//","/"); @@ -1223,9 +1250,9 @@ void Web_Server::handle_direct_SDFileList() sstatus = shortname + " created"; } } - } + } } - + //check if no need build file list if( _webserver->hasArg("dontlist")) { if( _webserver->arg("dontlist") == "yes") { @@ -1234,7 +1261,7 @@ void Web_Server::handle_direct_SDFileList() } String jsonfile = "{" ; jsonfile+="\"files\":["; - if (!card.openDir(path)){ + if (!card.openDir(path)) { String s = "{\"status\":\" "; s += path; s+= " does not exist on SD Card\"}"; @@ -1247,7 +1274,7 @@ void Web_Server::handle_direct_SDFileList() uint32_t size; bool isFile; uint i = 0; - while (card.readDir(name,&size ,&isFile)) { + while (card.readDir(name,&size,&isFile)) { if (i>0) { jsonfile+=","; } @@ -1256,9 +1283,12 @@ void Web_Server::handle_direct_SDFileList() jsonfile+="\",\"shortname\":\""; jsonfile+=name; jsonfile+="\",\"size\":\""; - if (isFile)jsonfile+=ESPResponseStream::formatBytes(size); - else jsonfile+="-1"; - jsonfile+="\",\"datetime\":\""; + if (isFile) { + jsonfile+=ESPResponseStream::formatBytes(size); + } else { + jsonfile+="-1"; + } + jsonfile+="\",\"datetime\":\""; //TODO datatime jsonfile+="\"}"; i++; @@ -1269,15 +1299,15 @@ void Web_Server::handle_direct_SDFileList() } static uint32_t volTotal = card.card_total_space(); static uint32_t volUsed = card.card_used_space();; - //TODO + //TODO //Get right values uint32_t occupedspace = (volUsed/volTotal)*100; jsonfile+="\"total\":\""; if ( (occupedspace <= 1) && (volTotal!=volUsed)) { - occupedspace=1; - } + occupedspace=1; + } jsonfile+= ESPResponseStream::formatBytes(volTotal); ; - + jsonfile+="\",\"used\":\""; jsonfile+= ESPResponseStream::formatBytes(volUsed); ; jsonfile+="\",\"occupation\":\""; @@ -1288,7 +1318,7 @@ void Web_Server::handle_direct_SDFileList() jsonfile+= "\"status\":\""; jsonfile+=sstatus + "\""; jsonfile+= "}"; - + _webserver->sendHeader("Cache-Control","no-cache"); _webserver->send (200, "application/json", jsonfile.c_str()); _upload_status=UPLOAD_STATUS_NONE; @@ -1307,7 +1337,7 @@ void Web_Server::SDFile_direct_upload() } //retrieve current file id HTTPUpload& upload = _webserver->upload(); - + //Upload start //************** if(upload.status == UPLOAD_FILE_START) { @@ -1319,14 +1349,16 @@ void Web_Server::SDFile_direct_upload() if ( sdfile.card_status() != 1) { _upload_status=UPLOAD_STATUS_CANCELLED; Esp3DCom::echo("Upload cancelled"); - _webserver->client().stop(); + _webserver->client().stop(); return; } if (sdfile.exists (upload_filename.c_str()) ) { sdfile.remove (upload_filename.c_str()); - } - - if (sdfile.isopen())sdfile.close(); + } + + if (sdfile.isopen()) { + sdfile.close(); + } if (!sdfile.open (upload_filename.c_str(),false)) { Esp3DCom::echo("Upload cancelled"); _webserver->client().stop(); @@ -1340,14 +1372,14 @@ void Web_Server::SDFile_direct_upload() } else if(upload.status == UPLOAD_FILE_WRITE) { //we need to check SD is inside if ( sdfile.card_status() != 1) { - sdfile.close(); - Esp3DCom::echo("Upload failed"); + sdfile.close(); + Esp3DCom::echo("Upload failed"); if (sdfile.exists (upload_filename.c_str()) ) { - sdfile.remove (upload_filename.c_str()); - } - _webserver->client().stop(); - return; + sdfile.remove (upload_filename.c_str()); } + _webserver->client().stop(); + return; + } if (sdfile.isopen()) { if ( (_upload_status = UPLOAD_STATUS_ONGOING) && (upload.currentSize > 0)) { sdfile.write (upload.buf, upload.currentSize); @@ -1356,18 +1388,18 @@ void Web_Server::SDFile_direct_upload() //Upload end //************** } else if(upload.status == UPLOAD_FILE_END) { - sdfile.close(); - uint32_t filesize = sdfile.size(); - String sizeargname = upload.filename + "S"; - if (_webserver->hasArg (sizeargname.c_str()) ) { - if (_webserver->arg (sizeargname.c_str()) != String(filesize)) { - Esp3DCom::echo("Upload failed"); - _upload_status = UPLOAD_STATUS_FAILED; - } - } - if (_upload_status == UPLOAD_STATUS_ONGOING) { - _upload_status = UPLOAD_STATUS_SUCCESSFUL; + sdfile.close(); + uint32_t filesize = sdfile.size(); + String sizeargname = upload.filename + "S"; + if (_webserver->hasArg (sizeargname.c_str()) ) { + if (_webserver->arg (sizeargname.c_str()) != String(filesize)) { + Esp3DCom::echo("Upload failed"); + _upload_status = UPLOAD_STATUS_FAILED; } + } + if (_upload_status == UPLOAD_STATUS_ONGOING) { + _upload_status = UPLOAD_STATUS_SUCCESSFUL; + } } else {//Upload cancelled _upload_status=UPLOAD_STATUS_FAILED; Esp3DCom::echo("Upload failed"); @@ -1375,28 +1407,31 @@ void Web_Server::SDFile_direct_upload() sdfile.close(); if (sdfile.exists (upload_filename.c_str()) ) { sdfile.remove (upload_filename.c_str()); - } + } } Esp3DLibConfig::wait(0); } #endif -void Web_Server::handle(){ -static uint32_t timeout = millis(); +void Web_Server::handle() +{ + static uint32_t timeout = millis(); #ifdef CAPTIVE_PORTAL_FEATURE - if(WiFi.getMode() == WIFI_AP){ + if(WiFi.getMode() == WIFI_AP) { dnsServer.processNextRequest(); } #endif //CAPTIVE_PORTAL_FEATURE - if (_webserver)_webserver->handleClient(); + if (_webserver) { + _webserver->handleClient(); + } if (_socket_server && _setupdone) { Serial2Socket.handle_flush(); _socket_server->loop(); } if ((millis() - timeout) > 10000) { - if (_socket_server){ - String s = "PING:"; - s+=String(_id_connection); + if (_socket_server) { + String s = "PING:"; + s+=String(_id_connection); _socket_server->broadcastTXT(s); timeout=millis(); } @@ -1404,61 +1439,61 @@ static uint32_t timeout = millis(); } -void Web_Server::handle_Websocket_Event(uint8_t num, uint8_t type, uint8_t * payload, size_t length) { +void Web_Server::handle_Websocket_Event(uint8_t num, uint8_t type, uint8_t * payload, size_t length) +{ switch(type) { - case WStype_DISCONNECTED: - //USE_SERIAL.printf("[%u] Disconnected!\n", num); - break; - case WStype_CONNECTED: - { - IPAddress ip = _socket_server->remoteIP(num); - //USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); - String s = "CURRENT_ID:" + String(num); - // send message to client - _id_connection = num; - _socket_server->sendTXT(_id_connection, s); - s = "ACTIVE_ID:" + String(_id_connection); - _socket_server->broadcastTXT(s); - } - break; - case WStype_TEXT: - //USE_SERIAL.printf("[%u] get Text: %s\n", num, payload); + case WStype_DISCONNECTED: + //USE_SERIAL.printf("[%u] Disconnected!\n", num); + break; + case WStype_CONNECTED: { + IPAddress ip = _socket_server->remoteIP(num); + //USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); + String s = "CURRENT_ID:" + String(num); + // send message to client + _id_connection = num; + _socket_server->sendTXT(_id_connection, s); + s = "ACTIVE_ID:" + String(_id_connection); + _socket_server->broadcastTXT(s); + } + break; + case WStype_TEXT: + //USE_SERIAL.printf("[%u] get Text: %s\n", num, payload); - // send message to client - // webSocket.sendTXT(num, "message here"); + // send message to client + // webSocket.sendTXT(num, "message here"); - // send data to all connected clients - // webSocket.broadcastTXT("message here"); - break; - case WStype_BIN: - //USE_SERIAL.printf("[%u] get binary length: %u\n", num, length); - //hexdump(payload, length); + // send data to all connected clients + // webSocket.broadcastTXT("message here"); + break; + case WStype_BIN: + //USE_SERIAL.printf("[%u] get binary length: %u\n", num, length); + //hexdump(payload, length); - // send message to client - // webSocket.sendBIN(num, payload, length); - break; - default: - break; + // send message to client + // webSocket.sendBIN(num, payload, length); + break; + default: + break; } } String Web_Server::get_Splited_Value(String data, char separator, int index) { - int found = 0; - int strIndex[] = {0, -1}; - int maxIndex = data.length()-1; + int found = 0; + int strIndex[] = {0, -1}; + int maxIndex = data.length()-1; - for(int i=0; i<=maxIndex && found<=index; i++){ - if(data.charAt(i)==separator || i==maxIndex){ - found++; - strIndex[0] = strIndex[1]+1; - strIndex[1] = (i == maxIndex) ? i+1 : i; + for(int i=0; i<=maxIndex && found<=index; i++) { + if(data.charAt(i)==separator || i==maxIndex) { + found++; + strIndex[0] = strIndex[1]+1; + strIndex[1] = (i == maxIndex) ? i+1 : i; + } } - } - return found>index ? data.substring(strIndex[0], strIndex[1]) : ""; + return found>index ? data.substring(strIndex[0], strIndex[1]) : ""; } diff --git a/src/web_server.h b/src/web_server.h index c4a1b8a..39f88cf 100644 --- a/src/web_server.h +++ b/src/web_server.h @@ -39,15 +39,16 @@ struct auth_ip { #endif -class Web_Server { - public: +class Web_Server +{ +public: Web_Server(); ~Web_Server(); bool begin(); void end(); static void handle(); static long get_client_ID(); - private: +private: static bool _setupdone; static WebServer * _webserver; static long _id_connection; diff --git a/src/wificonfig.cpp b/src/wificonfig.cpp index a3c0e44..56bdf1c 100644 --- a/src/wificonfig.cpp +++ b/src/wificonfig.cpp @@ -35,10 +35,13 @@ * Helper to convert IP string to int */ -uint32_t WiFiConfig::IP_int_from_string(String & s){ +uint32_t WiFiConfig::IP_int_from_string(String & s) +{ uint32_t ip_int = 0; IPAddress ipaddr; - if (ipaddr.fromString(s)) ip_int = ipaddr; + if (ipaddr.fromString(s)) { + ip_int = ipaddr; + } return ip_int; } @@ -46,7 +49,8 @@ uint32_t WiFiConfig::IP_int_from_string(String & s){ * Helper to convert int to IP string */ -String WiFiConfig::IP_string_from_int(uint32_t ip_int){ +String WiFiConfig::IP_string_from_int(uint32_t ip_int) +{ IPAddress ipaddr(ip_int); return ipaddr.toString(); } @@ -101,30 +105,33 @@ bool WiFiConfig::isSSIDValid (const char * ssid) bool WiFiConfig::isPasswordValid (const char * password) { - if (strlen (password) == 0) return true; //open network + if (strlen (password) == 0) { + return true; //open network + } //limited size if ((strlen (password) > MAX_PASSWORD_LENGTH) || (strlen (password) < MIN_PASSWORD_LENGTH)) { return false; } //no space allowed ? - /* for (int i = 0; i < strlen (password); i++) - if (password[i] == ' ') { - return false; - }*/ + /* for (int i = 0; i < strlen (password); i++) + if (password[i] == ' ') { + return false; + }*/ return true; } /** * Check if IP string is valid */ -bool WiFiConfig::isValidIP(const char * string){ +bool WiFiConfig::isValidIP(const char * string) +{ IPAddress ip; return ip.fromString(string); } /** - * WiFi events + * WiFi events * SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready * SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP * SYSTEM_EVENT_STA_START < ESP32 station start @@ -154,8 +161,7 @@ bool WiFiConfig::isValidIP(const char * string){ void WiFiConfig::WiFiEvent(WiFiEvent_t event) { - switch (event) - { + switch (event) { case SYSTEM_EVENT_STA_GOT_IP: Esp3DCom::echo ("Connected"); Esp3DCom::echo(WiFi.localIP().toString().c_str()); @@ -186,37 +192,38 @@ int32_t WiFiConfig::getSignal (int32_t RSSI) * Connect client to AP */ -bool WiFiConfig::ConnectSTA2AP(){ +bool WiFiConfig::ConnectSTA2AP() +{ String msg, msg_out; uint8_t count = 0; uint8_t dot = 0; wl_status_t status = WiFi.status(); while (status != WL_CONNECTED && count < 40) { - - switch (status) { - case WL_NO_SSID_AVAIL: - msg="No SSID"; - break; - case WL_CONNECT_FAILED: - msg="Connection failed"; - break; - case WL_CONNECTED: - break; - default: - if ((dot>3) || (dot==0) ){ - dot=0; - msg_out = "Connecting"; - } - msg_out+="."; - msg= msg_out; - dot++; - break; + + switch (status) { + case WL_NO_SSID_AVAIL: + msg="No SSID"; + break; + case WL_CONNECT_FAILED: + msg="Connection failed"; + break; + case WL_CONNECTED: + break; + default: + if ((dot>3) || (dot==0) ) { + dot=0; + msg_out = "Connecting"; + } + msg_out+="."; + msg= msg_out; + dot++; + break; } Esp3DCom::echo(msg.c_str()); Esp3DLibConfig::wait (500); count++; status = WiFi.status(); - } + } return (status == WL_CONNECTED); } @@ -224,14 +231,19 @@ bool WiFiConfig::ConnectSTA2AP(){ * Start client mode (Station) */ -bool WiFiConfig::StartSTA(){ +bool WiFiConfig::StartSTA() +{ String defV; Preferences prefs; //stop active service wifi_services.end(); //Sanity check - if((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA))WiFi.disconnect(); - if((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA))WiFi.softAPdisconnect(); + if((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA)) { + WiFi.disconnect(); + } + if((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) { + WiFi.softAPdisconnect(); + } WiFi.enableAP (false); WiFi.mode(WIFI_STA); //Get parameters for STA @@ -242,7 +254,9 @@ bool WiFiConfig::StartSTA(){ //SSID defV = DEFAULT_STA_SSID; String SSID = prefs.getString(STA_SSID_ENTRY, defV); - if (SSID.length() == 0)SSID = DEFAULT_STA_SSID; + if (SSID.length() == 0) { + SSID = DEFAULT_STA_SSID; + } //password defV = DEFAULT_STA_PWD; String password = prefs.getString(STA_PWD_ENTRY, defV); @@ -256,13 +270,13 @@ bool WiFiConfig::StartSTA(){ //MK defV = DEFAULT_STA_MK; int32_t MK = prefs.getInt(STA_MK_ENTRY, IP_int_from_string(defV)); - prefs.end(); + prefs.end(); //if not DHCP if (IP_mode != DHCP_MODE) { IPAddress ip(IP), mask(MK), gateway(GW); WiFi.config(ip, gateway,mask); } - if (WiFi.begin(SSID.c_str(), (password.length() > 0)?password.c_str():NULL)){ + if (WiFi.begin(SSID.c_str(), (password.length() > 0)?password.c_str():NULL)) { Esp3DCom::echo("WiFi station started"); SSID = "Connecting " + SSID; Esp3DCom::echo(SSID.c_str()); @@ -277,14 +291,19 @@ bool WiFiConfig::StartSTA(){ * Setup and start Access point */ -bool WiFiConfig::StartAP(){ +bool WiFiConfig::StartAP() +{ String defV; Preferences prefs; //stop active services wifi_services.end(); //Sanity check - if((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA))WiFi.disconnect(); - if((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA))WiFi.softAPdisconnect(); + if((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA)) { + WiFi.disconnect(); + } + if((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) { + WiFi.softAPdisconnect(); + } WiFi.enableSTA (false); WiFi.mode(WIFI_AP); //Get parameters for AP @@ -292,20 +311,24 @@ bool WiFiConfig::StartAP(){ //SSID defV = DEFAULT_AP_SSID; String SSID = prefs.getString(AP_SSID_ENTRY, defV); - if (SSID.length() == 0)SSID = DEFAULT_AP_SSID; + if (SSID.length() == 0) { + SSID = DEFAULT_AP_SSID; + } //password defV = DEFAULT_AP_PWD; String password = prefs.getString(AP_PWD_ENTRY, defV); //channel int8_t channel = prefs.getChar(AP_CHANNEL_ENTRY, DEFAULT_AP_CHANNEL); - if (channel == 0)channel = DEFAULT_AP_CHANNEL; + if (channel == 0) { + channel = DEFAULT_AP_CHANNEL; + } //IP defV = DEFAULT_AP_IP; int32_t IP = prefs.getInt(AP_IP_ENTRY, IP_int_from_string(defV)); - if (IP==0){ + if (IP==0) { IP = IP_int_from_string(defV); - } - prefs.end(); + } + prefs.end(); IPAddress ip(IP); IPAddress mask; mask.fromString(DEFAULT_AP_MK); @@ -326,10 +349,15 @@ bool WiFiConfig::StartAP(){ * Stop WiFi */ -void WiFiConfig::StopWiFi(){ +void WiFiConfig::StopWiFi() +{ //Sanity check - if((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA))WiFi.disconnect(true); - if((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA))WiFi.softAPdisconnect(true); + if((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA)) { + WiFi.disconnect(true); + } + if((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) { + WiFi.softAPdisconnect(true); + } wifi_services.end(); WiFi.mode(WIFI_OFF); Esp3DCom::echo("WiFi Off"); @@ -338,34 +366,38 @@ void WiFiConfig::StopWiFi(){ /** * begin WiFi setup */ -void WiFiConfig::begin() { - Preferences prefs; - //stop active services +void WiFiConfig::begin() +{ + Preferences prefs; + //stop active services wifi_services.end(); - //setup events - WiFi.onEvent(WiFiConfig::WiFiEvent); - //open preferences as read-only - prefs.begin(NAMESPACE, true); - int8_t wifiMode = prefs.getChar(ESP_RADIO_MODE, DEFAULT_RADIO_MODE); - prefs.end(); - if (wifiMode == ESP_WIFI_AP) { - StartAP(); - //start services - wifi_services.begin(); - } else if (wifiMode == ESP_WIFI_STA){ - if(!StartSTA()){ - Esp3DCom::echo("Cannot connect to AP"); - StartAP(); - } - //start services - wifi_services.begin(); - }else WiFi.mode(WIFI_OFF); + //setup events + WiFi.onEvent(WiFiConfig::WiFiEvent); + //open preferences as read-only + prefs.begin(NAMESPACE, true); + int8_t wifiMode = prefs.getChar(ESP_RADIO_MODE, DEFAULT_RADIO_MODE); + prefs.end(); + if (wifiMode == ESP_WIFI_AP) { + StartAP(); + //start services + wifi_services.begin(); + } else if (wifiMode == ESP_WIFI_STA) { + if(!StartSTA()) { + Esp3DCom::echo("Cannot connect to AP"); + StartAP(); + } + //start services + wifi_services.begin(); + } else { + WiFi.mode(WIFI_OFF); + } } /** - * End WiFi + * End WiFi */ -void WiFiConfig::end() { +void WiFiConfig::end() +{ StopWiFi(); } @@ -373,10 +405,11 @@ void WiFiConfig::end() { /** * Handle not critical actions that must be done in sync environement */ -void WiFiConfig::handle() { +void WiFiConfig::handle() +{ //in case of restart requested - Esp3DLibConfig::handle(); - + Esp3DLibConfig::handle(); + //Services wifi_services.handle(); } diff --git a/src/wificonfig.h b/src/wificonfig.h index 72abc96..73e9080 100644 --- a/src/wificonfig.h +++ b/src/wificonfig.h @@ -26,7 +26,8 @@ #include -class WiFiConfig { +class WiFiConfig +{ public: static bool isValidIP(const char * string); static bool isPasswordValid (const char * password); @@ -42,7 +43,7 @@ public: static void begin(); static void end(); static void handle(); - private : +private : static bool ConnectSTA2AP(); static void WiFiEvent(WiFiEvent_t event); }; diff --git a/src/wifiservices.cpp b/src/wifiservices.cpp index c067d5d..2957d11 100644 --- a/src/wifiservices.cpp +++ b/src/wifiservices.cpp @@ -40,16 +40,21 @@ WiFiServices wifi_services; -WiFiServices::WiFiServices(){ +WiFiServices::WiFiServices() +{ } -WiFiServices::~WiFiServices(){ +WiFiServices::~WiFiServices() +{ end(); } -bool WiFiServices::begin(){ +bool WiFiServices::begin() +{ bool no_error = true; //Sanity check - if(WiFi.getMode() == WIFI_OFF) return false; + if(WiFi.getMode() == WIFI_OFF) { + return false; + } String h; Preferences prefs; //Get hostname @@ -63,49 +68,55 @@ bool WiFiServices::begin(){ #ifdef OTA_FEATURE ArduinoOTA .onStart([]() { - String type = "OTA:Start OTA updating "; - if (ArduinoOTA.getCommand() == U_FLASH) - type += "sketch"; - else {// U_SPIFFS - // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end() - type += "filesystem"; - SPIFFS.end(); + String type = "OTA:Start OTA updating "; + if (ArduinoOTA.getCommand() == U_FLASH) { + type += "sketch"; + } else { // U_SPIFFS + // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end() + type += "filesystem"; + SPIFFS.end(); } - Esp3DCom::echo(type.c_str()); + Esp3DCom::echo(type.c_str()); }) .onEnd([]() { - Esp3DCom::echo("OTA:End"); - + Esp3DCom::echo("OTA:End"); + }) .onProgress([](unsigned int progress, unsigned int total) { - String tmp = "OTA:OTA Progress:"; - tmp += String(progress / (total / 100)); - tmp +="%%"; - Esp3DCom::echo(tmp.c_str()); + String tmp = "OTA:OTA Progress:"; + tmp += String(progress / (total / 100)); + tmp +="%%"; + Esp3DCom::echo(tmp.c_str()); }) .onError([](ota_error_t error) { - String tmp = "OTA: Error("; - tmp += String(error) + ")"; - Esp3DCom::echo(tmp.c_str()); - if (error == OTA_AUTH_ERROR) Esp3DCom::echo("OTA:Auth Failed"); - else if (error == OTA_BEGIN_ERROR) Esp3DCom::echo("OTA:Begin Failed"); - else if (error == OTA_CONNECT_ERROR) Esp3DCom::echo("OTA:Connect Failed"); - else if (error == OTA_RECEIVE_ERROR) Esp3DCom::echo("OTA:Receive Failed"); - else if (error == OTA_END_ERROR) Esp3DCom::echo("OTA:End Failed"); + String tmp = "OTA: Error("; + tmp += String(error) + ")"; + Esp3DCom::echo(tmp.c_str()); + if (error == OTA_AUTH_ERROR) { + Esp3DCom::echo("OTA:Auth Failed"); + } else if (error == OTA_BEGIN_ERROR) { + Esp3DCom::echo("OTA:Begin Failed"); + } else if (error == OTA_CONNECT_ERROR) { + Esp3DCom::echo("OTA:Connect Failed"); + } else if (error == OTA_RECEIVE_ERROR) { + Esp3DCom::echo("OTA:Receive Failed"); + } else if (error == OTA_END_ERROR) { + Esp3DCom::echo("OTA:End Failed"); + } }); - ArduinoOTA.begin(); - Esp3DCom::echo("OTA service started"); + ArduinoOTA.begin(); + Esp3DCom::echo("OTA service started"); #endif #ifdef MDNS_FEATURE - //no need in AP mode - if(WiFi.getMode() == WIFI_STA){ + //no need in AP mode + if(WiFi.getMode() == WIFI_STA) { //start mDns if (!MDNS.begin(h.c_str())) { Esp3DCom::echo("Cannot start mDNS"); no_error = false; } else { - String tmp = "mDNS service (" + h; - tmp+=") started"; + String tmp = "mDNS service (" + h; + tmp+=") started"; Esp3DCom::echo(tmp.c_str()); } } @@ -115,7 +126,8 @@ bool WiFiServices::begin(){ #endif //HTTP_FEATURE return no_error; } -void WiFiServices::end(){ +void WiFiServices::end() +{ #ifdef HTTP_FEATURE web_server.end(); #endif @@ -125,14 +137,15 @@ void WiFiServices::end(){ #endif //OTA_FEATURE //Stop SPIFFS SPIFFS.end(); - + #ifdef MDNS_FEATURE //Stop mDNS //MDNS.end(); #endif //MDNS_FEATURE } -void WiFiServices::handle(){ +void WiFiServices::handle() +{ #ifdef OTA_FEATURE ArduinoOTA.handle(); #endif //OTA_FEATURE diff --git a/src/wifiservices.h b/src/wifiservices.h index 790fd67..6ffdc0d 100644 --- a/src/wifiservices.h +++ b/src/wifiservices.h @@ -24,8 +24,9 @@ #define _WIFI_SERVICES_H -class WiFiServices { - public: +class WiFiServices +{ +public: WiFiServices(); ~WiFiServices(); static bool begin();