From b7b3cf797c1b50d71aa0d3d1d3d339b8d4c9fb09 Mon Sep 17 00:00:00 2001 From: Justin Wong <51811017+justin-wong-ce@users.noreply.github.com> Date: Mon, 7 Mar 2022 14:37:48 -0800 Subject: [PATCH] Updated error code for password checking --- BACnetServerExample/BACnetServerExample.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BACnetServerExample/BACnetServerExample.cpp b/BACnetServerExample/BACnetServerExample.cpp index 2e91bf4..485b901 100644 --- a/BACnetServerExample/BACnetServerExample.cpp +++ b/BACnetServerExample/BACnetServerExample.cpp @@ -2130,13 +2130,16 @@ bool CallbackReinitializeDevice(const uint32_t deviceInstance, const uint32_t re // Before handling the reinitializedState, first check the password. // If your device does not require a password, then ignore any password passed in. // Otherwise, validate the password. - // If password invalid: set errorCode to PasswordInvalid (26) - // If password is required, but no password was provided: set errorCode to MissingRequiredParameter (16) + // If password invalid, or a password is required, but no password was provided: set errorCode to PasswordInvalid (26) // In this example, a password of 12345 is required. + + // Check if missing if (password == NULL || passwordLength == 0) { - *errorCode = CASBACnetStackExampleConstants::ERROR_MISSING_REQUIRED_PARAMETER; + *errorCode = CASBACnetStackExampleConstants::ERROR_PASSWORD_FAILURE; return false; } + + // Check if correct if (strcmp(password, "12345") != 0) { *errorCode = CASBACnetStackExampleConstants::ERROR_PASSWORD_FAILURE; return false;