----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 220 | // Handle a message from the Z-Wave network |
| 221 | //----------------------------------------------------------------------------- |
| 222 | bool DoorLockLogging::HandleMsg |
| 223 | ( |
| 224 | uint8 const* _data, |
| 225 | uint32 const _length, |
| 226 | uint32 const _instance // = 1 |
| 227 | ) |
| 228 | { |
| 229 | |
| 230 | if( DoorLockLoggingCmd_RecordSupported_Report == (DoorLockLoggingCmd)_data[0] ) |
| 231 | { |
| 232 | Log::Write( LogLevel_Info, GetNodeId(), "Received DoorLockLoggingCmd_RecordSupported_Report: Max Records is %d ", _data[1]); |
| 233 | m_dom.SetFlagByte(STATE_FLAG_DOORLOCKLOG_MAXRECORDS, _data[1]); |
| 234 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, Value_System_Config_MaxRecords ) ) ) |
| 235 | { |
| 236 | |
| 237 | value->OnValueRefreshed( _data[1] ); |
| 238 | value->Release(); |
| 239 | } |
| 240 | ClearStaticRequest( StaticRequest_Values ); |
| 241 | return true; |
| 242 | } else if (DoorLockLoggingCmd_Record_Report == (DoorLockLoggingCmd)_data[0] ) |
| 243 | { |
| 244 | uint8 EventType = _data[9]; |
| 245 | if (EventType >= DoorLockEventType_Max) |
| 246 | EventType = DoorLockEventType_Max; |
| 247 | |
| 248 | Log::Write (LogLevel_Info, GetNodeId(), "Received a DoorLockLogging Record %d which is \"%s\"", _data[1], c_DoorLockEventType[EventType-1]); |
| 249 | |
| 250 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, Value_GetRecordNo ) ) ) |
| 251 | { |
| 252 | value->OnValueRefreshed( _data[1]); |
| 253 | value->Release(); |
| 254 | } |
| 255 | if( ValueString* value = static_cast<ValueString*>( GetValue( _instance, Value_LogRecord ) ) ) |
| 256 | { |
| 257 | char msg[512]; |
| 258 | uint16 year = (_data[2] << 8) + (_data[3] & 0xFF); |
| 259 | uint8 month = (_data[4] & 0x0F); |
| 260 | uint8 day = (_data[5] & 0x1F); |
| 261 | uint8 hour = (_data[6] & 0x1F); |
| 262 | uint8 minute = (_data[7] & 0x3F); |
| 263 | uint8 second = (_data[8] & 0x3F); |
| 264 | bool valid = false; |
| 265 | if (((_data[6] & 0xE0) >> 5) > 0) |
| 266 | { |
| 267 | valid = true; |
| 268 | } |
| 269 | uint8 userid = (_data[10]); |
| 270 | uint8 usercodelength = (_data[11]); |
| 271 | char usercode[254], tmpusercode[254]; |
| 272 | snprintf(usercode, sizeof(usercode), "UserCode:"); |
| 273 | if (usercodelength > 0) |
| 274 | for (int i = 0; i < usercodelength; i++ ) |
| 275 | { |
| 276 | snprintf(tmpusercode, sizeof(tmpusercode), "%d", (int)_data[12+i]); |
| 277 | strncat(usercode, tmpusercode, sizeof(usercode) - strlen(usercode) - 1 ); |
| 278 | } |
| 279 |
nothing calls this directly
no test coverage detected