mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-05 16:20:37 +08:00
add feature to disable network at boot suggested by @pmjdebruijn
Add ESP114 command to handle it
This commit is contained in:
parent
8753249cd9
commit
b4a6ca3c54
14
.vscode/extensions.json
vendored
14
.vscode/extensions.json
vendored
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
// for the documentation about the extensions.json format
|
// for the documentation about the extensions.json format
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"platformio.platformio-ide"
|
"platformio.platformio-ide"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -333,6 +333,11 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_
|
|||||||
case 112:
|
case 112:
|
||||||
response = ESP112(cmd_params, auth_type, output);
|
response = ESP112(cmd_params, auth_type, output);
|
||||||
break;
|
break;
|
||||||
|
//Get/Set boot Network (WiFi/BT/Ethernet) state which can be ON, OFF
|
||||||
|
//[ESP114]<state>pwd=<admin password>
|
||||||
|
case 114:
|
||||||
|
response = ESP114(cmd_params, auth_type, output);
|
||||||
|
break;
|
||||||
//Get/Set immediate Network (WiFi/BT/Ethernet) state which can be ON, OFF
|
//Get/Set immediate Network (WiFi/BT/Ethernet) state which can be ON, OFF
|
||||||
//[ESP115]<state>pwd=<admin password>
|
//[ESP115]<state>pwd=<admin password>
|
||||||
case 115:
|
case 115:
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||||
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_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 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);
|
bool ESP115(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||||
#endif //WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
|
#endif //WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
|
||||||
#if defined(HTTP_FEATURE)
|
#if defined(HTTP_FEATURE)
|
||||||
|
@ -116,11 +116,14 @@ bool Esp3D::begin()
|
|||||||
log_esp3d("Main screen");
|
log_esp3d("Main screen");
|
||||||
#endif //DISPLAY_DEVICE
|
#endif //DISPLAY_DEVICE
|
||||||
//Setup Network
|
//Setup Network
|
||||||
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
|
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BLUETOOTH_FEATURE)
|
||||||
if (!NetConfig::begin()) {
|
if (Settings_ESP3D::read_byte(ESP_BOOT_RADIO_STATE) == 1){
|
||||||
|
if (!NetConfig::begin()) {
|
||||||
log_esp3d("Error setup network");
|
log_esp3d("Error setup network");
|
||||||
res = false;
|
res = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //WIFI_FEATURE
|
#endif //WIFI_FEATURE
|
||||||
#if defined(ESP_AUTOSTART_SCRIPT)
|
#if defined(ESP_AUTOSTART_SCRIPT)
|
||||||
esp3d_gcode_host.processscript(ESP_AUTOSTART_SCRIPT);
|
esp3d_gcode_host.processscript(ESP_AUTOSTART_SCRIPT);
|
||||||
|
@ -45,6 +45,7 @@ const char * help[]= {"[ESP] - display this help",
|
|||||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||||
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE)
|
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE)
|
||||||
"[ESP112](Hostname) - display/set Hostname",
|
"[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",
|
"[ESP115](State) - display/set immediate Network state which can be ON, OFF",
|
||||||
#endif //WIFI_FEATURE || ETH_FEATURE || BT_FEATURE
|
#endif //WIFI_FEATURE || ETH_FEATURE || BT_FEATURE
|
||||||
#if defined(HTTP_FEATURE)
|
#if defined(HTTP_FEATURE)
|
||||||
|
69
esp3d/src/core/espcmd/ESP114.cpp
Normal file
69
esp3d/src/core/espcmd/ESP114.cpp
Normal file
@ -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]<state>pwd=<user/admin password>
|
||||||
|
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)
|
@ -61,6 +61,7 @@ bool Commands::ESP115(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
response = false;
|
response = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
output->printMSG ("OFF");
|
||||||
NetConfig::end();
|
NetConfig::end();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,6 +71,14 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
output->print (",{\"eth-sta\":\"4\"}");
|
output->print (",{\"eth-sta\":\"4\"}");
|
||||||
#endif //ETH_FEATURE
|
#endif //ETH_FEATURE
|
||||||
output->print ("]}");
|
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
|
#ifdef WIFI_FEATURE
|
||||||
//STA SSID network/sta
|
//STA SSID network/sta
|
||||||
output->print (",{\"F\":\"network/sta\",\"P\":\"");
|
output->print (",{\"F\":\"network/sta\",\"P\":\"");
|
||||||
|
@ -119,7 +119,7 @@
|
|||||||
#define DEFAULT_NOTIFICATION_SETTINGS ""
|
#define DEFAULT_NOTIFICATION_SETTINGS ""
|
||||||
#define DEFAULT_AUTO_NOTIFICATION_STATE 1
|
#define DEFAULT_AUTO_NOTIFICATION_STATE 1
|
||||||
#define DEFAULT_SECURE_SERIAL 1
|
#define DEFAULT_SECURE_SERIAL 1
|
||||||
|
#define DEFAULT_BOOT_RADIO_STATE 1
|
||||||
|
|
||||||
//default int values
|
//default int values
|
||||||
#define DEFAULT_ESP_INT 0L
|
#define DEFAULT_ESP_INT 0L
|
||||||
@ -240,6 +240,9 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos)
|
|||||||
{
|
{
|
||||||
uint8_t res;
|
uint8_t res;
|
||||||
switch(pos) {
|
switch(pos) {
|
||||||
|
case ESP_BOOT_RADIO_STATE:
|
||||||
|
res = DEFAULT_BOOT_RADIO_STATE;
|
||||||
|
break;
|
||||||
case ESP_SECURE_SERIAL:
|
case ESP_SECURE_SERIAL:
|
||||||
res = DEFAULT_SECURE_SERIAL;
|
res = DEFAULT_SECURE_SERIAL;
|
||||||
break;
|
break;
|
||||||
@ -1047,6 +1050,7 @@ bool Settings_ESP3D::reset(bool networkonly)
|
|||||||
{
|
{
|
||||||
//radio mode
|
//radio mode
|
||||||
Settings_ESP3D::write_byte(ESP_RADIO_MODE,Settings_ESP3D::get_default_byte_value(ESP_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)
|
#if defined (WIFI_FEATURE)
|
||||||
//STA SSID
|
//STA SSID
|
||||||
Settings_ESP3D::write_string(ESP_STA_SSID,Settings_ESP3D::get_default_string_value(ESP_STA_SSID).c_str());
|
Settings_ESP3D::write_string(ESP_STA_SSID,Settings_ESP3D::get_default_string_value(ESP_STA_SSID).c_str());
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
#define ESP_WEBDAV_PORT 1025 //4 bytes= int
|
#define ESP_WEBDAV_PORT 1025 //4 bytes= int
|
||||||
#define ESP_STA_DNS_VALUE 1029 //4 bytes= int
|
#define ESP_STA_DNS_VALUE 1029 //4 bytes= int
|
||||||
#define ESP_SECURE_SERIAL 1033 //1 byte = flag
|
#define ESP_SECURE_SERIAL 1033 //1 byte = flag
|
||||||
|
#define ESP_BOOT_RADIO_STATE 1034 //1 byte = flag
|
||||||
|
|
||||||
|
|
||||||
//Hidden password
|
//Hidden password
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#define _VERSION_ESP3D_H
|
#define _VERSION_ESP3D_H
|
||||||
|
|
||||||
//version and sources location
|
//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"
|
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
||||||
|
|
||||||
#endif //_VERSION_ESP3D_H
|
#endif //_VERSION_ESP3D_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user