MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / HandleIncommingMsg

Method HandleIncommingMsg

cpp/src/command_classes/SceneActivation.cpp:69–120  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

67// Handle a message from the Z-Wave network
68//-----------------------------------------------------------------------------
69bool SceneActivation::HandleIncommingMsg
70(
71 uint8 const* _data,
72 uint32 const _length,
73 uint32 const _instance // = 1
74)
75{
76 if( SceneActivationCmd_Set == (SceneActivationCmd)_data[0] )
77 {
78 // Scene Activation Set received so send notification
79 char msg[64];
80 uint32 duration;
81 if( _data[2] == 0 ) {
82 snprintf( msg, sizeof(msg), "now" );
83 duration = 0;
84 } else if( _data[2] <= 0x7F ) {
85 snprintf( msg, sizeof(msg), "%d seconds", _data[2] );
86 duration = _data[2];
87 } else if( _data[2] <= 0xFE ) {
88 snprintf( msg, sizeof(msg), "%d minutes", _data[2] );
89 duration = _data[2] * 60;
90 } else {
91 snprintf( msg, sizeof(msg), "via configuration" );
92 duration = 0;
93 }
94 Log::Write( LogLevel_Info, GetNodeId(), "Received SceneActivation set from node %d: scene id=%d %s. Sending event notification.", GetNodeId(), _data[1], msg );
95 /* Sending the Scene ID via a notification should be depreciated in 1.8 */
96 Notification* notification = new Notification( Notification::Type_SceneEvent );
97 notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() );
98 notification->SetSceneId( _data[1] );
99 GetDriver()->QueueNotification( notification );
100
101 Log::Write( LogLevel_Info, GetNodeId(), "Received SceneActivation report: %d (duration: %d)", _data[1]);
102 if( ValueInt* value = static_cast<ValueInt*>( GetValue( _instance, SceneActivationIndex_SceneID ) ) )
103 {
104 value->OnValueRefreshed( _data[1] );
105 value->Release();
106 }
107 if( ValueInt* value = static_cast<ValueInt*>( GetValue( _instance, SceneActivationIndex_Duration ) ) )
108 {
109 value->OnValueRefreshed( duration );
110 value->Release();
111 }
112
113 Log::Write( LogLevel_Info, GetNodeId(), "Automatically Clearing Alarm in %d ms", duration );
114 TimerThread::TimerCallback callback = bind(&SceneActivation::ClearScene, this, _instance);
115 TimerSetEvent(duration, callback, _instance);
116 return true;
117 }
118
119 return false;
120}
121
122//-----------------------------------------------------------------------------
123// <SceneActivation::HandleIncommingMsg>

Callers

nothing calls this directly

Calls 6

WriteFunction · 0.85
QueueNotificationMethod · 0.80
GetNodeIdFunction · 0.70
GetHomeIdFunction · 0.70
OnValueRefreshedMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected