fix standalone/make, fix HA avty, fix deprecated arduinojson, update packages

This commit is contained in:
proddy
2025-12-11 23:52:44 +01:00
parent 8bd1cd03b4
commit 55b8c2d04c
18 changed files with 535 additions and 488 deletions

View File

@@ -237,12 +237,20 @@ const char * Command::parse_command_string(const char * command, int8_t & id) {
const char * cmd_org = command;
int8_t id_org = id;
// convert cmd to lowercase and compare
char * lowerCmd = strdup(command);
for (char * p = lowerCmd; *p; p++) {
*p = tolower(*p);
// Optimized: Use stack buffer instead of strdup() to avoid heap allocation
// Most command strings are short, 64 bytes is more than enough
char lowerCmd[64];
size_t len = strlen(command);
if (len >= sizeof(lowerCmd)) {
len = sizeof(lowerCmd) - 1; // truncate if too long (rare case)
}
// Convert to lowercase in place using stack buffer
for (size_t i = 0; i < len; i++) {
lowerCmd[i] = tolower(command[i]);
}
lowerCmd[len] = '\0';
// check prefix and valid number range, also check 'id'
if (!strncmp(lowerCmd, "hc", 2) && command[2] >= '1' && command[2] <= '8') {
id = command[2] - '0';
@@ -279,7 +287,7 @@ const char * Command::parse_command_string(const char * command, int8_t & id) {
command += 3;
}
free(lowerCmd);
// No free() needed - stack buffer is automatically cleaned up
// return original if no seperator
if (command[0] != '/' && command[0] != '.') {