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

Method AdvanceQueries

cpp/src/Node.cpp:263–753  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Proceed through the initialisation process -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

261// Proceed through the initialisation process
262//-----------------------------------------------------------------------------
263void Node::AdvanceQueries
264(
265)
266{
267 // For OpenZWave to discover everything about a node, we have to follow a certain
268 // order of queries, because the results of one stage may affect what is requested
269 // in the next stage. The stage is saved with the node data, so that any incomplete
270 // queries can be restarted the next time the application runs.
271 // The individual command classes also store some state as to whether they have
272 // had a response to certain queries. This state is initilized by the SetStaticRequests
273 // call in QueryStage_None. It is also saved, so we do not need to request state
274 // from every command class if some have previously responded.
275 //
276 // Each stage must generate all the messages for its particular stage as
277 // assumptions are made in later code (RemoveMsg) that this is the case. This means
278 // each stage is only visited once.
279
280 Log::Write( LogLevel_Detail, m_nodeId, "AdvanceQueries queryPending=%d queryRetries=%d queryStage=%s live=%d", m_queryPending, m_queryRetries, c_queryStageNames[m_queryStage], m_nodeAlive );
281 bool addQSC = false; // We only want to add a query stage complete if we did some work.
282 while( !m_queryPending && m_nodeAlive )
283 {
284 switch( m_queryStage )
285 {
286 case QueryStage_None:
287 {
288 // Init the node query process
289 m_queryStage = QueryStage_ProtocolInfo;
290 m_queryRetries = 0;
291 break;
292 }
293 case QueryStage_ProtocolInfo:
294 {
295 // determines, among other things, whether this node is a listener, its maximum baud rate and its device classes
296 if( !ProtocolInfoReceived() )
297 {
298 Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_ProtocolInfo" );
299 Msg* msg = new Msg( "Get Node Protocol Info", m_nodeId, REQUEST, FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO, false );
300 msg->Append( m_nodeId );
301 GetDriver()->SendMsg( msg, Driver::MsgQueue_Query );
302 m_queryPending = true;
303 addQSC = true;
304 }
305 else
306 {
307 // This stage has been done already, so move to the Neighbours stage
308 m_queryStage = QueryStage_Probe;
309 m_queryRetries = 0;
310 }
311 break;
312 }
313 case QueryStage_Probe:
314 {
315 Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Probe" );
316 //
317 // Send a NoOperation message to see if the node is awake
318 // and alive. Based on the response or lack of response
319 // will determine next step.
320 //

Callers 1

WriteNextMsgMethod · 0.80

Calls 15

WriteFunction · 0.85
GetManufacturerIdFunction · 0.85
GetProductTypeFunction · 0.85
GetProductIdFunction · 0.85
SendMsgMethod · 0.80
GetControllerNodeIdMethod · 0.80
LoadConfigXMLMethod · 0.80
ReLoadConfigXMLMethod · 0.80
RequestInstancesMethod · 0.80
QueueNotificationMethod · 0.80

Tested by

no test coverage detected