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

Method SendMsg

cpp/src/Driver.cpp:1035–1097  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Queue a message to be sent to the Z-Wave PC Interface -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1033// Queue a message to be sent to the Z-Wave PC Interface
1034//-----------------------------------------------------------------------------
1035void Driver::SendMsg
1036(
1037 Msg* _msg,
1038 MsgQueue const _queue
1039)
1040{
1041 MsgQueueItem item;
1042
1043 item.m_command = MsgQueueCmd_SendMsg;
1044 item.m_msg = _msg;
1045 /* make sure the HomeId is Set on this message */
1046 _msg->SetHomeId(m_homeId);
1047 _msg->Finalize();
1048 {
1049 LockGuard LG(m_nodeMutex);
1050 if( Node* node = GetNode(_msg->GetTargetNodeId()) )
1051 {
1052 /* if the node Supports the Security Class - check if this message is meant to be encapsulated */
1053 if ( node->GetCommandClass(Security::StaticGetCommandClassId()) )
1054 {
1055 CommandClass *cc = node->GetCommandClass(_msg->GetSendingCommandClass());
1056 if ( (cc) && (cc->IsSecured()) )
1057 {
1058 Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Setting Encryption Flag on Message For Command Class %s", cc->GetCommandClassName().c_str());
1059 item.m_msg->setEncrypted();
1060 }
1061 }
1062
1063 // If the message is for a sleeping node, we queue it in the node itself.
1064 if( !node->IsListeningDevice() )
1065 {
1066 if( WakeUp* wakeUp = static_cast<WakeUp*>( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) )
1067 {
1068 if( !wakeUp->IsAwake() )
1069 {
1070 Log::Write( LogLevel_Detail, "" );
1071 // Handle saving multi-step controller commands
1072 if( m_currentControllerCommand != NULL )
1073 {
1074 Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Queuing (%s) %s", c_sendQueueNames[MsgQueue_Controller], c_controllerCommandNames[m_currentControllerCommand->m_controllerCommand] );
1075 delete _msg;
1076 item.m_command = MsgQueueCmd_Controller;
1077 item.m_cci = new ControllerCommandItem( *m_currentControllerCommand );
1078 item.m_msg = NULL;
1079 UpdateControllerState( ControllerState_Sleeping );
1080 }
1081 else
1082 {
1083 Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Queuing (%s) %s", c_sendQueueNames[MsgQueue_WakeUp], _msg->GetAsString().c_str() );
1084 }
1085 wakeUp->QueueMsg( item );
1086 return;
1087 }
1088 }
1089 }
1090 }
1091 }
1092 Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Queuing (%s) %s", c_sendQueueNames[_queue], _msg->GetAsString().c_str() );

Callers 15

SendRawDataMethod · 0.80
AdvanceQueriesMethod · 0.80
PlayInitSequenceMethod · 0.80
RequestValueMethod · 0.80
SetValueMethod · 0.80
SendPendingMethod · 0.80
SendNoMoreInfoMethod · 0.80
RequestValueMethod · 0.80
SetValueMethod · 0.80
RequestValueMethod · 0.80
HandleMsgMethod · 0.80

Calls 13

WriteFunction · 0.85
FinalizeMethod · 0.80
GetCommandClassMethod · 0.80
IsSecuredMethod · 0.80
IsListeningDeviceMethod · 0.80
IsAwakeMethod · 0.80
QueueMsgMethod · 0.80
c_strMethod · 0.45
GetCommandClassNameMethod · 0.45
GetAsStringMethod · 0.45
LockMethod · 0.45
SetMethod · 0.45

Tested by 3

TestMethod · 0.64
RequestStateMethod · 0.64
RequestValueMethod · 0.64