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

Method SetAwake

cpp/src/command_classes/WakeUp.cpp:342–384  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set whether the device is likely to be awake -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

340// Set whether the device is likely to be awake
341//-----------------------------------------------------------------------------
342void WakeUp::SetAwake
343(
344 bool _state
345)
346{
347 if( m_awake != _state )
348 {
349 /* we do the call on RefreshValuesOnWakeup here, so any duplicates in the wakeup Queue are handled appropriately
350 *
351 */
352 if ( m_awake == false ) {
353 Node* node = GetNodeUnsafe();
354 if (node)
355 node->RefreshValuesOnWakeup();
356 }
357
358 m_awake = _state;
359 Log::Write( LogLevel_Info, GetNodeId(), " Node %d has been marked as %s", GetNodeId(), m_awake ? "awake" : "asleep" );
360 Notification* notification = new Notification( Notification::Type_Notification );
361 notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() );
362 notification->SetNotification( m_awake ? Notification::Code_Awake : Notification::Code_Sleep );
363 GetDriver()->QueueNotification( notification );
364
365 }
366
367 if( m_awake )
368 {
369 // If the device is marked for polling, request the current state
370 Node* node = GetNodeUnsafe();
371 if( m_pollRequired )
372 {
373 if( node != NULL )
374 {
375 node->SetQueryStage( Node::QueryStage_Dynamic );
376 }
377 m_pollRequired = false;
378 }
379 // Send all pending messages
380 SendPending();
381
382
383 }
384}
385
386//-----------------------------------------------------------------------------
387// <WakeUp::QueueMsg>

Callers 3

HandleSendDataRequestMethod · 0.80
UpdateNodeInfoMethod · 0.80

Calls 6

WriteFunction · 0.85
RefreshValuesOnWakeupMethod · 0.80
QueueNotificationMethod · 0.80
SetQueryStageMethod · 0.80
GetNodeIdFunction · 0.70
GetHomeIdFunction · 0.70

Tested by

no test coverage detected