Skip to content

Commit

Permalink
Updated error code for password checking
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-wong-ce committed Mar 7, 2022
1 parent 4835897 commit b7b3cf7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions BACnetServerExample/BACnetServerExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b7b3cf7

Please sign in to comment.