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

Method HandleMsg

cpp/src/command_classes/CRC16Encap.cpp:64–101  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

62// Handle a message from the Z-Wave network
63//-----------------------------------------------------------------------------
64bool CRC16Encap::HandleMsg
65(
66 uint8 const* _data,
67 uint32 const _length,
68 uint32 const _instance // = 1
69)
70{
71 if( CRC16EncapCmd_Encap == (CRC16EncapCmd)_data[0] )
72 {
73 Log::Write( LogLevel_Info, GetNodeId(), "Received CRC16-command from node %d", GetNodeId());
74
75 uint16 crcM = (_data[_length - 3] << 8) + _data[_length - 2] ; // crc as reported in msg
76 uint16 crcC = crc16(&_data[0], _length - 3 ); // crc calculated
77
78 if ( crcM != crcC )
79 {
80 Log::Write( LogLevel_Info, GetNodeId(), "CRC check failed, message contains 0x%.4x but should be 0x%.4x", crcM, crcC);
81 return false;
82 }
83
84 if( Node const* node = GetNodeUnsafe() )
85 {
86 uint8 commandClassId = _data[1];
87
88 if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId, false ) )
89 {
90 pCommandClass->HandleMsg( &_data[2], _length - 4 );
91 }
92 if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId, true ) )
93 {
94 pCommandClass->HandleIncomingMsg( &_data[2], _length - 4 );
95 }
96 }
97
98 return true;
99 }
100 return false;
101}

Callers

nothing calls this directly

Calls 5

WriteFunction · 0.85
crc16Function · 0.85
GetCommandClassMethod · 0.80
GetNodeIdFunction · 0.70
HandleIncomingMsgMethod · 0.45

Tested by

no test coverage detected