Fixes bool to int

This commit is contained in:
iranl
2024-03-15 19:50:44 +01:00
parent 40808229a3
commit 620fde05ca
4 changed files with 52 additions and 44 deletions

View File

@@ -502,9 +502,9 @@ LockActionResult NukiOpenerWrapper::onLockActionReceivedCallback(const char *val
nukiOpenerPreferences = new Preferences();
nukiOpenerPreferences->begin("nukihub", true);
uint32_t aclPrefs[17];
nukiLockPreferences->getBytes(preference_acl, &aclPrefs, sizeof(aclPrefs));
nukiOpenerPreferences->getBytes(preference_acl, &aclPrefs, sizeof(aclPrefs));
if((action == NukiOpener::LockAction::ActivateRTO && aclPrefs[9] == 1) || (action == NukiOpener::LockAction::DeactivateRTO && aclPrefs[10] == 1) || (action == NukiOpener::LockAction::ElectricStrikeActuation && aclPrefs[11] == 1) || (action == NukiOpener::LockAction::ActivateCM && aclPrefs[12] == 1) || (action == NukiOpener::LockAction::DeactivateCM && aclPrefs[13] == 1) || (action == NukiOpener::LockAction::FobAction1 && aclPrefs[14] == 1) || (action == NukiOpener::LockAction::FobAction2 && aclPrefs[15] == 1) || (action == NukiOpener::LockAction::FobAction3 && aclPrefs[16] == 1))
if((action == NukiOpener::LockAction::ActivateRTO && (int)aclPrefs[9] == 1) || (action == NukiOpener::LockAction::DeactivateRTO && (int)aclPrefs[10] == 1) || (action == NukiOpener::LockAction::ElectricStrikeActuation && (int)aclPrefs[11] == 1) || (action == NukiOpener::LockAction::ActivateCM && (int)aclPrefs[12] == 1) || (action == NukiOpener::LockAction::DeactivateCM && (int)aclPrefs[13] == 1) || (action == NukiOpener::LockAction::FobAction1 && (int)aclPrefs[14] == 1) || (action == NukiOpener::LockAction::FobAction2 && (int)aclPrefs[15] == 1) || (action == NukiOpener::LockAction::FobAction3 && (int)aclPrefs[16] == 1))
{
nukiOpenerPreferences->end();
nukiOpenerInst->_nextLockAction = action;

View File

@@ -471,7 +471,7 @@ LockActionResult NukiWrapper::onLockActionReceivedCallback(const char *value)
uint32_t aclPrefs[17];
nukiLockPreferences->getBytes(preference_acl, &aclPrefs, sizeof(aclPrefs));
if((action == NukiLock::LockAction::Lock && aclPrefs[0] == 1) || (action == NukiLock::LockAction::Unlock && aclPrefs[1] == 1) || (action == NukiLock::LockAction::Unlatch && aclPrefs[2] == 1) || (action == NukiLock::LockAction::LockNgo && aclPrefs[3] == 1) || (action == NukiLock::LockAction::LockNgoUnlatch && aclPrefs[4] == 1) || (action == NukiLock::LockAction::FullLock && aclPrefs[5] == 1) || (action == NukiLock::LockAction::FobAction1 && aclPrefs[6] == 1) || (action == NukiLock::LockAction::FobAction2 && aclPrefs[7] == 1) || (action == NukiLock::LockAction::FobAction3 && aclPrefs[8] == 1))
if((action == NukiLock::LockAction::Lock && (int)aclPrefs[0] == 1) || (action == NukiLock::LockAction::Unlock && (int)aclPrefs[1] == 1) || (action == NukiLock::LockAction::Unlatch && (int)aclPrefs[2] == 1) || (action == NukiLock::LockAction::LockNgo && (int)aclPrefs[3] == 1) || (action == NukiLock::LockAction::LockNgoUnlatch && (int)aclPrefs[4] == 1) || (action == NukiLock::LockAction::FullLock && (int)aclPrefs[5] == 1) || (action == NukiLock::LockAction::FobAction1 && (int)aclPrefs[6] == 1) || (action == NukiLock::LockAction::FobAction2 && (int)aclPrefs[7] == 1) || (action == NukiLock::LockAction::FobAction3 && (int)aclPrefs[8] == 1))
{
nukiLockPreferences->end();
nukiInst->_nextLockAction = action;

View File

@@ -461,7 +461,7 @@ bool WebCfgServer::processArgs(String& message)
_preferences->putInt(preference_restart_ble_beacon_lost, value.toInt());
configChanged = true;
}
else if(key == "aclLvlChanged")
else if(key == "ACLLVLCHANGED")
{
aclLvlChanged = true;
}
@@ -638,7 +638,7 @@ bool WebCfgServer::processArgs(String& message)
if(aclLvlChanged)
{
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
_preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
configChanged = true;
}
@@ -935,7 +935,7 @@ void WebCfgServer::buildAccLvlHtml(String &response)
_preferences->getBytes(preference_acl, &aclPrefs, sizeof(aclPrefs));
response.concat("<form method=\"post\" action=\"savecfg\">");
response.concat("<input type=\"hidden\" name=\"aclLvlChanged\" value=\"1\">");
response.concat("<input type=\"hidden\" name=\"ACLLVLCHANGED\" value=\"1\">");
response.concat("<h3>Nuki General Access Control</h3>");
response.concat("<table><tr><th>Setting</th><th>Enabled</th></tr>");
printCheckBox(response, "ACLCNF", "Change Nuki configuration", _preferences->getBool(preference_admin_enabled));
@@ -951,15 +951,15 @@ void WebCfgServer::buildAccLvlHtml(String &response)
response.concat("<h3>Nuki Lock Access Control</h3>");
response.concat("<table><tr><th>Action</th><th>Allowed</th></tr>");
printCheckBox(response, "ACLLCKLCK", "Lock", (aclPrefs[0] == "1"));
printCheckBox(response, "ACLLCKUNLCK", "Unlock", (aclPrefs[1] == "1"));
printCheckBox(response, "ACLLCKUNLTCH", "Unlatch", (aclPrefs[2] == "1"));
printCheckBox(response, "ACLLCKLNG", "Lock N Go", (aclPrefs[3] == "1"));
printCheckBox(response, "ACLLCKLNGU", "Lock N Go Unlatch", (aclPrefs[4] == "1"));
printCheckBox(response, "ACLLCKFLLCK", "Full Lock", (aclPrefs[5] == "1"));
printCheckBox(response, "ACLLCKFOB1", "Fob Action 1", (aclPrefs[6] == "1"));
printCheckBox(response, "ACLLCKFOB2", "Fob Action 2", (aclPrefs[7] == "1"));
printCheckBox(response, "ACLLCKFOB3", "Fob Action 3", (aclPrefs[8] == "1"));
printCheckBox(response, "ACLLCKLCK", "Lock", ((int)aclPrefs[0] == 1));
printCheckBox(response, "ACLLCKUNLCK", "Unlock", ((int)aclPrefs[1] == 1));
printCheckBox(response, "ACLLCKUNLTCH", "Unlatch", ((int)aclPrefs[2] == 1));
printCheckBox(response, "ACLLCKLNG", "Lock N Go", ((int)aclPrefs[3] == 1));
printCheckBox(response, "ACLLCKLNGU", "Lock N Go Unlatch", ((int)aclPrefs[4] == 1));
printCheckBox(response, "ACLLCKFLLCK", "Full Lock", ((int)aclPrefs[5] == 1));
printCheckBox(response, "ACLLCKFOB1", "Fob Action 1", ((int)aclPrefs[6] == 1));
printCheckBox(response, "ACLLCKFOB2", "Fob Action 2", ((int)aclPrefs[7] == 1));
printCheckBox(response, "ACLLCKFOB3", "Fob Action 3", ((int)aclPrefs[8] == 1));
response.concat("</table><br>");
}
if(_nukiOpener != nullptr)
@@ -967,14 +967,14 @@ void WebCfgServer::buildAccLvlHtml(String &response)
response.concat("<h3>Nuki Opener Access Control</h3>");
response.concat("<table><tr><th>Action</th><th>Allowed</th></tr>");
printCheckBox(response, "ACLOPNUNLCK", "Activate Ring-to-Open", (aclPrefs[9] == "1"));
printCheckBox(response, "ACLOPNLCK", "Deactivate Ring-to-Open", (aclPrefs[10] == "1"));
printCheckBox(response, "ACLOPNUNLTCH", "Electric Strike Actuation", (aclPrefs[11] == "1"));
printCheckBox(response, "ACLOPNUNLCKCM", "Activate Continuous Mode", (aclPrefs[12] == "1"));
printCheckBox(response, "ACLOPNLCKCM", "Deactivate Continuous Mode", (aclPrefs[13] == "1"));
printCheckBox(response, "ACLOPNFOB1", "Fob Action 1", (aclPrefs[14] == "1"));
printCheckBox(response, "ACLOPNFOB2", "Fob Action 2", (aclPrefs[15] == "1"));
printCheckBox(response, "ACLOPNFOB3", "Fob Action 3", (aclPrefs[16] == "1"));
printCheckBox(response, "ACLOPNUNLCK", "Activate Ring-to-Open", ((int)aclPrefs[9] == 1));
printCheckBox(response, "ACLOPNLCK", "Deactivate Ring-to-Open", ((int)aclPrefs[10] == 1));
printCheckBox(response, "ACLOPNUNLTCH", "Electric Strike Actuation", ((int)aclPrefs[11] == 1));
printCheckBox(response, "ACLOPNUNLCKCM", "Activate Continuous Mode", ((int)aclPrefs[12] == 1));
printCheckBox(response, "ACLOPNLCKCM", "Deactivate Continuous Mode", ((int)aclPrefs[13] == 1));
printCheckBox(response, "ACLOPNFOB1", "Fob Action 1", ((int)aclPrefs[14] == 1));
printCheckBox(response, "ACLOPNFOB2", "Fob Action 2", ((int)aclPrefs[15] == 1));
printCheckBox(response, "ACLOPNFOB3", "Fob Action 3", ((int)aclPrefs[16] == 1));
response.concat("</table><br>");
}
response.concat("<br><input type=\"submit\" name=\"submit\" value=\"Save\">");

