diff --git a/esp3d/src/core/esp3d_settings.cpp b/esp3d/src/core/esp3d_settings.cpp index 09691b73..555fe2d5 100644 --- a/esp3d/src/core/esp3d_settings.cpp +++ b/esp3d/src/core/esp3d_settings.cpp @@ -26,6 +26,7 @@ #if defined(ESP_SAVE_SETTINGS) #include "esp3d_message.h" #include "esp3d_settings.h" +#include "esp3d_string.h" #if ESP_SAVE_SETTINGS == SETTINGS_IN_EEPROM #include @@ -386,7 +387,7 @@ bool ESP3DSettings::writeByte(int pos, const uint8_t value) { bool ESP3DSettings::is_string(const char *s, uint len) { for (uint p = 0; p < len; p++) { - if (!isPrintable(char(s[p]))) { + if (!esp3d_string::isPrintableChar(char(s[p]))) { return false; } } @@ -431,7 +432,7 @@ const char *ESP3DSettings::readString(int pos, bool *haserror) { // read until max size is reached or \0 is found while (i < size_max && b != 0) { b = EEPROM.read(pos + i); - byte_buffer[i] = isPrintable(char(b)) ? b : 0; + byte_buffer[i] = esp3d_string::isPrintableChar(char(b)) ? b : 0; i++; } @@ -778,7 +779,7 @@ bool ESP3DSettings::isValidStringSetting(const char *value, } // only printable char allowed for (size_t i = 0; i < strlen(value); i++) { - if (!isPrintable(value[i])) { + if (!esp3d_string::isPrintableChar(value[i])) { return false; } } diff --git a/esp3d/src/core/esp3d_string.cpp b/esp3d/src/core/esp3d_string.cpp index 8f8e8881..78b4f227 100644 --- a/esp3d/src/core/esp3d_string.cpp +++ b/esp3d/src/core/esp3d_string.cpp @@ -178,4 +178,12 @@ const char* esp3d_string::formatBytes(uint64_t bytes) { res = String((float)(bytes / 1024.0 / 1024.0 / 1024.0), 2) + " GB"; } return res.c_str(); +} + +bool esp3d_string::isPrintableChar(char ch){ + int c = static_cast(ch); +if (c==9 || (c >= 32 && c <= 126) || c>=128) { + return true; + } + return false; } \ No newline at end of file diff --git a/esp3d/src/core/esp3d_string.h b/esp3d/src/core/esp3d_string.h index 2426adf8..f94668d2 100644 --- a/esp3d/src/core/esp3d_string.h +++ b/esp3d/src/core/esp3d_string.h @@ -27,6 +27,7 @@ const char* generateUUID(const char* seed); const char* getContentType(const char* filename); const char* encodeString(const char* s); const char* formatBytes(uint64_t bytes); +bool isPrintableChar(char c); } // namespace esp3d_string #endif //_ESP3D_STRING_H diff --git a/esp3d/src/include/esp3d_version.h b/esp3d/src/include/esp3d_version.h index b7e485fe..aeb0261d 100644 --- a/esp3d/src/include/esp3d_version.h +++ b/esp3d/src/include/esp3d_version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H // version and sources location -#define FW_VERSION "3.0.0.a226" +#define FW_VERSION "3.0.0.a227" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/bluetooth/BT_service.cpp b/esp3d/src/modules/bluetooth/BT_service.cpp index 171844b4..a7b07961 100644 --- a/esp3d/src/modules/bluetooth/BT_service.cpp +++ b/esp3d/src/modules/bluetooth/BT_service.cpp @@ -25,6 +25,7 @@ #ifdef BLUETOOTH_FEATURE #include "../../core/esp3d_commands.h" #include "../../core/esp3d_settings.h" +#include "../../esp3d_string.h" #include "../network/netconfig.h" #include "BT_service.h" #include "BluetoothSerial.h" @@ -215,7 +216,7 @@ void BTService::push2buffer(uint8_t *sbuf, size_t len) { _buffer_size++; } flushbuffer(); - } else if (isPrintable(char(sbuf[i]))) { + } else if (esp3d_string::isPrintableChar(char(sbuf[i]))) { if (_buffer_size < ESP3D_BT_BUFFER_SIZE) { _buffer[_buffer_size] = sbuf[i]; _buffer_size++; diff --git a/esp3d/src/modules/serial/serial_service.cpp b/esp3d/src/modules/serial/serial_service.cpp index 9c234898..049ce698 100644 --- a/esp3d/src/modules/serial/serial_service.cpp +++ b/esp3d/src/modules/serial/serial_service.cpp @@ -23,6 +23,8 @@ COMMUNICATION_PROTOCOL == RAW_SERIAL || defined(ESP_SERIAL_BRIDGE_OUTPUT) #include "../../core/esp3d_commands.h" #include "../../core/esp3d_settings.h" +#include "../../core/esp3d_string.h" + #include "serial_service.h" #if COMMUNICATION_PROTOCOL == MKS_SERIAL @@ -406,7 +408,7 @@ void ESP3DSerialService::push2buffer(uint8_t *sbuf, size_t len) { _buffer_size++; } flushbuffer(); - } else if (isPrintable(char(sbuf[i]))) { + } else if (esp3d_string::isPrintableChar(char(sbuf[i]))) { if (_buffer_size < ESP3D_SERIAL_BUFFER_SIZE) { _buffer[_buffer_size] = sbuf[i]; _buffer_size++; diff --git a/esp3d/src/modules/telnet/telnet_server.cpp b/esp3d/src/modules/telnet/telnet_server.cpp index 60536ea4..73a8863f 100644 --- a/esp3d/src/modules/telnet/telnet_server.cpp +++ b/esp3d/src/modules/telnet/telnet_server.cpp @@ -28,6 +28,7 @@ #include "../../core/esp3d_commands.h" #include "../../core/esp3d_message.h" #include "../../core/esp3d_settings.h" +#include "../../core/esp3d_string.h" #include "../../include/esp3d_version.h" #include "telnet_server.h" @@ -245,7 +246,7 @@ void Telnet_Server::push2buffer(uint8_t *sbuf, size_t len) { _buffer_size++; } flushbuffer(); - } else if (isPrintable(char(sbuf[i]))) { + } else if (esp3d_string::isPrintableChar(char(sbuf[i]))) { if (_buffer_size < ESP3D_TELNET_BUFFER_SIZE) { _buffer[_buffer_size] = sbuf[i]; _buffer_size++; diff --git a/esp3d/src/modules/websocket/websocket_server.cpp b/esp3d/src/modules/websocket/websocket_server.cpp index 55dbc2e9..591bc0eb 100644 --- a/esp3d/src/modules/websocket/websocket_server.cpp +++ b/esp3d/src/modules/websocket/websocket_server.cpp @@ -28,6 +28,7 @@ #include "../../core/esp3d_commands.h" #include "../../core/esp3d_message.h" #include "../../core/esp3d_settings.h" +#include "../../core/esp3d_string.h" #include "../authentication/authentication_service.h" #include "websocket_server.h" @@ -288,7 +289,7 @@ void WebSocket_Server::push2RXbuffer(uint8_t *sbuf, size_t len) { _RXbufferSize++; } flushRXbuffer(); - } else if (isPrintable(char(sbuf[i]))) { + } else if (esp3d_string::isPrintableChar(char(sbuf[i]))) { if (_RXbufferSize < RXBUFFERSIZE) { _RXbuffer[_RXbufferSize] = sbuf[i]; _RXbufferSize++; diff --git a/platformio.ini b/platformio.ini index 0adc06e9..8f7ae0ff 100644 --- a/platformio.ini +++ b/platformio.ini @@ -271,3 +271,28 @@ upload_speed = 115200 extra_scripts = pre:platformIO/extra_script.py lib_ignore = ESP32SSPD + +[env:esp8285] +platform = espressif8266@4.1.0 +board = esp8285 +framework = arduino +monitor_speed = 115200 +monitor_echo = yes +monitor_filters = send_on_enter, colorize, esp8266_exception_decoder +; set frequency to 160MHz +board_build.f_cpu = 160000000L +; set frequency to 40MHz +board_build.f_flash = 40000000L +board_build.flash_mode = dout +upload_resetmethod = ck +board_build.ldscript = eagle.flash.1m256.ld +build_flags = + -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY + -DNONOSDK221=1 + -DNDEBUG + -DVTABLES_IN_FLASH + -DWAVEFORM_LOCKED_PWM +upload_speed = 115200 +extra_scripts = pre:platformIO/extra_script.py +lib_ignore = + ESP32SSPD