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

Method HandleMultiChannelEncap

cpp/src/command_classes/MultiInstance.cpp:622–665  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

620// Handle a message from the Z-Wave network
621//-----------------------------------------------------------------------------
622void MultiInstance::HandleMultiChannelEncap
623(
624 uint8 const* _data,
625 uint32 const _length
626)
627{
628 if( Node* node = GetNodeUnsafe() )
629 {
630 uint8 endPoint = _data[1] & 0x7f;
631 uint8 commandClassId = _data[3];
632 if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
633 {
634 /* 4.85.13 - If the Root Device is originating a command to an End Point in another node, the Source End Point MUST be set to 0.
635 *
636 */
637 if (endPoint == 0) {
638 Log::Write( LogLevel_Error, GetNodeId(), "MultiChannelEncap with endpoint set to 0 - Send to Root Device");
639 pCommandClass->HandleMsg(&_data[4], _length-4);
640 return;
641 }
642
643 uint8 instance = pCommandClass->GetInstance( endPoint );
644 /* we can never have a 0 Instance */
645 if (instance == 0)
646 instance = 1;
647 Log::Write( LogLevel_Info, GetNodeId(), "Received a MultiChannelEncap from node %d, endpoint %d for Command Class %s", GetNodeId(), endPoint, pCommandClass->GetCommandClassName().c_str() );
648 pCommandClass->HandleMsg( &_data[4], _length-4, instance );
649 }
650 else if (CommandClass* pCommandClass = node->GetCommandClass( commandClassId, true ) )
651 {
652 uint8 instance = pCommandClass->GetInstance( endPoint );
653 /* we can never have a 0 Instance */
654 if (instance == 0)
655 instance = 1;
656 Log::Write( LogLevel_Info, GetNodeId(), "Received a Incoming MultiChannelEncap from node %d, endpoint %d for Command Class %s", GetNodeId(), endPoint, pCommandClass->GetCommandClassName().c_str() );
657 pCommandClass->HandleIncomingMsg( &_data[4], _length-4, instance );
658
659 }
660 else
661 {
662 Log::Write(LogLevel_Error, GetNodeId(), "Received a MultiChannelEncap for endpoint %d for Command Class %d, which we can't find", endPoint, commandClassId);
663 }
664 }
665}
666//-----------------------------------------------------------------------------
667// <MultiInstance::HandleMultiChannelEncap>
668// Handle a message from the Z-Wave network

Callers

nothing calls this directly

Calls 8

WriteFunction · 0.85
GetCommandClassMethod · 0.80
GetInstanceMethod · 0.80
GetNodeIdFunction · 0.70
HandleMsgMethod · 0.45
c_strMethod · 0.45
GetCommandClassNameMethod · 0.45
HandleIncomingMsgMethod · 0.45

Tested by

no test coverage detected