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

Method HandleMsg

cpp/src/command_classes/Association.cpp:211–316  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

209// Handle a message from the Z-Wave network
210//-----------------------------------------------------------------------------
211bool Association::HandleMsg
212(
213 uint8 const* _data,
214 uint32 const _length,
215 uint32 const _instance // = 1
216)
217{
218 bool handled = false;
219 uint32 i;
220
221 if( Node* node = GetNodeUnsafe() )
222 {
223 if( AssociationCmd_GroupingsReport == (AssociationCmd)_data[0] )
224 {
225 // Retrieve the number of groups this device supports.
226 // The groups will be queried with the session data.
227 m_numGroups = _data[1];
228 Log::Write( LogLevel_Info, GetNodeId(), "Received Association Groupings report from node %d. Number of groups is %d", GetNodeId(), m_numGroups );
229 ClearStaticRequest( StaticRequest_Values );
230 handled = true;
231 }
232 else if( AssociationCmd_Report == (AssociationCmd)_data[0] )
233 {
234 // Get the group info
235 uint8 groupIdx = _data[1];
236 uint8 maxAssociations = _data[2]; // If the maxAssociations is zero, this is not a supported group.
237 uint8 numReportsToFollow = _data[3]; // If a device supports a lot of associations, they may come in more than one message.
238
239 if( maxAssociations )
240 {
241 if( _length >= 5 )
242 {
243 uint8 numAssociations = _length - 5;
244
245 Log::Write( LogLevel_Info, GetNodeId(), "Received Association report from node %d, group %d, containing %d associations", GetNodeId(), groupIdx, numAssociations );
246 if( numAssociations )
247 {
248 Log::Write( LogLevel_Info, GetNodeId(), " The group contains:" );
249 for( i=0; i<numAssociations; ++i )
250 {
251 Log::Write( LogLevel_Info, GetNodeId(), " Node %d", _data[i+4] );
252 m_pendingMembers.push_back( _data[i+4] );
253 }
254 }
255 }
256
257 if( numReportsToFollow )
258 {
259 // We're expecting more reports for this group
260 Log::Write( LogLevel_Info, GetNodeId(), "%d more association reports expected for node %d, group %d", numReportsToFollow, GetNodeId(), groupIdx );
261 return true;
262 }
263 else
264 {
265 // No more reports to come for this group, so we can apply the pending list
266 Group* group = node->GetGroup( groupIdx );
267 if( NULL == group )
268 {

Callers

nothing calls this directly

Calls 8

WriteFunction · 0.85
GetGroupMethod · 0.80
AddGroupMethod · 0.80
OnGroupChangedMethod · 0.80
clearMethod · 0.80
AutoAssociateMethod · 0.80
GetNodeIdFunction · 0.70
GetHomeIdFunction · 0.70

Tested by

no test coverage detected