mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-06-06 02:36:49 +08:00
Add M118 support
Add 4G capacity support Fix empty string saving
This commit is contained in:
parent
6c877d34df
commit
cc6e4ad3a4
@ -36,14 +36,21 @@ Commands::~Commands()
|
|||||||
void Commands::process(uint8_t * sbuf, size_t len, ESP3DOutput * output, level_authenticate_type auth, ESP3DOutput * outputonly )
|
void Commands::process(uint8_t * sbuf, size_t len, ESP3DOutput * output, level_authenticate_type auth, ESP3DOutput * outputonly )
|
||||||
{
|
{
|
||||||
if(is_esp_command(sbuf,len)) {
|
if(is_esp_command(sbuf,len)) {
|
||||||
|
size_t slen = len;
|
||||||
|
String tmpbuf = (const char*)sbuf;
|
||||||
|
if (tmpbuf.startsWith("echo: ")){
|
||||||
|
tmpbuf.replace("echo: ", "");
|
||||||
|
slen = tmpbuf.length();
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t cmd[4];
|
uint8_t cmd[4];
|
||||||
cmd[0] = sbuf[4];
|
cmd[0] = tmpbuf[4];
|
||||||
cmd[1] = sbuf[5];
|
cmd[1] = tmpbuf[5];
|
||||||
cmd[2] = sbuf[6];
|
cmd[2] = tmpbuf[6];
|
||||||
cmd[3] = 0x0;
|
cmd[3] = 0x0;
|
||||||
|
|
||||||
//log_esp3d("Authentication = %d client %d", auth, output->client());
|
//log_esp3d("Authentication = %d client %d", auth, output->client());
|
||||||
execute_internal_command (String((const char *)cmd).toInt(), (len > 8)?(const char*)&sbuf[8]:"", auth, (outputonly == nullptr)?output:outputonly);
|
execute_internal_command (String((const char*)cmd).toInt(), (slen > 8)?(const char*)&tmpbuf[8]:"", auth, (outputonly == nullptr)?output:outputonly);
|
||||||
} else {
|
} else {
|
||||||
//Dispatch to all clients but current or to define output
|
//Dispatch to all clients but current or to define output
|
||||||
if ((output->client() == ESP_HTTP_CLIENT) && (outputonly == nullptr)) {
|
if ((output->client() == ESP_HTTP_CLIENT) && (outputonly == nullptr)) {
|
||||||
@ -73,6 +80,13 @@ bool Commands::is_esp_command(uint8_t * sbuf, size_t len)
|
|||||||
if ((char(sbuf[0]) == '[') && (char(sbuf[1]) == 'E') && (char(sbuf[2]) == 'S') && (char(sbuf[3]) == 'P') && (char(sbuf[7]) == ']')) {
|
if ((char(sbuf[0]) == '[') && (char(sbuf[1]) == 'E') && (char(sbuf[2]) == 'S') && (char(sbuf[3]) == 'P') && (char(sbuf[7]) == ']')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if((char(sbuf[0]) == 'e') && (char(sbuf[1]) == 'c') && (char(sbuf[2]) == 'h') && (char(sbuf[3]) == 'o') && (char(sbuf[4]) == ':') && (char(sbuf[5]) == ' ') && (char(sbuf[6]) == '[') && (char(sbuf[7]) == 'E')) {
|
||||||
|
if (len >= 14){
|
||||||
|
if ((char(sbuf[8]) == 'S') && (char(sbuf[9]) == 'P') && (char(sbuf[13]) == ']')){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,7 +842,7 @@ bool Settings_ESP3D::write_string (int pos, const char * byte_buffer)
|
|||||||
String p = "P_" + String(pos);
|
String p = "P_" + String(pos);
|
||||||
uint8_t r = prefs.putString(p.c_str(), byte_buffer);
|
uint8_t r = prefs.putString(p.c_str(), byte_buffer);
|
||||||
prefs.end();
|
prefs.end();
|
||||||
if (r == 0) {
|
if (r != size_buffer) {
|
||||||
log_esp3d("Error commit %s", p.c_str());
|
log_esp3d("Error commit %s", p.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -54,17 +54,17 @@ ESP_FileSystem::~ESP_FileSystem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//helper to format size to readable string
|
//helper to format size to readable string
|
||||||
String & ESP_FileSystem::formatBytes (uint32_t bytes)
|
String & ESP_FileSystem::formatBytes (uint64_t bytes)
|
||||||
{
|
{
|
||||||
static String res;
|
static String res;
|
||||||
if (bytes < 1024) {
|
if (bytes < 1024) {
|
||||||
res = String (bytes) + " B";
|
res = String ((uint16_t)bytes) + " B";
|
||||||
} else if (bytes < (1024 * 1024) ) {
|
} else if (bytes < (1024 * 1024) ) {
|
||||||
res = String (bytes / 1024.0) + " KB";
|
res = String ((float)(bytes / 1024.0),2) + " KB";
|
||||||
} else if (bytes < (1024 * 1024 * 1024) ) {
|
} else if (bytes < (1024 * 1024 * 1024) ) {
|
||||||
res = String (bytes / 1024.0 / 1024.0) + " MB";
|
res = String ((float)(bytes / 1024.0 / 1024.0),2) + " MB";
|
||||||
} else {
|
} else {
|
||||||
res = String (bytes / 1024.0 / 1024.0 / 1024.0) + " GB";
|
res = String ((float)(bytes / 1024.0 / 1024.0 / 1024.0),2) + " GB";
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
class ESP_FileSystem
|
class ESP_FileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static String & formatBytes (uint32_t bytes);
|
static String & formatBytes (uint64_t bytes);
|
||||||
ESP_FileSystem();
|
ESP_FileSystem();
|
||||||
~ESP_FileSystem();
|
~ESP_FileSystem();
|
||||||
static bool begin();
|
static bool begin();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user