----------------------------------------------------------------------------- Move messages for a sleeping device to its wake-up queue -----------------------------------------------------------------------------
| 1400 | // Move messages for a sleeping device to its wake-up queue |
| 1401 | //----------------------------------------------------------------------------- |
| 1402 | bool Driver::MoveMessagesToWakeUpQueue |
| 1403 | ( |
| 1404 | uint8 const _targetNodeId, |
| 1405 | bool const _move |
| 1406 | ) |
| 1407 | { |
| 1408 | // If the target node is one that goes to sleep, transfer |
| 1409 | // all messages for it to its Wake-Up queue. |
| 1410 | if( Node* node = GetNodeUnsafe(_targetNodeId) ) |
| 1411 | { |
| 1412 | if( !node->IsListeningDevice() && !node->IsFrequentListeningDevice() && _targetNodeId != m_Controller_nodeId ) |
| 1413 | { |
| 1414 | if( WakeUp* wakeUp = static_cast<WakeUp*>( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) |
| 1415 | { |
| 1416 | // Mark the node as asleep |
| 1417 | wakeUp->SetAwake( false ); |
| 1418 | |
| 1419 | // If we need to save the messages |
| 1420 | if( _move ) |
| 1421 | { |
| 1422 | // Move all messages for this node to the wake-up queue |
| 1423 | m_sendMutex->Lock(); |
| 1424 | |
| 1425 | // See if we are working on a controller command |
| 1426 | if( m_currentControllerCommand ) |
| 1427 | { |
| 1428 | // Don't save controller message as it will be recreated |
| 1429 | RemoveCurrentMsg(); |
| 1430 | } |
| 1431 | |
| 1432 | // Then try the current message first |
| 1433 | if( m_currentMsg ) |
| 1434 | { |
| 1435 | if( _targetNodeId == m_currentMsg->GetTargetNodeId() ) |
| 1436 | { |
| 1437 | // This message is for the unresponsive node |
| 1438 | // We do not move any "Wake Up No More Information" |
| 1439 | // commands or NoOperations to the pending queue. |
| 1440 | if( !m_currentMsg->IsWakeUpNoMoreInformationCommand() && !m_currentMsg->IsNoOperation() ) |
| 1441 | { |
| 1442 | Log::Write( LogLevel_Info, _targetNodeId, "Node not responding - moving message to Wake-Up queue: %s", m_currentMsg->GetAsString().c_str() ); |
| 1443 | /* reset the sendAttempts */ |
| 1444 | m_currentMsg->SetSendAttempts(0); |
| 1445 | |
| 1446 | MsgQueueItem item; |
| 1447 | item.m_command = MsgQueueCmd_SendMsg; |
| 1448 | item.m_msg = m_currentMsg; |
| 1449 | wakeUp->QueueMsg( item ); |
| 1450 | } |
| 1451 | else |
| 1452 | { |
| 1453 | delete m_currentMsg; |
| 1454 | } |
| 1455 | |
| 1456 | m_currentMsg = NULL; |
| 1457 | m_expectedCallbackId = 0; |
| 1458 | m_expectedCommandClassId = 0; |
| 1459 | m_expectedNodeId = 0; |
nothing calls this directly
no test coverage detected