----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 204 | // Handle a message from the Z-Wave network |
| 205 | //----------------------------------------------------------------------------- |
| 206 | bool DoorLock::HandleMsg |
| 207 | ( |
| 208 | uint8 const* _data, |
| 209 | uint32 const _length, |
| 210 | uint32 const _instance // = 1 |
| 211 | ) |
| 212 | { |
| 213 | |
| 214 | if( DoorLockCmd_Report == (DoorLockCmd)_data[0] ) |
| 215 | { |
| 216 | uint8 lockState = (_data[1] == 0xFF) ? 6 : _data[1]; |
| 217 | if (lockState > 6) /* size of c_LockStateNames minus Invalid Entry */ |
| 218 | { |
| 219 | Log::Write (LogLevel_Warning, GetNodeId(), "LockState Value was greater than range. Setting to Invalid"); |
| 220 | lockState = 7; |
| 221 | } |
| 222 | |
| 223 | Log::Write( LogLevel_Info, GetNodeId(), "Received DoorLock report: DoorLock is %s", c_LockStateNames[lockState] ); |
| 224 | |
| 225 | if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, Value_Lock ) ) ) |
| 226 | { |
| 227 | value->OnValueRefreshed( lockState == 0x06 ); |
| 228 | value->Release(); |
| 229 | } |
| 230 | if( ValueList* value = static_cast<ValueList*>( GetValue( _instance, Value_Lock_Mode ) ) ) |
| 231 | { |
| 232 | value->OnValueRefreshed( lockState); |
| 233 | value->Release(); |
| 234 | } |
| 235 | return true; |
| 236 | } else if (DoorLockCmd_Configuration_Report == (DoorLockCmd)_data[0] ) |
| 237 | { |
| 238 | switch (_data[1]) { |
| 239 | case DoorLockConfig_NoTimeout: |
| 240 | m_dom.SetFlagByte(STATE_FLAG_DOORLOCK_TIMEOUT, DoorLockConfig_NoTimeout); |
| 241 | RemoveValue(_instance, Value_System_Config_Minutes); |
| 242 | RemoveValue(_instance, Value_System_Config_Seconds); |
| 243 | m_dom.SetFlagByte(STATE_FLAG_DOORLOCK_TIMEOUTMINS, 0xFE); |
| 244 | m_dom.SetFlagByte(STATE_FLAG_DOORLOCK_TIMEOUTSECS, 0xFE); |
| 245 | break; |
| 246 | case DoorLockConfig_Timeout: |
| 247 | /* if we have a timeout, then create the Values for the timeout config */ |
| 248 | if( Node* node = GetNodeUnsafe() ) |
| 249 | { |
| 250 | node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_Minutes, "Timeout Minutes", "Mins", false, false, _data[3], 0 ); |
| 251 | node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_Seconds, "Timeout Seconds", "Secs", false, false, _data[4], 0 ); |
| 252 | } |
| 253 | m_dom.SetFlagByte(STATE_FLAG_DOORLOCK_TIMEOUT, DoorLockConfig_Timeout); |
| 254 | m_dom.SetFlagByte(STATE_FLAG_DOORLOCK_TIMEOUTMINS, _data[3]); |
| 255 | m_dom.SetFlagByte(STATE_FLAG_DOORLOCK_TIMEOUTSECS, _data[4]); |
| 256 | break; |
| 257 | default: |
| 258 | Log::Write(LogLevel_Warning, GetNodeId(), "Received a Unsupported Door Lock Config Report %d", _data[1]); |
| 259 | } |
| 260 | |
| 261 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, Value_System_Config_OutsideHandles ) ) ) |
| 262 | { |
| 263 | value->OnValueRefreshed( ((_data[2] & 0xF0)>>4) ); |
nothing calls this directly
no test coverage detected