Skip to content

Commit

Permalink
Add a realtime command detector - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Dec 7, 2024
1 parent 7b99d8a commit 1266f79
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 0 additions & 4 deletions esp3d/src/core/esp3d_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,10 +1205,6 @@ void ESP3DCommands::process(ESP3DMessage *msg) {
esp3d_log("Execute internal command %d", cmdId);
execute_internal_command(cmdId, espcmdpos, msg);
} else {
/*esp3d_log("Dispatch command, len %d, from %d(%s) to %d(%s)", msg->size,
static_cast<uint8_t>(msg->origin), GETCLIENTSTR(msg->origin),
static_cast<uint8_t>(msg->target), GETCLIENTSTR(msg->target));*/

// Work around to avoid to dispatch single \n or \r to everyone as it is
// part of previous ESP3D command
if (msg->size == 1 &&
Expand Down
15 changes: 15 additions & 0 deletions esp3d/src/core/esp3d_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,19 @@ const char* esp3d_string::formatDuration(uint64_t duration) {
result += String(seconds) + "s";

return result.c_str();
}

bool esp3d_string::isRealtimeCommand(char c) {
// Standard characters
if (c == '?' || c == '!' || c == '~' || c == 0x18) { // 0x18 is ^X
return true;
}

// Range >= 0x80 et <= 0xA4
const unsigned char uc = static_cast<unsigned char>(c);
if (uc >= 0x80 && uc <= 0xA4) {
return true;
}

return false;
}
1 change: 1 addition & 0 deletions esp3d/src/core/esp3d_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const char* formatBytes(uint64_t bytes);
bool isPrintableChar(char c);
const char* expandString(const char* s, bool formatspace = false);
const char * urlEncode(const char* s);
bool isRealtimeCommand(char c);
} // namespace esp3d_string

#endif //_ESP3D_STRING_H

0 comments on commit 1266f79

Please sign in to comment.