----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 213 | // Handle a message from the Z-Wave network |
| 214 | //----------------------------------------------------------------------------- |
| 215 | bool Alarm::HandleMsg |
| 216 | ( |
| 217 | uint8 const* _data, |
| 218 | uint32 const _length, |
| 219 | uint32 const _instance // = 1 |
| 220 | ) |
| 221 | { |
| 222 | if (AlarmCmd_Report == (AlarmCmd)_data[0]) |
| 223 | { |
| 224 | // We have received a report from the Z-Wave device |
| 225 | if( GetVersion() == 1) |
| 226 | { |
| 227 | Log::Write( LogLevel_Info, GetNodeId(), "Received Alarm report: type=%d, level=%d", _data[1], _data[2] ); |
| 228 | |
| 229 | if( ValueByte *value = static_cast<ValueByte*>( GetValue( _instance, AlarmIndex_Type ) ) ) |
| 230 | { |
| 231 | value->OnValueRefreshed( _data[1] ); |
| 232 | value->Release(); |
| 233 | } |
| 234 | // For device on version 1 the level could have different value. This level value correspond to a list of alarm type. |
| 235 | if ( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, AlarmIndex_Level ) ) ) |
| 236 | { |
| 237 | value->OnValueRefreshed( _data[2] ); |
| 238 | value->Release(); |
| 239 | } |
| 240 | } |
| 241 | /* version 2 */ |
| 242 | else if(( GetVersion() > 1 ) && ( _length >= 7 )) |
| 243 | { |
| 244 | // With Version=2, the data has more detailed information about the alarm |
| 245 | if (m_v1Params) { |
| 246 | |
| 247 | Log::Write( LogLevel_Info, GetNodeId(), "Received Notification report (v1): type:%d event:%d", |
| 248 | _data[1], _data[2] ); |
| 249 | |
| 250 | if( ValueByte *value = static_cast<ValueByte*>( GetValue( _instance, AlarmIndex_Type ) ) ) |
| 251 | { |
| 252 | value->OnValueRefreshed( _data[1] ); |
| 253 | value->Release(); |
| 254 | } |
| 255 | // For device on version 1 the level could have different value. This level value correspond to a list of alarm type. |
| 256 | if ( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, AlarmIndex_Level ) ) ) |
| 257 | { |
| 258 | value->OnValueRefreshed( _data[2] ); |
| 259 | value->Release(); |
| 260 | } |
| 261 | } |
| 262 | /* ok. Its a AlarmCC/NotificationCC Version 2 or above. */ |
| 263 | bool NotificationStatus = false; |
| 264 | if (_data[4] == 0xFF) |
| 265 | NotificationStatus = true; |
| 266 | |
| 267 | uint8 NotificationType = _data[5]; |
| 268 | uint8 NotificationEvent = _data[6]; |
| 269 | bool NotificationSequencePresent = ((_data[7] & 0x80) == 1); |
| 270 | uint8 EventParamLength = (_data[7] & 0x1F); |
| 271 | uint8 NotificationSequence = 0; |
| 272 | if (NotificationSequencePresent) { |
nothing calls this directly
no test coverage detected