From 4aa9d115742af96085a155c1974d83c1af4216a7 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 2 Jan 2023 15:29:33 +0100 Subject: [PATCH] calculate command ids from tag names --- src/command.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index 34cf52fbf..4f78fe537 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -131,15 +131,15 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec id_n = input["hc"]; } else if (input.containsKey("wwc")) { id_n = input["wwc"]; - id_n += 8; // wwc1 has id 9 + id_n += DeviceValueTAG::TAG_WWC1 - DeviceValueTAG::TAG_HC1; // wwc1 has id 9 } else if (input.containsKey("id")) { id_n = input["id"]; } else if (input.containsKey("ahs")) { id_n = input["ahs"]; - id_n += 18; // ahs1 has id 19 + id_n += DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1; // ahs1 has id 19 } else if (input.containsKey("hs")) { id_n = input["hs"]; - id_n += 19; // hs1 has id 20 + id_n += DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1; // hs1 has id 20 } } @@ -210,10 +210,10 @@ const char * Command::parse_command_string(const char * command, int8_t & id) { id = command[2] - '0'; command += 3; } else if (!strncmp(lowerCmd, "wwc", 3) && command[3] == '1' && command[4] == '0') { - id = 18; + id = DeviceValueTAG::TAG_WWC10 - DeviceValueTAG::TAG_HC1 + 1; //18; command += 5; } else if (!strncmp(lowerCmd, "wwc", 3) && command[3] >= '1' && command[3] <= '9') { - id = command[3] - '1' + 9; + id = command[3] - '1' + DeviceValueTAG::TAG_WWC1 - DeviceValueTAG::TAG_HC1 + 1; //9; command += 4; } else if (!strncmp(lowerCmd, "id", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '9') { id = command[3] - '0' + 10; @@ -222,13 +222,13 @@ const char * Command::parse_command_string(const char * command, int8_t & id) { id = command[2] - '0'; command += 3; } else if (!strncmp(lowerCmd, "ahs", 3) && command[3] >= '1' && command[3] <= '1') { // only ahs1 for now - id = command[3] - '1' + 19; + id = command[3] - '1' + DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1 + 1; // 19; command += 4; } else if (!strncmp(lowerCmd, "hs", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '6') { - id = command[3] - '0' + 29; + id = command[3] - '0' + DeviceValueTAG::TAG_HS10 - DeviceValueTAG::TAG_HC1 + 1; //29; command += 4; } else if (!strncmp(lowerCmd, "hs", 2) && command[2] >= '1' && command[2] <= '9') { - id = command[2] - '1' + 20; + id = command[2] - '1' + DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1 + 1; //20; command += 3; } // remove separator