View File

@@ -164,37 +164,45 @@ bool initPreferences()
preferences->putBool(preference_keypad_info_enabled, false);
}
uint32_t aclPrefs[17];
switch(preferences->getInt(preference_access_level))
{
case 0:
preferences->putBool(preference_keypad_control_enabled, true);
preferences->putBool(preference_admin_enabled, true);
{
preferences->putBool(preference_keypad_control_enabled, true);
preferences->putBool(preference_admin_enabled, true);
aclPrefs = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
break;
uint32_t aclPrefs[17] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
break;
}
case 1:
preferences->putBool(preference_keypad_control_enabled, false);
preferences->putBool(preference_admin_enabled, false);
{
preferences->putBool(preference_keypad_control_enabled, false);
preferences->putBool(preference_admin_enabled, false);
aclPrefs = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0};
break;
uint32_t aclPrefs[17] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
break;
}
case 2:
preferences->putBool(preference_keypad_control_enabled, false);
preferences->putBool(preference_admin_enabled, false);
{
preferences->putBool(preference_keypad_control_enabled, false);
preferences->putBool(preference_admin_enabled, false);
aclPrefs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
break;
uint32_t aclPrefs[17] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
break;
}
case 3:
preferences->putBool(preference_keypad_control_enabled, false);
preferences->putBool(preference_admin_enabled, false);
{
preferences->putBool(preference_keypad_control_enabled, false);
preferences->putBool(preference_admin_enabled, false);
aclPrefs = {1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0};
break;
}
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t aclPrefs[17] = {1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
break;
}
}
}
preferences->putInt(preference_config_version, atof(NUKI_HUB_VERSION) * 100);