Make the code optional when updating keypad using JSON
This commit is contained in:
@@ -525,9 +525,12 @@ void NukiOpenerWrapper::updateKeypad()
|
||||
|
||||
_keypadCodeIds.clear();
|
||||
_keypadCodeIds.reserve(entries.size());
|
||||
_keypadCodes.clear();
|
||||
_keypadCodes.reserve(entries.size());
|
||||
for(const auto& entry : entries)
|
||||
{
|
||||
_keypadCodeIds.push_back(entry.codeId);
|
||||
_keypadCodes.push_back(entry.code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1504,7 +1507,7 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (strcmp(action, "update") != 0)
|
||||
{
|
||||
_network->publishKeypadJsonCommandResult("noCodeSet");
|
||||
return;
|
||||
@@ -1685,7 +1688,14 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
|
||||
entry.codeId = codeId;
|
||||
size_t nameLen = strlen(name);
|
||||
memcpy(&entry.name, name, nameLen > 20 ? 20 : nameLen);
|
||||
entry.code = code;
|
||||
|
||||
if(code) entry.code = code;
|
||||
else
|
||||
{
|
||||
auto it = std::find(_keypadCodeIds.begin(), _keypadCodeIds.end(), codeId);
|
||||
entry.code = _keypadCodes[(it - _keypadCodeIds.begin())];
|
||||
}
|
||||
|
||||
entry.enabled = enabled == 0 ? 0 : 1;
|
||||
entry.timeLimited = timeLimited == 1 ? 1 : 0;
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ private:
|
||||
int _retryLockstateCount = 0;
|
||||
unsigned long _nextRetryTs = 0;
|
||||
std::vector<uint16_t> _keypadCodeIds;
|
||||
std::vector<uint32_t> _keypadCodes;
|
||||
std::vector<uint8_t> _timeControlIds;
|
||||
|
||||
NukiOpener::OpenerState _lastKeyTurnerState;
|
||||
|
||||
@@ -506,9 +506,12 @@ void NukiWrapper::updateKeypad()
|
||||
|
||||
_keypadCodeIds.clear();
|
||||
_keypadCodeIds.reserve(entries.size());
|
||||
_keypadCodes.clear();
|
||||
_keypadCodes.reserve(entries.size());
|
||||
for(const auto& entry : entries)
|
||||
{
|
||||
_keypadCodeIds.push_back(entry.codeId);
|
||||
_keypadCodes.push_back(entry.code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1490,7 +1493,7 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (strcmp(action, "update") != 0)
|
||||
{
|
||||
_network->publishKeypadJsonCommandResult("noCodeSet");
|
||||
return;
|
||||
@@ -1671,7 +1674,14 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
|
||||
entry.codeId = codeId;
|
||||
size_t nameLen = strlen(name);
|
||||
memcpy(&entry.name, name, nameLen > 20 ? 20 : nameLen);
|
||||
entry.code = code;
|
||||
|
||||
if(code) entry.code = code;
|
||||
else
|
||||
{
|
||||
auto it = std::find(_keypadCodeIds.begin(), _keypadCodeIds.end(), codeId);
|
||||
entry.code = _keypadCodes[(it - _keypadCodeIds.begin())];
|
||||
}
|
||||
|
||||
entry.enabled = enabled == 0 ? 0 : 1;
|
||||
entry.timeLimited = timeLimited == 1 ? 1 : 0;
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ private:
|
||||
bool _publishAuthData = false;
|
||||
bool _clearAuthData = false;
|
||||
std::vector<uint16_t> _keypadCodeIds;
|
||||
std::vector<uint32_t> _keypadCodes;
|
||||
std::vector<uint8_t> _timeControlIds;
|
||||
|
||||
NukiLock::KeyTurnerState _lastKeyTurnerState;
|
||||
|
||||
Reference in New Issue
Block a user