Skip to content

Door Lock: handling of ValueID_Index_DoorLock::Lock_Mode probably incorrect #1886

Description

@petergebruers

I say "probably" because I do not own a lock but when looking at the code, the data received from and sent to the node should be encoded as correctly suggested by the enum in DoorLock.cpp:

enum DoorLockState
{
    DoorLockState_Unsecured = 0x00,
    DoorLockState_Unsecured_Timeout = 0x01,
    DoorLockState_Inside_Unsecured = 0x10,
(...)

However, for the list to work an index between 0..6 should be used, and the code does not do that, in fact it does:

uint8 lockState = (_data[1] == 0xFF) ? 6 : _data[1];
if (lockState > 6) /* size of c_LockStateNames minus Invalid Entry */
{
    Log::Write(LogLevel_Warning, GetNodeId(), "LockState Value was greater than range. Setting to Invalid");
    lockState = 7;
}

Log::Write(LogLevel_Info, GetNodeId(), "Received DoorLock report: DoorLock is %s", c_LockStateNames[lockState]);

This indeed means DoorLockState_Inside_Unsecured would get translated to 7 and trigger a "LockState Value was greater than range"

I wonder why this wasn't reported before. I don't have a real lock, I can only simulate one with my Z-Uno, so the problem might be academic (like: "nobody uses this list" or "there are no locks reporting this state").

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions