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

Method GetVirtualNeighbors

cpp/src/Driver.cpp:6358–6398  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Gets the virtual neighbors for a network -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

6356// Gets the virtual neighbors for a network
6357//-----------------------------------------------------------------------------
6358uint32 Driver::GetVirtualNeighbors
6359(
6360 uint8** o_neighbors
6361)
6362{
6363 int i;
6364 uint32 numNeighbors = 0;
6365 if( !m_virtualNeighborsReceived )
6366 {
6367 *o_neighbors = NULL;
6368 return 0;
6369 }
6370 for( i = 0; i < 29; i++ )
6371 {
6372 for( unsigned char mask = 0x80; mask != 0; mask >>= 1 )
6373 if( m_virtualNeighbors[i] & mask )
6374 numNeighbors++;
6375 }
6376
6377 // handle the possibility that no neighbors are reported
6378 if( !numNeighbors )
6379 {
6380 *o_neighbors = NULL;
6381 return 0;
6382 }
6383
6384 // create and populate an array with neighbor node ids
6385 uint8* neighbors = new uint8[numNeighbors];
6386 uint32 index = 0;
6387 for( int by=0; by<29; by++ )
6388 {
6389 for( int bi=0; bi<8; bi++ )
6390 {
6391 if( (m_virtualNeighbors[by] & (0x01<<bi)) )
6392 neighbors[index++] = ( (by<<3) + bi + 1 );
6393 }
6394 }
6395
6396 *o_neighbors = neighbors;
6397 return numNeighbors;
6398}
6399
6400//-----------------------------------------------------------------------------
6401// <Driver::RequestVirtualNeighbors>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected