gpsCli: use parseTextParts

This commit is contained in:
Florent 2025-10-11 15:29:17 +02:00
parent 9e3c2fc9d9
commit 76dcfbb23a

View file

@ -518,15 +518,16 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
const char* key = command + 11; const char* key = command + 11;
const char* val = sensors.getSettingByKey(key); const char* val = sensors.getSettingByKey(key);
if (val != NULL) { if (val != NULL) {
strcpy(reply, val); sprintf(reply, "> %s", val);
} else { } else {
strcpy(reply, "can't find custom var"); strcpy(reply, "null");
} }
} else if (memcmp(command, "sensor set ", 11) == 0) { } else if (memcmp(command, "sensor set ", 11) == 0) {
const char* args = &command[11]; strcpy(tmp, &command[11]);
const char* value = strchr(args,' ') + 1; const char *parts[2];
char key [value-args+1]; int num = mesh::Utils::parseTextParts(tmp, parts, 2, ' ');
strncpy(key, args, value-args-1); const char *key = (num > 0) ? parts[0] : "";
const char *value = (num > 1) ? parts[1] : "null";
if (sensors.setSettingByKey(key, value)) { if (sensors.setSettingByKey(key, value)) {
strcpy(reply, "ok"); strcpy(reply, "ok");
} else { } else {