diff --git a/.vscode/extensions.json b/.vscode/extensions.json index e80666bf..0f0d7401 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,7 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/esp3d/src/core/commands.cpp b/esp3d/src/core/commands.cpp index cb43a551..7daeb4da 100644 --- a/esp3d/src/core/commands.cpp +++ b/esp3d/src/core/commands.cpp @@ -333,6 +333,11 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_ case 112: response = ESP112(cmd_params, auth_type, output); break; + //Get/Set boot Network (WiFi/BT/Ethernet) state which can be ON, OFF + //[ESP114]pwd= + case 114: + response = ESP114(cmd_params, auth_type, output); + break; //Get/Set immediate Network (WiFi/BT/Ethernet) state which can be ON, OFF //[ESP115]pwd= case 115: diff --git a/esp3d/src/core/commands.h b/esp3d/src/core/commands.h index 8b85292e..5f47e8f6 100644 --- a/esp3d/src/core/commands.h +++ b/esp3d/src/core/commands.h @@ -59,6 +59,7 @@ public: #endif //WIFI_FEATURE || ETH_FEATURE #if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE) bool ESP112(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); + bool ESP114(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); bool ESP115(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); #endif //WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE #if defined(HTTP_FEATURE) diff --git a/esp3d/src/core/esp3d.cpp b/esp3d/src/core/esp3d.cpp index 6f2c8bd5..51476f64 100644 --- a/esp3d/src/core/esp3d.cpp +++ b/esp3d/src/core/esp3d.cpp @@ -116,11 +116,14 @@ bool Esp3D::begin() log_esp3d("Main screen"); #endif //DISPLAY_DEVICE //Setup Network -#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) - if (!NetConfig::begin()) { +#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BLUETOOTH_FEATURE) + if (Settings_ESP3D::read_byte(ESP_BOOT_RADIO_STATE) == 1){ + if (!NetConfig::begin()) { log_esp3d("Error setup network"); res = false; + } } + #endif //WIFI_FEATURE #if defined(ESP_AUTOSTART_SCRIPT) esp3d_gcode_host.processscript(ESP_AUTOSTART_SCRIPT); diff --git a/esp3d/src/core/espcmd/ESP0.cpp b/esp3d/src/core/espcmd/ESP0.cpp index e68f01c2..0151f3e5 100644 --- a/esp3d/src/core/espcmd/ESP0.cpp +++ b/esp3d/src/core/espcmd/ESP0.cpp @@ -45,6 +45,7 @@ const char * help[]= {"[ESP] - display this help", #endif //WIFI_FEATURE || ETH_FEATURE #if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE) "[ESP112](Hostname) - display/set Hostname", + "[ESP114](State) - display/set boot Network state which can be ON, OFF", "[ESP115](State) - display/set immediate Network state which can be ON, OFF", #endif //WIFI_FEATURE || ETH_FEATURE || BT_FEATURE #if defined(HTTP_FEATURE) diff --git a/esp3d/src/core/espcmd/ESP114.cpp b/esp3d/src/core/espcmd/ESP114.cpp new file mode 100644 index 00000000..6bc3a320 --- /dev/null +++ b/esp3d/src/core/espcmd/ESP114.cpp @@ -0,0 +1,69 @@ +/* + ESP114.cpp - ESP3D command class + + Copyright (c) 2014 Luc Lebosse. All rights reserved. + + This code is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with This code; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "../../include/esp3d_config.h" +#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE) +#include "../commands.h" +#include "../esp3doutput.h" +#include "../settings_esp3d.h" +#include "../../modules/authentication/authentication_service.h" + +//Set Boot radio state which can be ON, OFF +//[ESP114]pwd= +bool Commands::ESP114(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output) +{ + bool response = true; + String parameter; +#ifdef AUTHENTICATION_FEATURE + if (auth_type == LEVEL_GUEST) { + output->printERROR("Wrong authentication!", 401); + return false; + } +#else + (void)auth_type; +#endif //AUTHENTICATION_FEATURE + parameter = get_param (cmd_params, ""); + //get + if (parameter.length() == 0) { + output->printMSG((Settings_ESP3D::read_byte(ESP_BOOT_RADIO_STATE) == 0)?"OFF":"ON"); + } else { //set +#ifdef AUTHENTICATION_FEATURE + if (auth_type != LEVEL_ADMIN) { + output->printERROR("Wrong authentication!", 401); + return false; + } +#endif //AUTHENTICATION_FEATURE + parameter.toUpperCase(); + if (!((parameter == "ON") || (parameter == "OFF"))) { + output->printERROR("Only ON or OFF mode supported!"); + return false; + } else { + if (!Settings_ESP3D::write_byte (ESP_BOOT_RADIO_STATE, (parameter == "ON")?1:0)) { + output->printERROR ("Set failed!"); + response = false; + } + else { + output->printMSG ("ok"); + } + } + } + return response; +} + +#endif //defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE) \ No newline at end of file diff --git a/esp3d/src/core/espcmd/ESP115.cpp b/esp3d/src/core/espcmd/ESP115.cpp index c0eb1603..93c89bca 100644 --- a/esp3d/src/core/espcmd/ESP115.cpp +++ b/esp3d/src/core/espcmd/ESP115.cpp @@ -61,6 +61,7 @@ bool Commands::ESP115(const char* cmd_params, level_authenticate_type auth_type, response = false; } } else { + output->printMSG ("OFF"); NetConfig::end(); } } else { diff --git a/esp3d/src/core/espcmd/ESP400.cpp b/esp3d/src/core/espcmd/ESP400.cpp index 83ea4715..c4c4e718 100644 --- a/esp3d/src/core/espcmd/ESP400.cpp +++ b/esp3d/src/core/espcmd/ESP400.cpp @@ -71,6 +71,14 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type, output->print (",{\"eth-sta\":\"4\"}"); #endif //ETH_FEATURE output->print ("]}"); +#if defined (WIFI_FEATURE) || defined (ETH_FEATURE) || defined(BT_FEATURE) + //Radio State at Boot + output->print (",{\"F\":\"network/network\",\"P\":\""); + output->print (ESP_BOOT_RADIO_STATE); + output->print ("\",\"T\":\"B\",\"R\":\"1\",\"V\":\""); + output->print (Settings_ESP3D::read_byte(ESP_BOOT_RADIO_STATE)); + output->print ("\",\"H\":\"radio_boot\",\"O\":[{\"no\":\"0\"},{\"yes\":\"1\"}]}"); +#endif // #ifdef WIFI_FEATURE //STA SSID network/sta output->print (",{\"F\":\"network/sta\",\"P\":\""); diff --git a/esp3d/src/core/settings_esp3d.cpp b/esp3d/src/core/settings_esp3d.cpp index cb4cd013..cd742701 100644 --- a/esp3d/src/core/settings_esp3d.cpp +++ b/esp3d/src/core/settings_esp3d.cpp @@ -119,7 +119,7 @@ #define DEFAULT_NOTIFICATION_SETTINGS "" #define DEFAULT_AUTO_NOTIFICATION_STATE 1 #define DEFAULT_SECURE_SERIAL 1 - +#define DEFAULT_BOOT_RADIO_STATE 1 //default int values #define DEFAULT_ESP_INT 0L @@ -240,6 +240,9 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos) { uint8_t res; switch(pos) { + case ESP_BOOT_RADIO_STATE: + res = DEFAULT_BOOT_RADIO_STATE; + break; case ESP_SECURE_SERIAL: res = DEFAULT_SECURE_SERIAL; break; @@ -1047,6 +1050,7 @@ bool Settings_ESP3D::reset(bool networkonly) { //radio mode Settings_ESP3D::write_byte(ESP_RADIO_MODE,Settings_ESP3D::get_default_byte_value(ESP_RADIO_MODE)); + Settings_ESP3D::write_byte(ESP_BOOT_RADIO_STATE,Settings_ESP3D::get_default_byte_value(ESP_BOOT_RADIO_STATE)); #if defined (WIFI_FEATURE) //STA SSID Settings_ESP3D::write_string(ESP_STA_SSID,Settings_ESP3D::get_default_string_value(ESP_STA_SSID).c_str()); diff --git a/esp3d/src/core/settings_esp3d.h b/esp3d/src/core/settings_esp3d.h index 475bab24..52125e65 100644 --- a/esp3d/src/core/settings_esp3d.h +++ b/esp3d/src/core/settings_esp3d.h @@ -106,6 +106,7 @@ #define ESP_WEBDAV_PORT 1025 //4 bytes= int #define ESP_STA_DNS_VALUE 1029 //4 bytes= int #define ESP_SECURE_SERIAL 1033 //1 byte = flag +#define ESP_BOOT_RADIO_STATE 1034 //1 byte = flag //Hidden password diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index 9e97c952..f76fca12 100644 --- a/esp3d/src/include/version.h +++ b/esp3d/src/include/version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H //version and sources location -#define FW_VERSION "3.0.0.a97" +#define FW_VERSION "3.0.0.a98" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H