From 8c53e93e9d4e34b68238a4e4233092781ac8a2f5 Mon Sep 17 00:00:00 2001 From: technyon Date: Fri, 12 Aug 2022 23:50:50 +0200 Subject: [PATCH] sort keypad codes --- NukiWrapper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NukiWrapper.cpp b/NukiWrapper.cpp index ce3151e..4ddcb3e 100644 --- a/NukiWrapper.cpp +++ b/NukiWrapper.cpp @@ -254,6 +254,8 @@ void NukiWrapper::updateKeypad() std::list entries; _nukiLock.getKeypadEntries(&entries); + entries.sort([](const NukiLock::KeypadEntry& a, const NukiLock::KeypadEntry& b) { return a.codeId < b.codeId; }); + uint keypadCount = entries.size(); if(keypadCount > _maxKeypadCodeCount) { @@ -367,7 +369,7 @@ void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, c bool idExists = std::find(_keypadCodeIds.begin(), _keypadCodeIds.end(), id) != _keypadCodeIds.end(); int codeInt = code.toInt(); - bool codeValid = codeInt > 100000 && (code.indexOf('0') == -1); + bool codeValid = codeInt > 100000 && codeInt < 1000000 && (code.indexOf('0') == -1); NukiLock::CmdResult result = (NukiLock::CmdResult)-1; if(strcmp(command, "add") == 0)