diff --git a/NukiWrapper.cpp b/NukiWrapper.cpp index 2539373..ce3151e 100644 --- a/NukiWrapper.cpp +++ b/NukiWrapper.cpp @@ -367,6 +367,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); NukiLock::CmdResult result = (NukiLock::CmdResult)-1; if(strcmp(command, "add") == 0) @@ -381,6 +382,11 @@ void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, c _network->publishKeypadCommandResult("MissingParameterCode"); return; } + if(!codeValid) + { + _network->publishKeypadCommandResult("CodeInvalid"); + return; + } NukiLock::NewKeypadEntry entry; memset(&entry, 0, sizeof(entry)); @@ -414,6 +420,11 @@ void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, c _network->publishKeypadCommandResult("MissingParameterCode"); return; } + if(!codeValid) + { + _network->publishKeypadCommandResult("CodeInvalid"); + return; + } if(!idExists) { _network->publishKeypadCommandResult("UnknownId");