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

Method HandleMsg

cpp/src/command_classes/Basic.cpp:139–193  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

137// Handle a message from the Z-Wave network
138//-----------------------------------------------------------------------------
139bool Basic::HandleMsg
140(
141 uint8 const* _data,
142 uint32 const _length,
143 uint32 const _instance // = 1
144)
145{
146 if( BasicCmd_Report == (BasicCmd)_data[0] )
147 {
148 // Level
149 Log::Write( LogLevel_Info, GetNodeId(), "Received Basic report from node %d: level=%d", GetNodeId(), _data[1] );
150 if( !m_com.GetFlagBool(COMPAT_FLAG_BASIC_IGNOREREMAPPING) && m_com.GetFlagByte(COMPAT_FLAG_BASIC_MAPPING) != 0 )
151 {
152 UpdateMappedClass( _instance, m_com.GetFlagByte(COMPAT_FLAG_BASIC_MAPPING), _data[1] );
153 }
154 else if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
155 {
156 value->OnValueRefreshed( _data[1] );
157 value->Release();
158 } else {
159 Log::Write(LogLevel_Warning, GetNodeId(), "No Valid Mapping for Basic Command Class and No ValueID Exported. Error?");
160 }
161 return true;
162 }
163
164 if( BasicCmd_Set == (BasicCmd)_data[0] )
165 {
166 if( m_com.GetFlagBool(COMPAT_FLAG_BASIC_SETASREPORT) )
167 {
168 Log::Write( LogLevel_Info, GetNodeId(), "Received Basic set from node %d: level=%d. Treating it as a Basic report.", GetNodeId(), _data[1] );
169 if( !m_com.GetFlagBool(COMPAT_FLAG_BASIC_IGNOREREMAPPING) && m_com.GetFlagByte(COMPAT_FLAG_BASIC_MAPPING) != 0 )
170 {
171 UpdateMappedClass( _instance, m_com.GetFlagByte(COMPAT_FLAG_BASIC_MAPPING), _data[1] );
172 }
173 else if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
174 {
175 value->OnValueRefreshed( _data[1] );
176 value->Release();
177 }
178 }
179 else
180 {
181 // Commmand received from the node. Handle as a notification event
182 Log::Write( LogLevel_Info, GetNodeId(), "Received Basic set from node %d: level=%d. Sending event notification.", GetNodeId(), _data[1] );
183
184 Notification* notification = new Notification( Notification::Type_NodeEvent );
185 notification->SetHomeNodeIdAndInstance( GetHomeId(), GetNodeId(), _instance );
186 notification->SetEvent( _data[1] );
187 GetDriver()->QueueNotification( notification );
188 }
189 return true;
190 }
191
192 return false;
193}
194
195//-----------------------------------------------------------------------------
196// <Basic::SetValue>

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected