diff --git a/src/AccessControl.cpp b/src/AccessControl.cpp
index 567a36d..5b9dcb5 100644
--- a/src/AccessControl.cpp
+++ b/src/AccessControl.cpp
@@ -1722,67 +1722,82 @@ void AccessControl::handleFunctionPropertySetFingerPassword(uint8_t *data, uint8
newPasswordCrc = crc32.crc32((uint8_t *)newPassword, 16);
logDebugP("newPassword: %s (crc: %u)", newPassword, newPasswordCrc);
- // change password
- uint32_t oldPasswordCrc = 0;
- if (passwordOption == 2)
+ if (passwordOption == 3)
{
- char oldPassword[16] = {};
- for (uint8_t i = 0; i < 16; i++)
- {
- dataOffset++;
- memcpy(oldPassword + i, data + dataOffset, 1);
+ logDebugP("Saving new password directly to flash.");
+ _fingerprintStorage.writeInt(FLASH_FINGER_SCANNER_PASSWORD_OFFSET, newPasswordCrc);
+ _fingerprintStorage.commit();
- if (oldPassword[i] == 0) // null termination
- break;
- }
+ finger->close();
+ initFingerprintScanner();
+ finger->start();
- if (oldPassword[0] != 48 || // = "0": if user inputs only "0", we just use it as is without CRC
- oldPassword[1] != 0) // null termination
- oldPasswordCrc = crc32.crc32((uint8_t *)oldPassword, 16);
- logDebugP("oldPassword: %s (crc: %u)", oldPassword, oldPasswordCrc);
+ resultData[0] = 0;
}
+ else
+ {
+ // change password
+ uint32_t oldPasswordCrc = 0;
+ if (passwordOption == 2)
+ {
+ char oldPassword[16] = {};
+ for (uint8_t i = 0; i < 16; i++)
+ {
+ dataOffset++;
+ memcpy(oldPassword + i, data + dataOffset, 1);
- uint32_t currentCrc = _fingerprintStorage.readInt(FLASH_FINGER_SCANNER_PASSWORD_OFFSET);
- logDebugP("currentCrc: %u", currentCrc);
+ if (oldPassword[i] == 0) // null termination
+ break;
+ }
- bool success = false;
- if (currentCrc == oldPasswordCrc)
- {
- logDebugP("Current matches old CRC.");
- logIndentUp();
+ if (oldPassword[0] != 48 || // = "0": if user inputs only "0", we just use it as is without CRC
+ oldPassword[1] != 0) // null termination
+ oldPasswordCrc = crc32.crc32((uint8_t *)oldPassword, 16);
+ logDebugP("oldPassword: %s (crc: %u)", oldPassword, oldPasswordCrc);
+ }
- logInfoP("Setting new fingerprint scanner password.");
- logIndentUp();
+ uint32_t currentCrc = _fingerprintStorage.readInt(FLASH_FINGER_SCANNER_PASSWORD_OFFSET);
+ logDebugP("currentCrc: %u", currentCrc);
- if (switchFingerprintPower(true))
- success = finger->setPassword(newPasswordCrc);
-
- resetFingerLedTimer = delayTimerInit();
- logInfoP(success ? "Success." : "Failed.");
- logIndentDown();
-
- if (success)
+ bool success = false;
+ if (currentCrc == oldPasswordCrc)
{
- logDebugP("Saving new password in flash.");
- _fingerprintStorage.writeInt(FLASH_FINGER_SCANNER_PASSWORD_OFFSET, newPasswordCrc);
- _fingerprintStorage.commit();
+ logDebugP("Current matches old CRC.");
+ logIndentUp();
- finger->close();
- initFingerprintScanner();
- finger->start();
- }
+ logInfoP("Setting new fingerprint scanner password.");
+ logIndentUp();
- resetFingerLedTimer = delayTimerInit();
- logIndentDown();
+ if (switchFingerprintPower(true))
+ success = finger->setPassword(newPasswordCrc);
+
+ resetFingerLedTimer = delayTimerInit();
+ logInfoP(success ? "Success." : "Failed.");
+ logIndentDown();
+
+ if (success)
+ {
+ logDebugP("Saving new password in flash.");
+ _fingerprintStorage.writeInt(FLASH_FINGER_SCANNER_PASSWORD_OFFSET, newPasswordCrc);
+ _fingerprintStorage.commit();
- resultData[0] = success ? 0 : 2;
- }
- else
- {
- logDebugP("Invalid old password provided.");
- resultData[0] = 1;
+ finger->close();
+ initFingerprintScanner();
+ finger->start();
+ }
+
+ resetFingerLedTimer = delayTimerInit();
+ logIndentDown();
+
+ resultData[0] = success ? 0 : 2;
+ }
+ else
+ {
+ logDebugP("Invalid old password provided.");
+ resultData[0] = 1;
+ }
}
-
+
resultLength = 1;
logIndentDown();
}
diff --git a/src/AccessControl.script.js b/src/AccessControl.script.js
index 7e5cbca..43129d3 100644
--- a/src/AccessControl.script.js
+++ b/src/AccessControl.script.js
@@ -499,7 +499,7 @@ function ACC_setFingerPassword(device, online, progress, context) {
var parPasswordNew = device.getParameterByName("ACC_PasswordNew");
var parPasswordOld = device.getParameterByName("ACC_PasswordOld");
- progress.setText("Fingerprint: " + parPasswordOption.value == 1 ? "Passwort festsetzen..." : "Passwort ändern...");
+ progress.setText("Fingerprint: " + (parPasswordOption.value == 1 || parPasswordOption.value == 3) ? "Passwort festsetzen..." : "Passwort ändern...");
online.connect();
var data = [21]; // internal function ID
@@ -537,7 +537,7 @@ function ACC_setFingerPassword(device, online, progress, context) {
parPasswordAlreadySet.value = parPasswordNew.value == "0" ? 0 : 1;
online.disconnect();
- progress.setText("Fingerprint: " + parPasswordOption.value == 1 ? "Passwort festgesetzt." : "Passwort geändert.");
+ progress.setText("Fingerprint: " + (parPasswordOption.value == 1 || parPasswordOption.value == 3) ? "Passwort festgesetzt." : "Passwort geändert.");
}
function ACC_checkNfcAction(device, online, progress, context) {
diff --git a/src/AccessControl.share.xml b/src/AccessControl.share.xml
index 5037139..d5147c5 100644
--- a/src/AccessControl.share.xml
+++ b/src/AccessControl.share.xml
@@ -41,6 +41,7 @@
+
@@ -573,6 +574,10 @@
+
+
+
+