Refactoring internal clients (#987)

* Remove all output flags
* Masse replace name function / class to sync with ESP3D-TFT
* Create ESP3DMessageManager  class to handle messages creation / deletion (import functions of ESp3DClient from ESp3D-TFT)
*  Move to new messaging API of ESP3D-TFT
* Remove empty line from remote screen dispatching
* Replace \n to space and \r to nothing in remote screen dispatching
* Add missing default entry for sensor device
* Fix buzzer for ESP32 missing ledc initialization with latest core
* Move formatBytes to esp3d_string
* Add welcome message to telnet connection\
* Add display to the new messaging API
* Add sticky authentication on Serial / SerialBridge /Telnet/Data web socket and BT
* Log simplification
* Use enum class instead of typdef enum for ESP3DAuthenticationLevel  to be sure correct enum is used
* (v3) Home Assistant notification support (#971)
* Add notification via post request
* Extend t1 size to 255 bytes
* Hide Home Assistant notifications from web UI (#974)
* Sync with ESP3DLib on serial_socket
* Add some sanity check to avoid unnecessary message copies
* Update ESP0.cpp

---------

Co-authored-by: David Buezas <dbuezas@users.noreply.github.com>
This commit is contained in:
Luc
2024-01-03 10:46:13 +08:00
committed by GitHub
parent dabc95bc8c
commit a10a7f74bf
274 changed files with 21311 additions and 21782 deletions

View File

@@ -60,7 +60,7 @@ void update_hash(uint8_t* data, size_t len, uint8_t* hash_buffer,
static bool reverse = false;
reverse = !reverse;
int start_index = reverse ? hash_size : 0;
for (int i = 0; i < hash_size; i++) {
for (uint8_t i = 0; i < hash_size; i++) {
int idx =
reverse ? (start_index - i) % hash_size : (start_index + i) % hash_size;
if (i >= len) {
@@ -147,4 +147,35 @@ const char* esp3d_string::getContentType(const char* filename) {
return "text/plain";
}
return "application/octet-stream";
}
// tool function to avoid string corrupt JSON files
const char* esp3d_string::encodeString(const char* s) {
static String tmp;
tmp = s;
while (tmp.indexOf("'") != -1) {
tmp.replace("'", "&#39;");
}
while (tmp.indexOf("\"") != -1) {
tmp.replace("\"", "&#34;");
}
if (tmp == "") {
tmp = " ";
}
return tmp.c_str();
}
// helper to format size to readable string
const char* esp3d_string::formatBytes(uint64_t bytes) {
static String res;
if (bytes < 1024) {
res = String((uint16_t)bytes) + " B";
} else if (bytes < (1024 * 1024)) {
res = String((float)(bytes / 1024.0), 2) + " KB";
} else if (bytes < (1024 * 1024 * 1024)) {
res = String((float)(bytes / 1024.0 / 1024.0), 2) + " MB";
} else {
res = String((float)(bytes / 1024.0 / 1024.0 / 1024.0), 2) + " GB";
}
return res.c_str();
}