mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-14 07:06:02 +08:00
Settings validation refactoring (#964)
* Rewrite the setting API to use same API as ESP3D-TFT or at least close enough to be improved - WIP * Add isValidXXX setting API * Factorize dispatch_setting for ESP400 * ESP400 refactoring
This commit is contained in:
parent
265e0e60a2
commit
cda276e2e6
270
docs/espXXX.md
270
docs/espXXX.md
@ -1552,132 +1552,180 @@ the admin password if authentication is enabled
|
||||
|
||||
+++
|
||||
archetype = "section"
|
||||
title = "[ESP800]"
|
||||
title = "[ESP400]"
|
||||
weight = 800
|
||||
+++
|
||||
Get FW capabilities
|
||||
Get full ESP3D settings
|
||||
|
||||
## Input
|
||||
|
||||
`[ESP800]<time=YYYY-MM-DDTHH:mm:ss> <tzone=+HH:ss> <version=3.0.0-a11> <setup=0/1> json=<no> pwd=<admin/user password>`
|
||||
`[ESP400] json=<no> pwd=<admin password>`
|
||||
|
||||
* json=no
|
||||
the output format
|
||||
can be in JSON or plain text
|
||||
|
||||
* time=
|
||||
to set ESP3D time using ISO 8601 format : `YYYY`-`MM`-`DD`T`HH`:`minutes`:`seconds`
|
||||
|
||||
* tzone=
|
||||
to set ESP3D time zone using ISO 8601 format : `+`/`-` `HH`:`minutes`
|
||||
|
||||
* pwd=<admin password>
|
||||
the admin password if authentication is enabled
|
||||
|
||||
* version
|
||||
version of webUI
|
||||
* setup flag
|
||||
Enable / Disable the setup flag
|
||||
|
||||
## Output
|
||||
|
||||
- In json format
|
||||
Passwords are not displayed and replaced by `********`
|
||||
|
||||
```json
|
||||
{
|
||||
"cmd":"800",
|
||||
"status":"ok",
|
||||
"data":{
|
||||
"FWVersion":"bugfix-2.0.x-3.0.0.a200",
|
||||
"FWTarget":"marlin",
|
||||
"FWTargetID":"30",
|
||||
"Setup":"Enabled",
|
||||
"SDConnection":"shared",
|
||||
"SerialProtocol":"Socket",
|
||||
"Authentication":"Disabled",
|
||||
"WebCommunication":"Synchronous",
|
||||
"WebSocketIP":"192.168.2.117",
|
||||
"WebSocketPort":"81",
|
||||
"Hostname":"esp3d",
|
||||
"WiFiMode":"STA",
|
||||
"WebUpdate":"Enabled",
|
||||
"FlashFileSystem":"LittleFS",
|
||||
"HostPath":"www",
|
||||
"Time":"none"
|
||||
}
|
||||
}
|
||||
* if json
|
||||
```json
|
||||
{"cmd":"400","status":"ok","data":[
|
||||
{"F":"network/network","P":"130","T":"S","R":"1","V":"esp3d","H":"hostname" ,"S":"32", "M":"1"},
|
||||
{"F":"network/network","P":"0","T":"B","R":"1","V":"1","H":"radio mode","O":[{"none":"0"},
|
||||
{"sta":"1"},
|
||||
{"ap":"2"},
|
||||
{"setup":"5"}]},
|
||||
{"F":"network/network","P":"1034","T":"B","R":"1","V":"1","H":"radio_boot","O":[{"no":"0"},
|
||||
{"yes":"1"}]},
|
||||
{"F":"network/sta","P":"1","T":"S","V":"Luc-Lab","S":"32","H":"SSID","M":"1"},
|
||||
{"F":"network/sta","P":"34","T":"S","N":"1","MS":"0","R":"1","V":"********","S":"64","H":"pwd","M":"8"},
|
||||
{"F":"network/sta","P":"99","T":"B","R":"1","V":"1","H":"ip mode","O":[{"dhcp":"1"},
|
||||
{"static":"0"}]},
|
||||
{"F":"network/sta","P":"100","T":"A","R":"1","V":"192.168.0.1","H":"ip"},
|
||||
{"F":"network/sta","P":"108","T":"A","R":"1","V":"192.168.0.1","H":"gw"},
|
||||
{"F":"network/sta","P":"104","T":"A","R":"1","V":"255.255.255.0","H":"msk"},
|
||||
{"F":"network/sta","P":"1029","T":"A","R":"1","V":"192.168.0.1","H":"DNS"},
|
||||
{"F":"network/sta","P":"1035","T":"B","R":"0","V":"5","H":"sta fallback mode","O":[{"none":"0"},
|
||||
{"setup":"5"}]},
|
||||
{"F":"network/ap","P":"218","T":"S","R":"1","V":"ESP3D","S":"32","H":"SSID","M":"1"},
|
||||
{"F":"network/ap","P":"251","T":"S","N":"1","MS":"0","R":"1","V":"********","S":"64","H":"pwd","M":"8"},
|
||||
{"F":"network/ap","P":"316","T":"A","R":"1","V":"192.168.0.1","H":"ip"},
|
||||
{"F":"network/ap","P":"118","T":"B","R":"1","V":"11","H":"channel","O":[{"1":"1"},
|
||||
{"2":"2"},
|
||||
{"3":"3"},
|
||||
{"4":"4"},
|
||||
{"5":"5"},
|
||||
{"6":"6"},
|
||||
{"7":"7"},
|
||||
{"8":"8"},
|
||||
{"9":"9"},
|
||||
{"10":"10"},
|
||||
{"11":"11"},
|
||||
{"12":"12"},
|
||||
{"13":"13"},
|
||||
{"14":"14"}]},
|
||||
{"F":"service/http","P":"328","T":"B","R":"1","V":"1","H":"enable","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"service/http","P":"121","T":"I","R":"1","V":"8181","H":"port","S":"65001","M":"1"},
|
||||
{"F":"service/telnetp","P":"329","T":"B","R":"1","V":"1","H":"enable","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"service/telnetp","P":"125","T":"I","R":"1","V":"23","H":"port","S":"65001","M":"1"},
|
||||
{"F":"service/webdavp","P":"1024","T":"B","R":"1","V":"1","H":"enable","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"service/webdavp","P":"1025","T":"I","R":"1","V":"80","H":"port","S":"65001","M":"1"},
|
||||
{"F":"service/time","P":"120","T":"B","V":"1","H":"i-time","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"service/time","P":"1042","T":"S","R":"1","V":"+08:00","H":"tzone","O":[{"-12:00":"-12:00"},
|
||||
{"-11:00":"-11:00"},
|
||||
{"-10:00":"-10:00"},
|
||||
{"-09:00":"-09:00"},
|
||||
{"-08:00":"-08:00"},
|
||||
{"-07:00":"-07:00"},
|
||||
{"-06:00":"-06:00"},
|
||||
{"-05:00":"-05:00"},
|
||||
{"-04:00":"-04:00"},
|
||||
{"-03:30":"-03:30"},
|
||||
{"-03:00":"-03:00"},
|
||||
{"-02:00":"-02:00"},
|
||||
{"-01:00":"-01:00"},
|
||||
{"+00:00":"+00:00"},
|
||||
{"+01:00":"+01:00"},
|
||||
{"+02:00":"+02:00"},
|
||||
{"+03:00":"+03:00"},
|
||||
{"+03:30":"+03:30"},
|
||||
{"+04:00":"+04:00"},
|
||||
{"+04:30":"+04:30"},
|
||||
{"+05:00":"+05:00"},
|
||||
{"+05:30":"+05:30"},
|
||||
{"+05:45":"+05:45"},
|
||||
{"+06:00":"+06:00"},
|
||||
{"+06:30":"+06:30"},
|
||||
{"+07:00":"+07:00"},
|
||||
{"+08:00":"+08:00"},
|
||||
{"+08:45":"+08:45"},
|
||||
{"+09:00":"+09:00"},
|
||||
{"+09:30":"+09:30"},
|
||||
{"+10:00":"+10:00"},
|
||||
{"+10:30":"+10:30"},
|
||||
{"+11:00":"+11:00"},
|
||||
{"+12:00":"+12:00"},
|
||||
{"+12:45":"+12:45"},
|
||||
{"+13:00":"+13:00"},
|
||||
{"+14:00":"+14:00"}]},
|
||||
{"F":"service/time","P":"464","T":"S","R":"1","V":"time.windows.com","S":"128","H":"t-server","M":"0"},
|
||||
{"F":"service/time","P":"593","T":"S","R":"1","V":"time.google.com","S":"128","H":"t-server","M":"0"},
|
||||
{"F":"service/time","P":"722","T":"S","R":"1","V":"0.pool.ntp.org","S":"128","H":"t-server","M":"0"},
|
||||
{"F":"service/notification","P":"1022","T":"B","R":"1","V":"1","H":"auto notif","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"service/notification","P":"116","T":"B","R":"1","V":"0","H":"notification","O":[{"none":"0"},
|
||||
{"pushover":"1"},
|
||||
{"email":"2"},
|
||||
{"line":"3"},
|
||||
{"telegram":"4"},
|
||||
{"IFTTT":"5"}]},
|
||||
{"F":"service/notification","P":"332","T":"S","R":"1","V":"********","S":"63","H":"t1","M":"0"},
|
||||
{"F":"service/notification","P":"396","T":"S","R":"1","V":"********","S":"63","H":"t2","M":"0"},
|
||||
{"F":"service/notification","P":"856","T":"S","R":"1","V":" ","S":"128","H":"ts","M":"0"},
|
||||
{"F":"system/system","P":"461","T":"B","V":"0","H":"targetfw","O":[{"repetier":"50"},
|
||||
{"marlin":"20"},
|
||||
{"smoothieware":"40"},
|
||||
{"grbl":"10"},
|
||||
{"unknown":"0"}]},
|
||||
{"F":"system/system","P":"112","T":"I","V":"115200","H":"baud","O":[{"9600":"9600"},
|
||||
{"19200":"19200"},
|
||||
{"38400":"38400"},
|
||||
{"57600":"57600"},
|
||||
{"74880":"74880"},
|
||||
{"115200":"115200"},
|
||||
{"230400":"230400"},
|
||||
{"250000":"250000"},
|
||||
{"500000":"500000"},
|
||||
{"921600":"921600"},
|
||||
{"1958400":"1958400"}]},
|
||||
{"F":"system/boot","P":"320","T":"I","V":"100","H":"bootdelay","S":"40000","M":"0"},
|
||||
{"F":"system/boot","P":"1023","T":"B","V":"0","H":"verbose","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"system/outputmsg","P":"129","T":"B","V":"1","H":"serial","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"system/outputmsg","P":"851","T":"B","V":"1","H":"M117","O":[{"no":"0"},{"yes":"1"}]},
|
||||
{"F":"system/outputmsg","P":"1006","T":"B","V":"1","H":"telnet","O":[{"no":"0"},{"yes":"1"}]
|
||||
}]}
|
||||
```
|
||||
|
||||
1 - key : `Settings`
|
||||
2 - value: array of data formated like this
|
||||
{"F":"network/network","P":"130","T":"S","V":"esp3d","H":"hostname","S":"32","M":"1"}
|
||||
or
|
||||
{"F":"service/notification","P":"1004","T":"B","V":"1","H":"auto notif","O":[{"no":"0"},{"yes":"1"}]}
|
||||
|
||||
- F: is filter formated as section/sub-section, if section is same as sub-section, it means no sub-section
|
||||
- P: is id (also position reference so it is unique)
|
||||
- T: is type of data which can be:
|
||||
- S: for string
|
||||
- I: for integer
|
||||
- B: for Byte
|
||||
- A: for IP address / Mask
|
||||
- F: for float (only grblHAL)
|
||||
- M: for bits mask (only grblHAL)
|
||||
- X: for exclusive bitsfield (only grblHAL)
|
||||
- V: is current value, if type is string and value is `********`, (8 stars) then it is a password
|
||||
- E: is integer for exactess / precision of float/double value (only grblHAL)
|
||||
- U: is text unit of value (only grblHAL)
|
||||
- H: is text label of value
|
||||
- S: is max size if type is string, and max possible value if value is number (byte, integer)
|
||||
- M: is min size if type is string, and min possible value if value is number (byte, integer)
|
||||
- MS: is additionnal min size if type is string (e.g for password can be 0 or 8, so need additional min size), M should be the more minimal value
|
||||
so MS value must be between M and S
|
||||
- O: is an array of {label:value} used for possible values in selection or bits labels list
|
||||
- R: need restart to be applied
|
||||
|
||||
Note: if Type `M` and `X` use `O` entry to define the label / position, if `O` is `[]` then axis label are used according need `X`, `Y`, `Z`, `A`, `B`, `C`
|
||||
Note2 : the 2.1 Flag type is no more used, several entries are used instead grouped by sub-section
|
||||
|
||||
If no json the list is limited to a list of `<help>: <value>`
|
||||
|
||||
```text
|
||||
|
||||
Settings:
|
||||
network/network/hostname: esp3d
|
||||
network/network/mdns: 1
|
||||
```
|
||||
|
||||
* `cmd`
|
||||
Id of requested command, should be `800`
|
||||
|
||||
* `status`
|
||||
status of command, should be `ok`
|
||||
|
||||
* `data`
|
||||
content of response:
|
||||
* `FWVersion`
|
||||
Version of ESP3D firmware or targeted FW (Marlin with ESP3DLib / grblHal)
|
||||
* `FWTarget`
|
||||
name of targeted Firmware
|
||||
* `FWTargetID`
|
||||
numerical ID of targeted FW as same name can have several Ids
|
||||
* `Setup`
|
||||
Should be `Enabled` or `Disabled` according flag in EEPROM/Preferences, this allows to WedUI to start wizard automaticaly (or not)
|
||||
|
||||
* `SDConnection`
|
||||
This is SD capability, SD can be
|
||||
* `shared`
|
||||
ESP does share access to SD card reader with main board or Firmware (Marlin with ESP3Dlib, ESP3D with hardware SD share solution)
|
||||
* `direct`
|
||||
ESP does have direct access to SD card reader (e.g: ESP3D, grblHal)
|
||||
* `none`
|
||||
ESP does not have direct access to SD card reader, (e.g: ESP3D with only serial connection)
|
||||
* `SerialProtocol`
|
||||
It define how ESP3D FW communicate with main FW
|
||||
* `Socket`
|
||||
ESP and main FW use same FW (e.g: Marlin with ESP3DLib, grblHal)
|
||||
* `Raw`
|
||||
Classic serial connection
|
||||
* `MKS`
|
||||
Serial connection using MKS protocol
|
||||
* `Authentication`
|
||||
Can be `Enabled` or `Disabled`
|
||||
* `WebCommunication`
|
||||
currently only `Synchronous`, because `Asychronous` has been put in hold
|
||||
* `WebSocketIP`
|
||||
Ip address for the websocket terminal `192.168.2.117`
|
||||
* `WebSocketPort`
|
||||
Port for the web socket terminal `81`
|
||||
* `Hostname`
|
||||
Hostname of ESP3D or main Baord `esp3d`
|
||||
* `WiFiMode`
|
||||
Current wiFi mode in use can be `AP` or `STA`
|
||||
* `WebUpdate`
|
||||
Inform webUI the feature is available or not, can be `Enabled` or `Disabled`
|
||||
* `FlashFileSystem` (currently `FileSystem`, to be updated soon )
|
||||
The file system used by ESP board can be `LittleFS`, `SPIFFS`, `Fat`, `none`
|
||||
* `HostPath`
|
||||
Path where the preferences.json and index.html.gz are stored and can be updated (e.g: `www`)
|
||||
* `Time`
|
||||
Type of time support
|
||||
* `none`
|
||||
Time is not supported
|
||||
* `Auto`
|
||||
Board use internet to sync time and it is successful
|
||||
* `Failed to set`
|
||||
Board use internet to sync time and it is failed
|
||||
* `Manual`
|
||||
Board use time of ESP800 to set the time and it is successful
|
||||
* `Not set`
|
||||
Board use time of ESP800 to set the time and command did not sent it (time may have been set by previous command)
|
||||
* `CameraID`
|
||||
if ESP has camera it contain the camera ID
|
||||
* `CameraName`
|
||||
if ESP has camera it contain the camera name
|
||||
* `Axisletters`
|
||||
Currently only used for grbHAL
|
||||
can be :
|
||||
- XYZABC
|
||||
- XYZUVZ (supported soon)
|
||||
- XYZABCUVZ (supported soon)
|
||||
|
41
docs/pagespliter.py
Normal file
41
docs/pagespliter.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
|
||||
input_file = "espXXX.md"
|
||||
output_file_head = "esp"
|
||||
output_ext = ".md"
|
||||
|
||||
|
||||
|
||||
f = open(input_file, "r")
|
||||
lines = f.readlines()
|
||||
#parse each lines
|
||||
head = ""
|
||||
have_command = False
|
||||
fo=0
|
||||
count = 0
|
||||
for line in lines:
|
||||
if not have_command:
|
||||
count=0
|
||||
head+=line
|
||||
if line.startswith("title ="):
|
||||
have_command = True
|
||||
num = line.split("ESP")[1].split("]")[0]
|
||||
fo = open(output_file_head+num+output_ext, "w")
|
||||
fo.write(head)
|
||||
have_command = True
|
||||
else:
|
||||
if line.startswith("+++"):
|
||||
count+=1
|
||||
if count==2:
|
||||
fo.close()
|
||||
have_command = False
|
||||
head = line
|
||||
print("close file "+output_file_head+num+output_ext)
|
||||
else:
|
||||
fo.write(line)
|
||||
else:
|
||||
fo.write(line)
|
||||
|
||||
f.close()
|
@ -809,3 +809,161 @@ bool Commands::execute_internal_command(int cmd, const char *cmd_params,
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
bool Commands::_dispatchSetting(
|
||||
bool json, const char *filter, ESP3DSettingIndex index, const char *help,
|
||||
const char **optionValues, const char **optionLabels, uint32_t maxsize,
|
||||
uint32_t minsize, uint32_t minsize2, uint8_t precision, const char *unit,
|
||||
bool needRestart, ESP3DOutput *output, bool isFirst) {
|
||||
String tmpstr;
|
||||
String value;
|
||||
char out_str[255];
|
||||
tmpstr.reserve(
|
||||
350); // to save time and avoid several memories allocation delay
|
||||
const ESP3DSettingDescription *elementSetting =
|
||||
Settings_ESP3D::getSettingPtr(index);
|
||||
if (!elementSetting) {
|
||||
return false;
|
||||
}
|
||||
switch (elementSetting->type) {
|
||||
case ESP3DSettingType::byte_t:
|
||||
value = String(Settings_ESP3D::read_byte(index));
|
||||
break;
|
||||
case ESP3DSettingType::integer_t:
|
||||
value = String(Settings_ESP3D::read_uint32(index));
|
||||
break;
|
||||
case ESP3DSettingType::ip_t:
|
||||
value = Settings_ESP3D::read_IP_String(index);
|
||||
break;
|
||||
case ESP3DSettingType::float_t:
|
||||
// TODO Add float support ?
|
||||
value = "Not supported";
|
||||
log_esp3d_e("Float not supported");
|
||||
return false;
|
||||
break;
|
||||
case ESP3DSettingType::mask:
|
||||
// TODO Add Mask support ?
|
||||
value = "Not supported";
|
||||
log_esp3d_e("Mask not supported");
|
||||
return false;
|
||||
break;
|
||||
case ESP3DSettingType::bitsfield:
|
||||
// TODO Add bitfield support ?
|
||||
value = "Not supported";
|
||||
log_esp3d_e("Bitsfield not supported");
|
||||
return false;
|
||||
break;
|
||||
case ESP3DSettingType::string_t:
|
||||
// String
|
||||
if (index == ESP_AP_PASSWORD || index == ESP_STA_PASSWORD ||
|
||||
#ifdef NOTIFICATION_FEATURE
|
||||
index == ESP_NOTIFICATION_TOKEN1 ||
|
||||
index == ESP_NOTIFICATION_TOKEN2 ||
|
||||
#endif // NOTIFICATION_FEATURE
|
||||
|
||||
index == ESP_USER_PWD || index == ESP_ADMIN_PWD) { // hide passwords
|
||||
// using ********
|
||||
value = HIDDEN_PASSWORD;
|
||||
} else {
|
||||
value = Settings_ESP3D::read_string(index);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
value = "Not supported";
|
||||
log_esp3d_e("Type not supported");
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (json) {
|
||||
if (!isFirst) {
|
||||
tmpstr += ",";
|
||||
}
|
||||
tmpstr += "{\"F\":\"";
|
||||
tmpstr += filter;
|
||||
tmpstr += "\",\"P\":\"";
|
||||
tmpstr += String(static_cast<uint16_t>(index));
|
||||
tmpstr += "\",\"T\":\"";
|
||||
// Limited support already done for above so even not supported we can
|
||||
// define it once will be enabled
|
||||
switch (elementSetting->type) {
|
||||
case ESP3DSettingType::byte_t:
|
||||
tmpstr += "B";
|
||||
break;
|
||||
case ESP3DSettingType::integer_t:
|
||||
tmpstr += "I";
|
||||
break;
|
||||
case ESP3DSettingType::ip_t:
|
||||
tmpstr += "A";
|
||||
break;
|
||||
case ESP3DSettingType::float_t:
|
||||
tmpstr += "F";
|
||||
break;
|
||||
case ESP3DSettingType::mask:
|
||||
tmpstr += "M";
|
||||
break;
|
||||
case ESP3DSettingType::bitsfield:
|
||||
tmpstr += "X";
|
||||
break;
|
||||
default:
|
||||
tmpstr += "S";
|
||||
}
|
||||
tmpstr += "\",\"V\":\"";
|
||||
tmpstr += value;
|
||||
tmpstr += "\",\"H\":\"";
|
||||
tmpstr += help;
|
||||
tmpstr += "\"";
|
||||
if (needRestart) {
|
||||
tmpstr += ",\"R\":\"1\"";
|
||||
}
|
||||
if (optionValues && optionLabels) {
|
||||
tmpstr += ",\"O\":[";
|
||||
for (uint8_t i = 0; i < maxsize; i++) {
|
||||
if (i > 0) {
|
||||
tmpstr += ",";
|
||||
}
|
||||
tmpstr += "{\"";
|
||||
// be sure we have same size for both array to avoid overflow
|
||||
tmpstr += optionLabels[i];
|
||||
tmpstr += "\":\"";
|
||||
tmpstr += optionValues[i];
|
||||
tmpstr += "\"}";
|
||||
}
|
||||
tmpstr += "]";
|
||||
}
|
||||
if (unit) {
|
||||
tmpstr += ",\"R\":\"";
|
||||
tmpstr += unit;
|
||||
tmpstr += "\"";
|
||||
}
|
||||
if (precision != ((uint8_t)-1)) {
|
||||
tmpstr += ",\"E\":\"";
|
||||
tmpstr += String(precision);
|
||||
tmpstr += "\"";
|
||||
}
|
||||
if (maxsize != (uint32_t)-1 && !optionValues) {
|
||||
tmpstr += ",\"S\":\"";
|
||||
tmpstr += String(maxsize);
|
||||
tmpstr += "\"";
|
||||
}
|
||||
if (minsize != (uint32_t)-1) {
|
||||
tmpstr += ",\"M\":\"";
|
||||
tmpstr += String(minsize);
|
||||
tmpstr += "\"";
|
||||
}
|
||||
if (minsize2 != (uint32_t)-1) {
|
||||
tmpstr += ",\"MS\":\"";
|
||||
tmpstr += String(minsize2);
|
||||
tmpstr += "\"";
|
||||
}
|
||||
tmpstr += "}";
|
||||
} else {
|
||||
tmpstr = filter;
|
||||
tmpstr += "/";
|
||||
tmpstr += help;
|
||||
tmpstr += ": ";
|
||||
tmpstr += value;
|
||||
tmpstr += "\n";
|
||||
}
|
||||
output->print(tmpstr.c_str());
|
||||
return true;
|
||||
}
|
@ -21,159 +21,244 @@
|
||||
#ifndef COMMANDS_H
|
||||
#define COMMANDS_H
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "../modules/authentication/authentication_service.h"
|
||||
|
||||
class ESP3DOutput;
|
||||
|
||||
class Commands
|
||||
{
|
||||
public:
|
||||
Commands();
|
||||
~Commands();
|
||||
void process(uint8_t * sbuf, size_t len, ESP3DOutput * output, level_authenticate_type auth = LEVEL_GUEST, ESP3DOutput * outputonly = nullptr, uint8_t outputignore = 0);
|
||||
bool is_esp_command(uint8_t * sbuf, size_t len);
|
||||
bool execute_internal_command(int cmd, const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
int get_space_pos(const char * string, uint from = 0);
|
||||
const char* get_param (const char * cmd_params, const char * label);
|
||||
const char* get_label (const char * cmd_params, const char * labelseparator, uint8_t startindex = 0);
|
||||
const char * clean_param (const char * cmd_params);
|
||||
const char * format_response(uint cmdID, bool isjson = false, bool isok=true, const char * message="");
|
||||
bool has_tag (const char * cmd_params, const char * tag);
|
||||
bool ESP0(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#if defined (WIFI_FEATURE)
|
||||
bool ESP100(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP101(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WIFI_FEATURE
|
||||
#if defined (WIFI_FEATURE) || defined (ETH_FEATURE)
|
||||
bool ESP102(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP103(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WIFI_FEATURE ||ETH_FEATURE
|
||||
#if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
|
||||
bool ESP104(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
|
||||
#if defined (WIFI_FEATURE)
|
||||
bool ESP105(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP106(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP107(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP108(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WIFI_FEATURE
|
||||
#if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
|
||||
bool ESP110(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
|
||||
#if defined( WIFI_FEATURE) || defined (ETH_FEATURE)
|
||||
bool ESP111(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||
class Commands {
|
||||
public:
|
||||
Commands();
|
||||
~Commands();
|
||||
void process(uint8_t* sbuf, size_t len, ESP3DOutput* output,
|
||||
level_authenticate_type auth = LEVEL_GUEST,
|
||||
ESP3DOutput* outputonly = nullptr, uint8_t outputignore = 0);
|
||||
bool is_esp_command(uint8_t* sbuf, size_t len);
|
||||
bool execute_internal_command(int cmd, const char* cmd_params,
|
||||
level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
int get_space_pos(const char* string, uint from = 0);
|
||||
const char* get_param(const char* cmd_params, const char* label);
|
||||
const char* get_label(const char* cmd_params, const char* labelseparator,
|
||||
uint8_t startindex = 0);
|
||||
const char* clean_param(const char* cmd_params);
|
||||
const char* format_response(uint cmdID, bool isjson = false, bool isok = true,
|
||||
const char* message = "");
|
||||
bool has_tag(const char* cmd_params, const char* tag);
|
||||
bool ESP0(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#if defined(WIFI_FEATURE)
|
||||
bool ESP100(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP101(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WIFI_FEATURE
|
||||
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
|
||||
bool ESP102(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP103(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WIFI_FEATURE ||ETH_FEATURE
|
||||
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
|
||||
bool ESP104(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
|
||||
#if defined(WIFI_FEATURE)
|
||||
bool ESP105(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP106(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP107(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP108(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WIFI_FEATURE
|
||||
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
|
||||
bool ESP110(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
|
||||
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
|
||||
bool ESP111(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#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
|
||||
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)
|
||||
bool ESP120(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP121(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //HTTP_FEATURE
|
||||
bool ESP120(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP121(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // HTTP_FEATURE
|
||||
#if defined(TELNET_FEATURE)
|
||||
bool ESP130(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP131(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //TELNET_FEATURE
|
||||
bool ESP130(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP131(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // TELNET_FEATURE
|
||||
#if defined(TIMESTAMP_FEATURE)
|
||||
bool ESP140(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //TIMESTAMP_FEATURE
|
||||
bool ESP150(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP140(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // TIMESTAMP_FEATURE
|
||||
bool ESP150(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#if defined(WS_DATA_FEATURE)
|
||||
bool ESP160(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP161(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WS_DATA_FEATURE
|
||||
bool ESP160(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP161(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WS_DATA_FEATURE
|
||||
#if defined(CAMERA_DEVICE)
|
||||
bool ESP170(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP171(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //CAMERA_DEVICE
|
||||
bool ESP170(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP171(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // CAMERA_DEVICE
|
||||
#if defined(FTP_FEATURE)
|
||||
bool ESP180(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP181(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //FTP_FEATURE
|
||||
bool ESP180(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP181(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // FTP_FEATURE
|
||||
#if defined(WEBDAV_FEATURE)
|
||||
bool ESP190(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP191(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WEBDAV_FEATURE
|
||||
#if defined (SD_DEVICE)
|
||||
bool ESP200(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP190(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP191(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WEBDAV_FEATURE
|
||||
#if defined(SD_DEVICE)
|
||||
bool ESP200(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#if SD_DEVICE != ESP_SDIO
|
||||
bool ESP202(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //SD_DEVICE != ESP_SDIO
|
||||
bool ESP202(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // SD_DEVICE != ESP_SDIO
|
||||
#ifdef SD_UPDATE_FEATURE
|
||||
bool ESP402(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //SD_UPDATE_FEATURE
|
||||
#endif //SD_DEVICE
|
||||
bool ESP402(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // SD_UPDATE_FEATURE
|
||||
#endif // SD_DEVICE
|
||||
#ifdef DIRECT_PIN_FEATURE
|
||||
bool ESP201(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //DIRECT_PIN_FEATURE
|
||||
#if defined (DISPLAY_DEVICE)
|
||||
bool ESP214(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP201(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // DIRECT_PIN_FEATURE
|
||||
#if defined(DISPLAY_DEVICE)
|
||||
bool ESP214(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#if defined(DISPLAY_TOUCH_DRIVER)
|
||||
bool ESP215(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //DISPLAY_TOUCH_DRIVER
|
||||
#endif //DISPLAY_DEVICE
|
||||
bool ESP215(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // DISPLAY_TOUCH_DRIVER
|
||||
#endif // DISPLAY_DEVICE
|
||||
#ifdef SENSOR_DEVICE
|
||||
bool ESP210(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //SENSOR_DEVICE
|
||||
bool ESP220(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP290(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP400(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP401(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#if defined (WIFI_FEATURE)
|
||||
bool ESP410(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WIFI_FEATURE
|
||||
bool ESP420(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP444(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP210(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // SENSOR_DEVICE
|
||||
bool ESP220(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP290(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP400(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP401(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#if defined(WIFI_FEATURE)
|
||||
bool ESP410(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // WIFI_FEATURE
|
||||
bool ESP420(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP444(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#ifdef MDNS_FEATURE
|
||||
bool ESP450(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //MDNS_FEATURE
|
||||
#if defined (AUTHENTICATION_FEATURE)
|
||||
bool ESP550(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP555(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
bool ESP450(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // MDNS_FEATURE
|
||||
#if defined(AUTHENTICATION_FEATURE)
|
||||
bool ESP550(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP555(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
#if defined(NOTIFICATION_FEATURE)
|
||||
bool ESP600(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP610(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP620(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //NOTIFICATION_FEATURE
|
||||
bool ESP600(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP610(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP620(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // NOTIFICATION_FEATURE
|
||||
#if defined(GCODE_HOST_FEATURE)
|
||||
bool ESP700(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP701(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //GCODE_HOST_FEATURE
|
||||
bool ESP700(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP701(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // GCODE_HOST_FEATURE
|
||||
#if defined(FILESYSTEM_FEATURE)
|
||||
bool ESP710(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP720(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP730(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //FILESYSTEM_FEATURE
|
||||
#if defined (SD_DEVICE)
|
||||
bool ESP715(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP750(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP740(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //SD_DEVICE
|
||||
#if defined (GLOBAL_FILESYSTEM_FEATURE)
|
||||
bool ESP780(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP790(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //GLOBAL_FILESYSTEM_FEATURE
|
||||
bool ESP800(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP710(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP720(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP730(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // FILESYSTEM_FEATURE
|
||||
#if defined(SD_DEVICE)
|
||||
bool ESP715(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP750(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP740(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // SD_DEVICE
|
||||
#if defined(GLOBAL_FILESYSTEM_FEATURE)
|
||||
bool ESP780(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP790(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // GLOBAL_FILESYSTEM_FEATURE
|
||||
bool ESP800(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#if COMMUNICATION_PROTOCOL != SOCKET_SERIAL
|
||||
bool ESP900(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP901(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //COMMUNICATION_PROTOCOL != SOCKET_SERIAL
|
||||
bool ESP920(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#if defined (ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
bool ESP930(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP931(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //defined (ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
bool ESP900(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP901(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL
|
||||
bool ESP920(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
bool ESP930(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP931(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // defined (ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
#ifdef BUZZER_DEVICE
|
||||
bool ESP910(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP250(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //BUZZER_DEVICE
|
||||
#if defined(ARDUINO_ARCH_ESP32) && (CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3)
|
||||
bool ESP999(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //ARDUINO_ARCH_ESP32
|
||||
bool ESP910(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
bool ESP250(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // BUZZER_DEVICE
|
||||
#if defined(ARDUINO_ARCH_ESP32) && \
|
||||
(CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || \
|
||||
CONFIG_IDF_TARGET_ESP32C3)
|
||||
bool ESP999(const char* cmd_params, level_authenticate_type auth_level,
|
||||
ESP3DOutput* output);
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
|
||||
private:
|
||||
bool _dispatchSetting(bool json, const char* filter, ESP3DSettingIndex index,
|
||||
const char* help, const char** optionValues,
|
||||
const char** optionLabels, uint32_t maxsize,
|
||||
uint32_t minsize, uint32_t minsize2, uint8_t precision,
|
||||
const char* unit, bool needRestart, ESP3DOutput* output,
|
||||
bool isFirst = false);
|
||||
};
|
||||
|
||||
extern Commands esp3d_commands;
|
||||
|
||||
#endif //COMMANDS_H
|
||||
#endif // COMMANDS_H
|
||||
|
@ -48,17 +48,17 @@
|
||||
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || \
|
||||
COMMUNICATION_PROTOCOL == MKS_SERIAL || \
|
||||
COMMUNICATION_PROTOCOL == SOCKET_SERIAL
|
||||
uint8_t ESP3DOutput::_serialoutputflags = DEFAULT_SERIAL_OUTPUT_FLAG;
|
||||
uint8_t ESP3DOutput::_serialoutputflags = 0;
|
||||
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
|
||||
// MKS_SERIAL || COMMUNICATION_PROTOCOL == SOCKET_SERIAL
|
||||
#if defined(HAS_DISPLAY) || defined(HAS_SERIAL_DISPLAY)
|
||||
uint8_t ESP3DOutput::_remotescreenoutputflags = DEFAULT_REMOTE_SCREEN_FLAG;
|
||||
uint8_t ESP3DOutput::_remotescreenoutputflags = 0;
|
||||
#endif // HAS_DISPLAY || HAS_SERIAL_DISPLAY
|
||||
#if defined(WS_DATA_FEATURE)
|
||||
uint8_t ESP3DOutput::_websocketoutputflags = DEFAULT_WEBSOCKET_FLAG;
|
||||
#endif // WS_DATA_FEATURE
|
||||
#if defined(TELNET_FEATURE)
|
||||
uint8_t ESP3DOutput::_telnetoutputflags = DEFAULT_TELNET_FLAG;
|
||||
uint8_t ESP3DOutput::_telnetoutputflags = 0;
|
||||
#endif // TELNET_FEATURE
|
||||
#if defined(DISPLAY_DEVICE)
|
||||
uint8_t ESP3DOutput::_screenoutputflags = DEFAULT_SCREEN_FLAG;
|
||||
|
@ -63,7 +63,8 @@ bool Commands::ESP100(const char* cmd_params, level_authenticate_type auth_type,
|
||||
}
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
if (!WiFiConfig::isSSIDValid(parameter.c_str())) {
|
||||
if (!Settings_ESP3D::isValidStringSetting(parameter.c_str(),
|
||||
ESP_STA_SSID)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect SSID");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -57,7 +57,8 @@ bool Commands::ESP101(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (clearSetting) {
|
||||
parameter = "";
|
||||
}
|
||||
if (!WiFiConfig::isPasswordValid(parameter.c_str())) {
|
||||
if (!Settings_ESP3D::isValidStringSetting(parameter.c_str(),
|
||||
ESP_STA_PASSWORD)) {
|
||||
response =
|
||||
format_response(COMMANDID, json, false, "Incorrect password");
|
||||
noError = false;
|
||||
|
@ -99,20 +99,25 @@ bool Commands::ESP103(const char* cmd_params, level_authenticate_type auth_type,
|
||||
String GW = get_param(cmd_params, "GW=");
|
||||
String MSK = get_param(cmd_params, "MSK=");
|
||||
String DNS = get_param(cmd_params, "DNS=");
|
||||
if (!NetConfig::isValidIP(IP.c_str())) {
|
||||
|
||||
if (!Settings_ESP3D::isValidIPStringSetting(IP.c_str(),
|
||||
ESP_STA_IP_VALUE)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect IP");
|
||||
noError = false;
|
||||
}
|
||||
if (!NetConfig::isValidIP(GW.c_str())) {
|
||||
if (!Settings_ESP3D::isValidIPStringSetting(GW.c_str(),
|
||||
ESP_STA_GATEWAY_VALUE)) {
|
||||
response =
|
||||
format_response(COMMANDID, json, false, "Incorrect gateway");
|
||||
noError = false;
|
||||
}
|
||||
if (!NetConfig::isValidIP(MSK.c_str())) {
|
||||
if (!Settings_ESP3D::isValidIPStringSetting(MSK.c_str(),
|
||||
ESP_STA_MASK_VALUE)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect mask");
|
||||
noError = false;
|
||||
}
|
||||
if (!NetConfig::isValidIP(DNS.c_str())) {
|
||||
if (!Settings_ESP3D::isValidIPStringSetting(DNS.c_str(),
|
||||
ESP_STA_DNS_VALUE)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect dns");
|
||||
noError = false;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ bool Commands::ESP105(const char* cmd_params, level_authenticate_type auth_type,
|
||||
}
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
if (!WiFiConfig::isSSIDValid(parameter.c_str())) {
|
||||
if (!Settings_ESP3D::isValidStringSetting(parameter.c_str(),
|
||||
ESP_AP_SSID)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect SSID");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -58,7 +58,8 @@ bool Commands::ESP106(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (clearSetting) {
|
||||
parameter = "";
|
||||
}
|
||||
if (!WiFiConfig::isPasswordValid(parameter.c_str())) {
|
||||
if (!Settings_ESP3D::isValidStringSetting(parameter.c_str(),
|
||||
ESP_AP_PASSWORD)) {
|
||||
response = format_response(COMMANDID, json, false, "Set failed");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -65,7 +65,8 @@ bool Commands::ESP107(const char* cmd_params, level_authenticate_type auth_type,
|
||||
}
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
if (!NetConfig::isValidIP(parameter.c_str())) {
|
||||
if (!Settings_ESP3D::isValidIPStringSetting(parameter.c_str(),
|
||||
ESP_AP_IP_VALUE)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect IP");
|
||||
noError = false;
|
||||
}
|
||||
|
@ -65,8 +65,7 @@ bool Commands::ESP108(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
int bbuf = parameter.toInt();
|
||||
if ((bbuf > Settings_ESP3D::get_max_byte(ESP_AP_CHANNEL)) ||
|
||||
(bbuf < Settings_ESP3D::get_min_byte(ESP_AP_CHANNEL))) {
|
||||
if (!Settings_ESP3D::isValidByteSetting(bbuf, ESP_AP_CHANNEL)) {
|
||||
response =
|
||||
format_response(COMMANDID, json, false, "Incorrect channel");
|
||||
noError = false;
|
||||
|
@ -63,7 +63,8 @@ bool Commands::ESP112(const char* cmd_params, level_authenticate_type auth_type,
|
||||
}
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
if (!NetConfig::isHostnameValid(parameter.c_str())) {
|
||||
if (!Settings_ESP3D::isValidStringSetting(parameter.c_str(),
|
||||
ESP_HOSTNAME)) {
|
||||
response =
|
||||
format_response(COMMANDID, json, false, "Incorrect hostname");
|
||||
noError = false;
|
||||
|
@ -64,8 +64,7 @@ bool Commands::ESP121(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
uint ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_HTTP_PORT)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(ESP_HTTP_PORT))) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(ibuf, ESP_HTTP_PORT)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect port");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -63,8 +63,7 @@ bool Commands::ESP131(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
uint ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_TELNET_PORT)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(ESP_TELNET_PORT))) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(ibuf, ESP_TELNET_PORT)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect port");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -64,8 +64,8 @@ bool Commands::ESP140(const char* cmd_params, level_authenticate_type auth_type,
|
||||
parameter = get_param(cmd_params, "srv1=");
|
||||
if (parameter.length() > 0) {
|
||||
hasParam = true;
|
||||
if (parameter.length() <
|
||||
Settings_ESP3D::get_max_string_size(ESP_TIME_SERVER1)) {
|
||||
if (Settings_ESP3D::isValidIPStringSetting(parameter.c_str(),
|
||||
ESP_TIME_SERVER1)) {
|
||||
if (!Settings_ESP3D::write_string(ESP_TIME_SERVER1,
|
||||
parameter.c_str())) {
|
||||
response = format_response(COMMANDID, json, false,
|
||||
@ -79,8 +79,8 @@ bool Commands::ESP140(const char* cmd_params, level_authenticate_type auth_type,
|
||||
parameter = get_param(cmd_params, "srv2=");
|
||||
if (parameter.length() > 0) {
|
||||
hasParam = true;
|
||||
if (parameter.length() <
|
||||
Settings_ESP3D::get_max_string_size(ESP_TIME_SERVER2)) {
|
||||
if (!Settings_ESP3D::isValidIPStringSetting(parameter.c_str(),
|
||||
ESP_TIME_SERVER2)) {
|
||||
if (!Settings_ESP3D::write_string(ESP_TIME_SERVER2,
|
||||
parameter.c_str())) {
|
||||
response = format_response(COMMANDID, json, false,
|
||||
@ -94,8 +94,8 @@ bool Commands::ESP140(const char* cmd_params, level_authenticate_type auth_type,
|
||||
parameter = get_param(cmd_params, "srv3=");
|
||||
if (parameter.length() > 0) {
|
||||
hasParam = true;
|
||||
if (parameter.length() <
|
||||
Settings_ESP3D::get_max_string_size(ESP_TIME_SERVER3)) {
|
||||
if (!Settings_ESP3D::isValidIPStringSetting(parameter.c_str(),
|
||||
ESP_TIME_SERVER3)) {
|
||||
if (!Settings_ESP3D::write_string(ESP_TIME_SERVER3,
|
||||
parameter.c_str())) {
|
||||
response = format_response(COMMANDID, json, false,
|
||||
|
@ -81,8 +81,7 @@ bool Commands::ESP150(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (parameter.length() != 0) {
|
||||
hasParameter = true;
|
||||
uint ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_BOOT_DELAY)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(ESP_BOOT_DELAY))) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(ibuf, ESP_BOOT_DELAY)) {
|
||||
response =
|
||||
format_response(COMMANDID, json, false, "Incorrect delay");
|
||||
noError = false;
|
||||
|
@ -63,8 +63,7 @@ bool Commands::ESP161(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
uint ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_WEBSOCKET_PORT)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(ESP_WEBSOCKET_PORT))) {
|
||||
if !(Settings_ESP3D::isValidIntegerSetting(ibuf, ESP_WEBSOCKET_PORT)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect port");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define COMMANDID 181
|
||||
// Set/Get Ftp ports
|
||||
//[ESP181]ctrl=<port> active=<port> passive=<port> json=<no> pwd=<admin
|
||||
//password>
|
||||
// password>
|
||||
bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
|
||||
ESP3DOutput* output) {
|
||||
bool noError = true;
|
||||
@ -90,8 +90,7 @@ bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (parameter.length() > 0) {
|
||||
hasParam = true;
|
||||
ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_FTP_CTRL_PORT)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(ESP_FTP_CTRL_PORT))) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(ibuf, ESP_FTP_CTRL_PORT)) {
|
||||
response =
|
||||
format_response(COMMANDID, json, false, "Incorrect ctrl port");
|
||||
noError = false;
|
||||
@ -107,10 +106,8 @@ bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (parameter.length() > 0) {
|
||||
ibuf = parameter.toInt();
|
||||
hasParam = true;
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(
|
||||
ESP_FTP_DATA_ACTIVE_PORT)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(
|
||||
ESP_FTP_DATA_ACTIVE_PORT))) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(ibuf,
|
||||
ESP_FTP_DATA_ACTIVE_PORT)) {
|
||||
response = format_response(COMMANDID, json, false,
|
||||
"Incorrect active port");
|
||||
noError = false;
|
||||
@ -129,10 +126,8 @@ bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (parameter.length() > 0) {
|
||||
hasParam = true;
|
||||
ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(
|
||||
ESP_FTP_DATA_PASSIVE_PORT)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(
|
||||
ESP_FTP_DATA_PASSIVE_PORT))) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(
|
||||
ibuf, ESP_FTP_DATA_PASSIVE_PORT)) {
|
||||
response = format_response(COMMANDID, json, false,
|
||||
"Incorrect passive port");
|
||||
noError = false;
|
||||
|
@ -63,8 +63,7 @@ bool Commands::ESP191(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
uint ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_WEBDAV_PORT)) ||
|
||||
(ibuf < Settings_ESP3D::get_min_int32_value(ESP_WEBDAV_PORT))) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(ibuf, ESP_WEBDAV_PORT)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect port");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -55,9 +55,8 @@ bool Commands::ESP202(const char* cmd_params, level_authenticate_type auth_type,
|
||||
String(Settings_ESP3D::read_byte(ESP_SD_SPEED_DIV)).c_str());
|
||||
} else { // set
|
||||
parameter = get_param(cmd_params, "SPEED=");
|
||||
if ((parameter == "1") || (parameter == "2") || (parameter == "4") ||
|
||||
(parameter == "6") || (parameter == "8") || (parameter == "16") ||
|
||||
(parameter == "32")) {
|
||||
if (Settings_ESP3D::isValidByteSetting(parameter.toInt(),
|
||||
ESP_SD_SPEED_DIV)) {
|
||||
if (!Settings_ESP3D::write_byte(ESP_SD_SPEED_DIV, parameter.toInt())) {
|
||||
response = format_response(COMMANDID, json, false, "Set failed");
|
||||
noError = false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -86,138 +86,164 @@ bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (response) {
|
||||
// Byte value
|
||||
if (styp == "B") {
|
||||
if (!Settings_ESP3D::write_byte(spos.toInt(),
|
||||
(uint8_t)sval.toInt())) {
|
||||
response = false;
|
||||
} else {
|
||||
// dynamique refresh is better than restart the boards
|
||||
switch (spos.toInt()) {
|
||||
if (Settings_ESP3D::isValidByteSetting((uint8_t)sval.toInt(),
|
||||
spos.toInt())) {
|
||||
if (!Settings_ESP3D::write_byte(spos.toInt(),
|
||||
(uint8_t)sval.toInt())) {
|
||||
response = false;
|
||||
log_esp3d_e("Set failed");
|
||||
} else {
|
||||
// dynamique refresh is better than restart the boards
|
||||
switch (spos.toInt()) {
|
||||
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
case ESP_SERIAL_BRIDGE_ON:
|
||||
if (!serial_bridge_service.started()) {
|
||||
serial_bridge_service.begin(ESP_SERIAL_BRIDGE_OUTPUT);
|
||||
}
|
||||
break;
|
||||
case ESP_SERIAL_BRIDGE_ON:
|
||||
if (!serial_bridge_service.started()) {
|
||||
serial_bridge_service.begin(ESP_SERIAL_BRIDGE_OUTPUT);
|
||||
}
|
||||
break;
|
||||
#endif // ESP_SERIAL_BRIDGE_OUTPUT
|
||||
case ESP_SERIAL_BRIDGE_FLAG:
|
||||
case ESP_SERIAL_FLAG:
|
||||
case ESP_REMOTE_SCREEN_FLAG:
|
||||
case ESP_WEBSOCKET_FLAG:
|
||||
case ESP_TELNET_FLAG:
|
||||
case ESP_SCREEN_FLAG:
|
||||
case ESP_BT_FLAG:
|
||||
ESP3DOutput::isOutput(ESP_ALL_CLIENTS, true);
|
||||
break;
|
||||
case ESP_VERBOSE_BOOT:
|
||||
Settings_ESP3D::isVerboseBoot(true);
|
||||
break;
|
||||
case ESP_TARGET_FW:
|
||||
Settings_ESP3D::GetFirmwareTarget(true);
|
||||
break;
|
||||
case ESP_SERIAL_BRIDGE_FLAG:
|
||||
case ESP_SERIAL_FLAG:
|
||||
case ESP_REMOTE_SCREEN_FLAG:
|
||||
case ESP_WEBSOCKET_FLAG:
|
||||
case ESP_TELNET_FLAG:
|
||||
case ESP_SCREEN_FLAG:
|
||||
case ESP_BT_FLAG:
|
||||
ESP3DOutput::isOutput(ESP_ALL_CLIENTS, true);
|
||||
break;
|
||||
case ESP_VERBOSE_BOOT:
|
||||
Settings_ESP3D::isVerboseBoot(true);
|
||||
break;
|
||||
case ESP_TARGET_FW:
|
||||
Settings_ESP3D::GetFirmwareTarget(true);
|
||||
break;
|
||||
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||
case ESP_SECURE_SERIAL:
|
||||
serial_service.setParameters();
|
||||
break;
|
||||
case ESP_SECURE_SERIAL:
|
||||
serial_service.setParameters();
|
||||
break;
|
||||
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
|
||||
// MKS_SERIAL
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
case ESP_SESSION_TIMEOUT:
|
||||
AuthenticationService::setSessionTimeout(1000 * 60 *
|
||||
sval.toInt());
|
||||
break;
|
||||
case ESP_SESSION_TIMEOUT:
|
||||
AuthenticationService::setSessionTimeout(1000 * 60 *
|
||||
sval.toInt());
|
||||
break;
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
#ifdef SD_DEVICE
|
||||
case ESP_SD_SPEED_DIV:
|
||||
ESP_SD::setSPISpeedDivider(sval.toInt());
|
||||
break;
|
||||
case ESP_SD_SPEED_DIV:
|
||||
ESP_SD::setSPISpeedDivider(sval.toInt());
|
||||
break;
|
||||
#endif // SD_DEVICE
|
||||
#ifdef TIMESTAMP_FEATURE
|
||||
case ESP_INTERNET_TIME:
|
||||
timeService.begin();
|
||||
break;
|
||||
case ESP_INTERNET_TIME:
|
||||
timeService.begin();
|
||||
break;
|
||||
#endif // TIMESTAMP_FEATURE
|
||||
#ifdef NOTIFICATION_FEATURE
|
||||
case ESP_AUTO_NOTIFICATION:
|
||||
notificationsservice.setAutonotification(
|
||||
(sval.toInt() == 0) ? false : true);
|
||||
break;
|
||||
case ESP_AUTO_NOTIFICATION:
|
||||
notificationsservice.setAutonotification(
|
||||
(sval.toInt() == 0) ? false : true);
|
||||
break;
|
||||
#endif // NOTIFICATION_FEATURE
|
||||
#ifdef SENSOR_DEVICE
|
||||
case ESP_SENSOR_TYPE:
|
||||
esp3d_sensor.begin();
|
||||
break;
|
||||
case ESP_SENSOR_TYPE:
|
||||
esp3d_sensor.begin();
|
||||
break;
|
||||
#endif // SENSOR_DEVICE
|
||||
#ifdef BUZZER_DEVICE
|
||||
case ESP_BUZZER:
|
||||
if (sval.toInt() == 1) {
|
||||
esp3d_buzzer.begin();
|
||||
} else if (sval.toInt() == 0) {
|
||||
esp3d_buzzer.end();
|
||||
}
|
||||
break;
|
||||
case ESP_BUZZER:
|
||||
if (sval.toInt() == 1) {
|
||||
esp3d_buzzer.begin();
|
||||
} else if (sval.toInt() == 0) {
|
||||
esp3d_buzzer.end();
|
||||
}
|
||||
break;
|
||||
#endif // BUZZER_DEVICE
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response = "Invalid value for V";
|
||||
noError = false;
|
||||
}
|
||||
}
|
||||
// Integer value
|
||||
if (styp == "I") {
|
||||
if (!Settings_ESP3D::write_uint32(spos.toInt(), sval.toInt())) {
|
||||
response = "Set failed";
|
||||
noError = false;
|
||||
} else {
|
||||
// dynamique refresh is better than restart the board
|
||||
switch (spos.toInt()) {
|
||||
if (Settings_ESP3D::isValidByteSetting(sval.toInt(), spos.toInt())) {
|
||||
if (!Settings_ESP3D::write_uint32(spos.toInt(), sval.toInt())) {
|
||||
response = "Set failed";
|
||||
noError = false;
|
||||
log_esp3d_e("Set failed");
|
||||
} else {
|
||||
// dynamique refresh is better than restart the board
|
||||
switch (spos.toInt()) {
|
||||
#ifdef SENSOR_DEVICE
|
||||
case ESP_SENSOR_INTERVAL:
|
||||
esp3d_sensor.setInterval(sval.toInt());
|
||||
break;
|
||||
case ESP_SENSOR_INTERVAL:
|
||||
esp3d_sensor.setInterval(sval.toInt());
|
||||
break;
|
||||
#endif // SENSOR_DEVICE
|
||||
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||
case ESP_BAUD_RATE:
|
||||
serial_service.updateBaudRate(sval.toInt());
|
||||
break;
|
||||
case ESP_BAUD_RATE:
|
||||
serial_service.updateBaudRate(sval.toInt());
|
||||
break;
|
||||
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
|
||||
// MKS_SERIAL
|
||||
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
case ESP_SERIAL_BRIDGE_BAUD:
|
||||
serial_bridge_service.updateBaudRate(sval.toInt());
|
||||
break;
|
||||
case ESP_SERIAL_BRIDGE_BAUD:
|
||||
serial_bridge_service.updateBaudRate(sval.toInt());
|
||||
break;
|
||||
#endif // defined(ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response = "Invalid value for V";
|
||||
noError = false;
|
||||
}
|
||||
}
|
||||
// String value
|
||||
if (styp == "S") {
|
||||
if (!Settings_ESP3D::write_string(spos.toInt(), sval.c_str())) {
|
||||
response = "Set failed";
|
||||
noError = false;
|
||||
} else {
|
||||
// dynamique refresh is better than restart the board
|
||||
switch (spos.toInt()) {
|
||||
if (Settings_ESP3D::isValidStringSetting(sval.c_str(),
|
||||
spos.toInt())) {
|
||||
if (!Settings_ESP3D::write_string(spos.toInt(), sval.c_str())) {
|
||||
response = "Set failed";
|
||||
noError = false;
|
||||
log_esp3d_e("Set failed");
|
||||
} else {
|
||||
// dynamique refresh is better than restart the board
|
||||
switch (spos.toInt()) {
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
case ESP_ADMIN_PWD:
|
||||
case ESP_USER_PWD:
|
||||
AuthenticationService::update();
|
||||
break;
|
||||
case ESP_ADMIN_PWD:
|
||||
case ESP_USER_PWD:
|
||||
AuthenticationService::update();
|
||||
break;
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response = "Invalid value for V";
|
||||
noError = false;
|
||||
}
|
||||
}
|
||||
#if defined(WIFI_FEATURE)
|
||||
// IP address
|
||||
if (styp == "A") {
|
||||
if (!Settings_ESP3D::write_IP_String(spos.toInt(), sval.c_str())) {
|
||||
response = "Set failed";
|
||||
noError = false;
|
||||
if (Settings_ESP3D::isValidIPStringSetting(sval.c_str(),
|
||||
spos.toInt())) {
|
||||
if (!Settings_ESP3D::write_IP_String(spos.toInt(), sval.c_str())) {
|
||||
response = "Set failed";
|
||||
noError = false;
|
||||
} else {
|
||||
// dynamique refresh is better than restart the board
|
||||
// TBD
|
||||
}
|
||||
} else {
|
||||
// dynamique refresh is better than restart the board
|
||||
// TBD
|
||||
response = "Invalid value for V";
|
||||
noError = false;
|
||||
}
|
||||
}
|
||||
#endif // WIFI_FEATURE
|
||||
|
@ -38,7 +38,8 @@ bool Commands::ESP550(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (auth_type == LEVEL_ADMIN) {
|
||||
parameter = clean_param(get_param(cmd_params, ""));
|
||||
if (parameter.length() != 0) {
|
||||
if (Settings_ESP3D::isLocalPasswordValid(parameter.c_str())) {
|
||||
if (Settings_ESP3D::isValidStringSetting(parameter.c_str(),
|
||||
ESP_ADMIN_PWD)) {
|
||||
if (!Settings_ESP3D::write_string(ESP_ADMIN_PWD, parameter.c_str())) {
|
||||
response = format_response(COMMANDID, json, false, "Set failed");
|
||||
noError = false;
|
||||
|
@ -38,7 +38,8 @@ bool Commands::ESP555(const char* cmd_params, level_authenticate_type auth_type,
|
||||
if (auth_type != LEVEL_GUEST) {
|
||||
parameter = clean_param(get_param(cmd_params, ""));
|
||||
if (parameter.length() != 0) {
|
||||
if (Settings_ESP3D::isLocalPasswordValid(parameter.c_str())) {
|
||||
if (Settings_ESP3D::isValidStringSetting(parameter.c_str(),
|
||||
ESP_USER_PWD)) {
|
||||
if (!Settings_ESP3D::write_string(ESP_USER_PWD, parameter.c_str())) {
|
||||
response = format_response(COMMANDID, json, false, "Set failed");
|
||||
noError = false;
|
||||
|
@ -114,9 +114,9 @@ bool Commands::ESP740(const char* cmd_params, level_authenticate_type auth_type,
|
||||
String time = "";
|
||||
line = "";
|
||||
countf++;
|
||||
#ifdef FILESYSTEM_TIMESTAMP_FEATURE
|
||||
#ifdef SD_TIMESTAMP_FEATURE
|
||||
time = timeService.getDateTime((time_t)sub.getLastWrite());
|
||||
#endif // FILESYSTEM_TIMESTAMP_FEATURE
|
||||
#endif // SD_TIMESTAMP_FEATURE
|
||||
if (json) {
|
||||
if (countd > 0 || countf > 1) {
|
||||
line += ",";
|
||||
|
@ -64,7 +64,7 @@ bool Commands::ESP901(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
uint ibuf = parameter.toInt();
|
||||
if (serial_service.is_valid_baudrate(ibuf)) {
|
||||
if (Settings_ESP3D::isValidIntegerSetting(ibuf, ESP_BAUD_RATE)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect port");
|
||||
noError = false;
|
||||
} else {
|
||||
|
@ -64,10 +64,11 @@ bool Commands::ESP931(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
if (noError) {
|
||||
uint ibuf = parameter.toInt();
|
||||
if (serial_bridge_service.is_valid_baudrate(ibuf)) {
|
||||
if (Settings_ESP3D.isValidIntegerSetting(ibuf, ESP_SERIAL_BRIDGE_BAUD)) {
|
||||
response = format_response(COMMANDID, json, false, "Incorrect port");
|
||||
noError = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!Settings_ESP3D::write_uint32(ESP_SERIAL_BRIDGE_BAUD, ibuf)) {
|
||||
response = format_response(COMMANDID, json, false, "Set failed");
|
||||
noError = false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,53 +19,86 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _SETTINGS_ESP3D_H
|
||||
#define _SETTINGS_ESP3D_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class Settings_ESP3D
|
||||
{
|
||||
public:
|
||||
static bool begin();
|
||||
static uint8_t get_default_byte_value(int pos);
|
||||
static uint32_t get_default_int32_value(int pos);
|
||||
static uint32_t get_default_IP_value(int pos);
|
||||
static const String & get_default_string_value(int pos);
|
||||
static uint8_t get_max_string_size(int pos);
|
||||
static uint8_t get_min_string_size(int pos);
|
||||
static uint32_t get_max_int32_value(int pos);
|
||||
static uint32_t get_min_int32_value(int pos);
|
||||
static uint8_t get_max_byte(int pos);
|
||||
static int8_t get_min_byte(int pos);
|
||||
static uint8_t read_byte (int pos, bool * haserror = NULL);
|
||||
static uint32_t read_uint32(int pos, bool * haserror = NULL);
|
||||
static uint32_t read_IP(int pos, bool * haserror = NULL);
|
||||
static String read_IP_String(int pos, bool * haserror = NULL);
|
||||
static const char * read_string (int pos, bool *haserror = NULL);
|
||||
static bool write_byte (int pos, const uint8_t value);
|
||||
static bool write_string (int pos, const char * byte_buffer);
|
||||
static bool write_uint32 (int pos, const uint32_t value);
|
||||
static bool write_IP (int pos, const uint32_t value);
|
||||
static bool write_IP_String (int pos, const char * value);
|
||||
static bool reset(bool networkonly = false);
|
||||
static int8_t GetSettingsVersion();
|
||||
static uint8_t GetFirmwareTarget(bool fromsettings = false);
|
||||
static bool isVerboseBoot(bool fromsettings = false);
|
||||
static uint8_t GetSDDevice();
|
||||
static const char* GetFirmwareTargetShortName();
|
||||
static String IPtoString(uint32_t ip_int);
|
||||
static uint32_t StringtoIP(const char *s);
|
||||
static const char * TargetBoard();
|
||||
static bool isLocalPasswordValid (const char * password);
|
||||
private:
|
||||
static bool is_string(const char * s, uint len);
|
||||
static uint8_t _FirmwareTarget;
|
||||
static bool _isverboseboot;
|
||||
#include "../include/esp3d_config.h"
|
||||
|
||||
enum class ESP3DState : uint8_t {
|
||||
off = 0,
|
||||
on = 1,
|
||||
};
|
||||
|
||||
enum class ESP3DSettingType : uint8_t {
|
||||
byte_t, // byte
|
||||
integer_t, // 4 bytes
|
||||
string_t, // string
|
||||
ip_t, // 4 bytes
|
||||
float_t, // 4 bytes
|
||||
mask, // x bytes
|
||||
bitsfield, // x bytes
|
||||
unknown_t
|
||||
};
|
||||
|
||||
#endif //_SETTINGS_ESP3D_H
|
||||
struct ESP3DSettingDescription {
|
||||
ESP3DSettingIndex index;
|
||||
ESP3DSettingType type;
|
||||
uint16_t size;
|
||||
const char *default_val;
|
||||
};
|
||||
#ifdef SD_DEVICE
|
||||
extern const uint8_t SupportedSPIDivider[];
|
||||
extern const uint8_t SupportedSPIDividerSize;
|
||||
#endif // SD_DEVICE
|
||||
#if defined(WIFI_FEATURE)
|
||||
extern const uint8_t SupportedApChannels[];
|
||||
extern const uint8_t SupportedApChannelsSize;
|
||||
#endif // WIFI_FEATURE
|
||||
|
||||
class Settings_ESP3D {
|
||||
public:
|
||||
static bool begin();
|
||||
static uint8_t read_byte(int pos, bool *haserror = NULL);
|
||||
static uint32_t read_uint32(int pos, bool *haserror = NULL);
|
||||
static uint32_t read_IP(int pos, bool *haserror = NULL);
|
||||
static String read_IP_String(int pos, bool *haserror = NULL);
|
||||
static const char *read_string(int pos, bool *haserror = NULL);
|
||||
static bool write_byte(int pos, const uint8_t value);
|
||||
static bool write_string(int pos, const char *byte_buffer);
|
||||
static bool write_uint32(int pos, const uint32_t value);
|
||||
static bool write_IP(int pos, const uint32_t value);
|
||||
static bool write_IP_String(int pos, const char *value);
|
||||
static bool reset(bool networkonly = false);
|
||||
static int8_t GetSettingsVersion();
|
||||
static uint8_t GetFirmwareTarget(bool fromsettings = false);
|
||||
static bool isVerboseBoot(bool fromsettings = false);
|
||||
static uint8_t GetSDDevice();
|
||||
static const char *GetFirmwareTargetShortName();
|
||||
static const char *TargetBoard();
|
||||
|
||||
static bool isValidIPStringSetting(const char *value,
|
||||
ESP3DSettingIndex settingElement);
|
||||
static bool isValidStringSetting(const char *value,
|
||||
ESP3DSettingIndex settingElement);
|
||||
static bool isValidIntegerSetting(uint32_t value,
|
||||
ESP3DSettingIndex settingElement);
|
||||
static bool isValidByteSetting(uint8_t value,
|
||||
ESP3DSettingIndex settingElement);
|
||||
static uint32_t getDefaultIntegerSetting(ESP3DSettingIndex settingElement);
|
||||
static const char *getDefaultStringSetting(ESP3DSettingIndex settingElement);
|
||||
static uint8_t getDefaultByteSetting(ESP3DSettingIndex settingElement);
|
||||
|
||||
static const ESP3DSettingDescription *getSettingPtr(
|
||||
const ESP3DSettingIndex index);
|
||||
|
||||
private:
|
||||
static String _IpToString(uint32_t ip_int);
|
||||
static uint32_t _stringToIP(const char *s);
|
||||
static bool is_string(const char *s, uint len);
|
||||
static uint8_t _FirmwareTarget;
|
||||
static bool _isverboseboot;
|
||||
};
|
||||
|
||||
#endif //_SETTINGS_ESP3D_H
|
||||
|
@ -36,14 +36,7 @@
|
||||
#define GRBLHAL 80
|
||||
#define HP_GL 90
|
||||
|
||||
// Default flags
|
||||
#define DEFAULT_SERIAL_OUTPUT_FLAG 1
|
||||
#define DEFAULT_REMOTE_SCREEN_FLAG 1
|
||||
#define DEFAULT_WEBSOCKET_FLAG 1
|
||||
#define DEFAULT_TELNET_FLAG 1
|
||||
#define DEFAULT_BT_FLAG 1
|
||||
#define DEFAULT_SCREEN_FLAG 1
|
||||
#define DEFAULT_SERIAL_BRIDGE_FLAG 1
|
||||
typedef uint ESP3DSettingIndex;
|
||||
|
||||
// position in EEPROM / preferences will use `P_` + <position> to make a string
|
||||
// : P_0 for 0
|
||||
|
@ -18,69 +18,60 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "../../include/esp3d_config.h"
|
||||
#include "boot_delay.h"
|
||||
#include "../../core/settings_esp3d.h"
|
||||
|
||||
#include "../../core/esp3doutput.h"
|
||||
#include "../../core/settings_esp3d.h"
|
||||
#include "../../include/esp3d_config.h"
|
||||
|
||||
#if defined(RECOVERY_FEATURE)
|
||||
#include "../recovery/recovery_service.h"
|
||||
#endif //RECOVERY_FEATURE
|
||||
#endif // RECOVERY_FEATURE
|
||||
|
||||
BootDelay::BootDelay()
|
||||
{
|
||||
_started = false;
|
||||
_startdelay = 0;
|
||||
_totalduration = 0;
|
||||
}
|
||||
BootDelay::~BootDelay()
|
||||
{
|
||||
end();
|
||||
BootDelay::BootDelay() {
|
||||
_started = false;
|
||||
_startdelay = 0;
|
||||
_totalduration = 0;
|
||||
}
|
||||
BootDelay::~BootDelay() { end(); }
|
||||
|
||||
bool BootDelay::started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
bool BootDelay::started() { return _started; }
|
||||
|
||||
bool BootDelay::begin()
|
||||
{
|
||||
_totalduration = Settings_ESP3D::read_uint32(ESP_BOOT_DELAY);
|
||||
log_esp3d("Boot delay %d", _totalduration);
|
||||
if (_totalduration > Settings_ESP3D::get_max_int32_value(ESP_BOOT_DELAY)) {
|
||||
_totalduration = Settings_ESP3D::get_default_int32_value(ESP_BOOT_DELAY);
|
||||
log_esp3d("Boot delay modified %d", _totalduration);
|
||||
}
|
||||
_started = true;
|
||||
ESP3DOutput::toScreen(ESP_OUTPUT_PROGRESS, "0");
|
||||
if (_totalduration > 0) {
|
||||
_startdelay = millis();
|
||||
handle();
|
||||
}
|
||||
ESP3DOutput::toScreen(ESP_OUTPUT_PROGRESS, "100");
|
||||
log_esp3d("Boot delay done");
|
||||
return _started;
|
||||
}
|
||||
void BootDelay::end()
|
||||
{
|
||||
bool BootDelay::begin() {
|
||||
_totalduration = Settings_ESP3D::read_uint32(ESP_BOOT_DELAY);
|
||||
log_esp3d("Boot delay %d", _totalduration);
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(_totalduration, ESP_BOOT_DELAY)) {
|
||||
_totalduration = Settings_ESP3D::getDefaultIntegerSetting(ESP_BOOT_DELAY);
|
||||
log_esp3d("Boot delay modified %d", _totalduration);
|
||||
}
|
||||
_started = true;
|
||||
ESP3DOutput::toScreen(ESP_OUTPUT_PROGRESS, "0");
|
||||
if (_totalduration > 0) {
|
||||
_startdelay = millis();
|
||||
handle();
|
||||
}
|
||||
ESP3DOutput::toScreen(ESP_OUTPUT_PROGRESS, "100");
|
||||
log_esp3d("Boot delay done");
|
||||
return _started;
|
||||
}
|
||||
void BootDelay::end() {}
|
||||
|
||||
void BootDelay::handle()
|
||||
{
|
||||
uint8_t lastpercent = 0;
|
||||
uint32_t lastSent = millis();
|
||||
while ((millis() - _startdelay) < _totalduration) {
|
||||
void BootDelay::handle() {
|
||||
uint8_t lastpercent = 0;
|
||||
uint32_t lastSent = millis();
|
||||
while ((millis() - _startdelay) < _totalduration) {
|
||||
#if defined(RECOVERY_FEATURE)
|
||||
recovery_service.handle();
|
||||
#endif //RECOVERY_FEATURE
|
||||
//to avoid overfload 2x/sec is enough for progression
|
||||
if ((millis() - lastSent) > 500) {
|
||||
lastSent = millis();
|
||||
uint8_t p = (100*(millis() - _startdelay))/_totalduration;
|
||||
if (p != lastpercent) {
|
||||
lastpercent=p;
|
||||
ESP3DOutput::toScreen(ESP_OUTPUT_PROGRESS, String(p).c_str());
|
||||
}
|
||||
}
|
||||
Hal::wait(10);
|
||||
recovery_service.handle();
|
||||
#endif // RECOVERY_FEATURE
|
||||
// to avoid overfload 2x/sec is enough for progression
|
||||
if ((millis() - lastSent) > 500) {
|
||||
lastSent = millis();
|
||||
uint8_t p = (100 * (millis() - _startdelay)) / _totalduration;
|
||||
if (p != lastpercent) {
|
||||
lastpercent = p;
|
||||
ESP3DOutput::toScreen(ESP_OUTPUT_PROGRESS, String(p).c_str());
|
||||
}
|
||||
}
|
||||
Hal::wait(10);
|
||||
}
|
||||
}
|
||||
|
@ -18,27 +18,26 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _BOOT_DELAY_H
|
||||
#define _BOOT_DELAY_H
|
||||
|
||||
typedef void (progress_t)(uint8_t percent);
|
||||
#include <cstdint>
|
||||
|
||||
class BootDelay
|
||||
{
|
||||
public:
|
||||
BootDelay();
|
||||
~BootDelay();
|
||||
bool begin();
|
||||
void end();
|
||||
void handle();
|
||||
bool started();
|
||||
private:
|
||||
bool _started;
|
||||
uint32_t _startdelay;
|
||||
uint32_t _totalduration;
|
||||
typedef void(progress_t)(uint8_t percent);
|
||||
|
||||
class BootDelay {
|
||||
public:
|
||||
BootDelay();
|
||||
~BootDelay();
|
||||
bool begin();
|
||||
void end();
|
||||
void handle();
|
||||
bool started();
|
||||
|
||||
private:
|
||||
bool _started;
|
||||
uint32_t _startdelay;
|
||||
uint32_t _totalduration;
|
||||
};
|
||||
|
||||
#endif //_BOOT_DELAY_H
|
||||
|
||||
#endif //_BOOT_DELAY_H
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "../../../core/settings_esp3d.h"
|
||||
#include "../../authentication/authentication_service.h"
|
||||
|
||||
|
||||
// login status check
|
||||
void HTTP_Server::handle_login() {
|
||||
HTTP_Server::set_http_headers();
|
||||
@ -67,7 +66,8 @@ void HTTP_Server::handle_login() {
|
||||
if (_webserver->hasArg("NEWPASSWORD")) {
|
||||
String newpassword = _webserver->arg("NEWPASSWORD");
|
||||
// check new password
|
||||
if (Settings_ESP3D::isLocalPasswordValid(newpassword.c_str())) {
|
||||
if (Settings_ESP3D::isValidStringSetting(newpassword.c_str(),
|
||||
ESP_ADMIN_PWD)) {
|
||||
if (!Settings_ESP3D::write_string(ESP_ADMIN_PWD,
|
||||
newpassword.c_str())) {
|
||||
code = 500;
|
||||
|
@ -80,30 +80,6 @@ String NetConfig::IP_string_from_int(uint32_t ip_int) {
|
||||
return ipaddr.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Hostname string is valid
|
||||
*/
|
||||
|
||||
bool NetConfig::isHostnameValid(const char* hostname) {
|
||||
// limited size
|
||||
char c;
|
||||
if (strlen(hostname) > MAX_HOSTNAME_LENGTH ||
|
||||
strlen(hostname) < MIN_HOSTNAME_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
// only letter and digit
|
||||
for (uint i = 0; i < strlen(hostname); i++) {
|
||||
c = hostname[i];
|
||||
if (!(isdigit(c) || isalpha(c) || c == '-')) {
|
||||
return false;
|
||||
}
|
||||
if (c == ' ') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IP Integer what ever is enabled
|
||||
*/
|
||||
@ -148,15 +124,6 @@ String NetConfig::localIP() {
|
||||
return currentIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if IP string is valid
|
||||
*/
|
||||
|
||||
bool NetConfig::isValidIP(const char* string) {
|
||||
IPAddress ip;
|
||||
return ip.fromString(string);
|
||||
}
|
||||
|
||||
// wifi event
|
||||
void NetConfig::onWiFiEvent(WiFiEvent_t event) {
|
||||
ESP3DOutput output(ESP_ALL_CLIENTS);
|
||||
|
@ -18,63 +18,55 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//boundaries
|
||||
|
||||
|
||||
#define MAX_WEBDAV_PORT 65001
|
||||
#define MIN_WEBDAV_PORT 1
|
||||
#define MAX_HTTP_PORT 65001
|
||||
#define MIN_HTTP_PORT 1
|
||||
#define MAX_FTP_PORT 65001
|
||||
#define MIN_FTP_PORT 1
|
||||
#define MAX_TELNET_PORT 65001
|
||||
#define MIN_TELNET_PORT 1
|
||||
#define MAX_WEBSOCKET_PORT 65001
|
||||
#define MIN_WEBSOCKET_PORT 1
|
||||
#define MAX_HOSTNAME_LENGTH 32
|
||||
#define MIN_HOSTNAME_LENGTH 1
|
||||
|
||||
// boundaries
|
||||
|
||||
#define MAX_WEBDAV_PORT 65001
|
||||
#define MIN_WEBDAV_PORT 1
|
||||
#define MAX_HTTP_PORT 65001
|
||||
#define MIN_HTTP_PORT 1
|
||||
#define MAX_FTP_PORT 65001
|
||||
#define MIN_FTP_PORT 1
|
||||
#define MAX_TELNET_PORT 65001
|
||||
#define MIN_TELNET_PORT 1
|
||||
#define MAX_WEBSOCKET_PORT 65001
|
||||
#define MIN_WEBSOCKET_PORT 1
|
||||
#define MAX_HOSTNAME_LENGTH 32
|
||||
#define MIN_HOSTNAME_LENGTH 1
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include <WiFi.h>
|
||||
#endif //ARDUINO_ARCH_ESP32
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif //ARDUINO_ARCH_ESP8266
|
||||
#endif // ARDUINO_ARCH_ESP8266
|
||||
|
||||
#ifndef _NET_CONFIG_H
|
||||
#define _NET_CONFIG_H
|
||||
|
||||
class NetConfig
|
||||
{
|
||||
public:
|
||||
static bool isValidIP(const char * string);
|
||||
static bool isHostnameValid (const char * hostname);
|
||||
static uint32_t IP_int_from_string(const char * s);
|
||||
static String IP_string_from_int(uint32_t ip_int);
|
||||
static bool isIPModeDHCP(uint8_t mode);
|
||||
static bool isDHCPServer (uint8_t mode);
|
||||
static const char* hostname(bool fromsettings = false);
|
||||
static char * mac2str (uint8_t mac [8]);
|
||||
static bool begin();
|
||||
static void end();
|
||||
static void handle();
|
||||
static uint8_t getMode();
|
||||
static void setMode(uint8_t mode);
|
||||
static bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
static String localIP();
|
||||
static IPAddress localIPAddress();
|
||||
private :
|
||||
static String _hostname;
|
||||
static void onWiFiEvent(WiFiEvent_t event);
|
||||
static bool _needReconnect2AP;
|
||||
static bool _events_registered;
|
||||
static bool _started;
|
||||
static uint8_t _mode;
|
||||
class NetConfig {
|
||||
public:
|
||||
static uint32_t IP_int_from_string(const char* s);
|
||||
static String IP_string_from_int(uint32_t ip_int);
|
||||
static bool isIPModeDHCP(uint8_t mode);
|
||||
static bool isDHCPServer(uint8_t mode);
|
||||
static const char* hostname(bool fromsettings = false);
|
||||
static char* mac2str(uint8_t mac[8]);
|
||||
static bool begin();
|
||||
static void end();
|
||||
static void handle();
|
||||
static uint8_t getMode();
|
||||
static void setMode(uint8_t mode);
|
||||
static bool started() { return _started; }
|
||||
static String localIP();
|
||||
static IPAddress localIPAddress();
|
||||
|
||||
private:
|
||||
static String _hostname;
|
||||
static void onWiFiEvent(WiFiEvent_t event);
|
||||
static bool _needReconnect2AP;
|
||||
static bool _events_registered;
|
||||
static bool _started;
|
||||
static uint8_t _mode;
|
||||
};
|
||||
|
||||
#endif //_NET_CONFIG_H
|
||||
#endif //_NET_CONFIG_H
|
||||
|
@ -66,6 +66,7 @@ TaskHandle_t _hserialtask = nullptr;
|
||||
const long SupportedBaudList[] = {9600, 19200, 38400, 57600,
|
||||
74880, 115200, 230400, 250000,
|
||||
500000, 921600, 1958400};
|
||||
const size_t SupportedBaudListSize = sizeof(SupportedBaudList) / sizeof(long);
|
||||
|
||||
#define TIMEOUT_SERIAL_FLUSH 1500
|
||||
// Constructor
|
||||
@ -140,13 +141,13 @@ bool SerialService::begin(uint8_t serialIndex) {
|
||||
switch (_id) {
|
||||
case MAIN_SERIAL:
|
||||
br = Settings_ESP3D::read_uint32(ESP_BAUD_RATE);
|
||||
defaultBr = Settings_ESP3D::get_default_int32_value(ESP_BAUD_RATE);
|
||||
defaultBr = Settings_ESP3D::getDefaultIntegerSetting(ESP_BAUD_RATE);
|
||||
break;
|
||||
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
case BRIDGE_SERIAL:
|
||||
br = Settings_ESP3D::read_uint32(ESP_SERIAL_BRIDGE_BAUD);
|
||||
defaultBr =
|
||||
Settings_ESP3D::get_default_int32_value(ESP_SERIAL_BRIDGE_BAUD);
|
||||
Settings_ESP3D::getDefaultIntegerSetting(ESP_SERIAL_BRIDGE_BAUD);
|
||||
break;
|
||||
#endif // ESP_SERIAL_BRIDGE_OUTPUT
|
||||
default:
|
||||
@ -159,7 +160,7 @@ bool SerialService::begin(uint8_t serialIndex) {
|
||||
_buffer_size = 0;
|
||||
// change only if different from current
|
||||
if (br != baudRate() || (_rxPin != -1) || (_txPin != -1)) {
|
||||
if (!is_valid_baudrate(br)) {
|
||||
if (!Settings_ESP3D::isValidIntegerSetting(br, ESP_BAUD_RATE)) {
|
||||
br = defaultBr;
|
||||
}
|
||||
Serials[_serialIndex]->setRxBufferSize(SERIAL_RX_BUFFER_SIZE);
|
||||
@ -217,17 +218,6 @@ const long *SerialService::get_baudratelist(uint8_t *count) {
|
||||
return SupportedBaudList;
|
||||
}
|
||||
|
||||
// check if value is in baudrate list
|
||||
bool SerialService::is_valid_baudrate(long br) {
|
||||
uint8_t listesize = sizeof(SupportedBaudList) / sizeof(long);
|
||||
for (uint8_t i = 0; i < listesize; i++) {
|
||||
if (SupportedBaudList[i] == br) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Function which could be called in other loop
|
||||
void SerialService::process() {
|
||||
if (!_started) {
|
||||
@ -421,15 +411,15 @@ bool SerialService::reset() {
|
||||
case MAIN_SERIAL:
|
||||
return Settings_ESP3D::write_uint32(
|
||||
ESP_BAUD_RATE,
|
||||
Settings_ESP3D::get_default_int32_value(ESP_BAUD_RATE));
|
||||
Settings_ESP3D::getDefaultIntegerSetting(ESP_BAUD_RATE));
|
||||
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
|
||||
case BRIDGE_SERIAL:
|
||||
res = Settings_ESP3D::write_byte(
|
||||
ESP_SERIAL_BRIDGE_ON,
|
||||
Settings_ESP3D::get_default_byte_value(ESP_SERIAL_BRIDGE_ON));
|
||||
Settings_ESP3D::getDefaultByteSetting(ESP_SERIAL_BRIDGE_ON));
|
||||
return res && Settings_ESP3D::write_uint32(
|
||||
ESP_SERIAL_BRIDGE_BAUD,
|
||||
Settings_ESP3D::get_default_int32_value(
|
||||
Settings_ESP3D::getDefaultIntegerSetting(
|
||||
ESP_SERIAL_BRIDGE_BAUD));
|
||||
#endif // ESP_SERIAL_BRIDGE_OUTPUT
|
||||
default:
|
||||
|
@ -25,6 +25,9 @@
|
||||
|
||||
#define ESP3D_SERIAL_BUFFER_SIZE 1024
|
||||
|
||||
extern const long SupportedBaudList[];
|
||||
extern const size_t SupportedBaudListSize;
|
||||
|
||||
class SerialService : public Print {
|
||||
public:
|
||||
SerialService(uint8_t id);
|
||||
@ -43,7 +46,6 @@ class SerialService : public Print {
|
||||
void swap();
|
||||
int availableForWrite();
|
||||
int available();
|
||||
bool is_valid_baudrate(long br);
|
||||
size_t write(uint8_t c);
|
||||
size_t write(const uint8_t *buffer, size_t size);
|
||||
inline size_t write(const char *s) { return write((uint8_t *)s, strlen(s)); }
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define _TIME_SERVICE_H
|
||||
|
||||
#include <time.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
class TimeService {
|
||||
public:
|
||||
|
@ -104,7 +104,7 @@ void WebdavServer::handler_get(const char* url) {
|
||||
}
|
||||
} else {
|
||||
code = 400;
|
||||
log_esp3d_e("Root cannot be deleted");
|
||||
log_esp3d_e("Root cannot be used as it is");
|
||||
}
|
||||
if (code != 200) {
|
||||
log_esp3d_e("Sending response code %d", code);
|
||||
|
@ -30,27 +30,8 @@
|
||||
#include "../network/netconfig.h"
|
||||
#include "../wifi/wificonfig.h"
|
||||
|
||||
|
||||
const uint8_t DEFAULT_AP_MASK_VALUE[] = {255, 255, 255, 0};
|
||||
|
||||
/**
|
||||
* Check if SSID string is valid
|
||||
*/
|
||||
bool WiFiConfig::isSSIDValid(const char* ssid) {
|
||||
// limited size
|
||||
// char c;
|
||||
if (strlen(ssid) > MAX_SSID_LENGTH || strlen(ssid) < MIN_SSID_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
// only printable
|
||||
for (uint i = 0; i < strlen(ssid); i++) {
|
||||
if (!isPrintable(ssid[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* WiFiConfig::hostname() {
|
||||
static String tmp;
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
@ -73,22 +54,6 @@ const char* WiFiConfig::hostname() {
|
||||
return tmp.c_str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if password string is valid
|
||||
*/
|
||||
|
||||
bool WiFiConfig::isPasswordValid(const char* password) {
|
||||
if (strlen(password) == 0) {
|
||||
return true; // open network
|
||||
}
|
||||
// limited size
|
||||
if ((strlen(password) > MAX_PASSWORD_LENGTH) ||
|
||||
(strlen(password) < MIN_PASSWORD_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get WiFi signal strength
|
||||
*/
|
||||
|
@ -18,16 +18,16 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//boundaries
|
||||
#define MIN_RSSI -78
|
||||
#define MAX_SSID_LENGTH 32
|
||||
#define MIN_SSID_LENGTH 1
|
||||
#define MIN_CHANNEL 1
|
||||
#define MAX_CHANNEL 14
|
||||
#define MAX_PASSWORD_LENGTH 64
|
||||
//min size of password is 0 or upper than 8 char
|
||||
//0 is special case so let's put 8
|
||||
#define MIN_PASSWORD_LENGTH 8
|
||||
// boundaries
|
||||
#define MIN_RSSI -78
|
||||
#define MAX_SSID_LENGTH 32
|
||||
#define MIN_SSID_LENGTH 1
|
||||
#define MIN_CHANNEL 1
|
||||
#define MAX_CHANNEL 14
|
||||
#define MAX_PASSWORD_LENGTH 64
|
||||
// min size of password is 0 or upper than 8 char
|
||||
// 0 is special case so let's put 8
|
||||
#define MIN_PASSWORD_LENGTH 8
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include <WiFi.h>
|
||||
#define WIFI_NONE_SLEEP WIFI_PS_NONE
|
||||
@ -35,7 +35,8 @@
|
||||
#define WIFI_MODEM_SLEEP WIFI_PS_MAX_MODEM
|
||||
#define WIFI_PHY_MODE_11B WIFI_PROTOCOL_11B
|
||||
#define WIFI_PHY_MODE_11G WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G
|
||||
#define WIFI_PHY_MODE_11N WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N
|
||||
#define WIFI_PHY_MODE_11N \
|
||||
WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N
|
||||
#define AUTH_OPEN WIFI_AUTH_OPEN
|
||||
#define AUTH_WEP WIFI_AUTH_WEP
|
||||
#define AUTH_WPA_PSK WIFI_AUTH_WPA_PSK
|
||||
@ -43,38 +44,37 @@
|
||||
#define AUTH_WPA_WPA2_PSK WIFI_AUTH_WPA_WPA2_PSK
|
||||
#define ENC_TYPE_NONE AUTH_OPEN
|
||||
#define WiFiMode_t wifi_mode_t
|
||||
#endif //ARDUINO_ARCH_ESP32
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif //ARDUINO_ARCH_ESP8266
|
||||
#endif // ARDUINO_ARCH_ESP8266
|
||||
|
||||
#ifndef _WIFI_CONFIG_H
|
||||
#define _WIFI_CONFIG_H
|
||||
|
||||
class WiFiConfig
|
||||
{
|
||||
public:
|
||||
static bool isPasswordValid (const char * password);
|
||||
static bool isSSIDValid (const char * ssid);
|
||||
static bool StartAP(bool setupMode = false);
|
||||
static bool StartSTA();
|
||||
static void StopWiFi();
|
||||
static int32_t getSignal (int32_t RSSI, bool filter=true);
|
||||
static const char* getSleepModeString ();
|
||||
static const char* getPHYModeString (uint8_t wifimode);
|
||||
static bool is_AP_visible();
|
||||
static const char * AP_SSID();
|
||||
static const char * hostname();
|
||||
static const char * AP_Auth_String();
|
||||
static const char * AP_Gateway_String();
|
||||
static const char * AP_Mask_String();
|
||||
static const char* getConnectedSTA(uint8_t * totalcount = NULL, bool reset = false);
|
||||
static bool started();
|
||||
static bool begin(int8_t & espMode);
|
||||
static void end();
|
||||
static void handle();
|
||||
private :
|
||||
static bool ConnectSTA2AP();
|
||||
class WiFiConfig {
|
||||
public:
|
||||
static bool StartAP(bool setupMode = false);
|
||||
static bool StartSTA();
|
||||
static void StopWiFi();
|
||||
static int32_t getSignal(int32_t RSSI, bool filter = true);
|
||||
static const char* getSleepModeString();
|
||||
static const char* getPHYModeString(uint8_t wifimode);
|
||||
static bool is_AP_visible();
|
||||
static const char* AP_SSID();
|
||||
static const char* hostname();
|
||||
static const char* AP_Auth_String();
|
||||
static const char* AP_Gateway_String();
|
||||
static const char* AP_Mask_String();
|
||||
static const char* getConnectedSTA(uint8_t* totalcount = NULL,
|
||||
bool reset = false);
|
||||
static bool started();
|
||||
static bool begin(int8_t& espMode);
|
||||
static void end();
|
||||
static void handle();
|
||||
|
||||
private:
|
||||
static bool ConnectSTA2AP();
|
||||
};
|
||||
|
||||
#endif //_WIFI_CONFIG_H
|
||||
#endif //_WIFI_CONFIG_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user