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

Method HandleApplicationCommandHandlerRequest

cpp/src/Driver.cpp:3732–3815  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Process a request from the Z-Wave PC interface -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3730// Process a request from the Z-Wave PC interface
3731//-----------------------------------------------------------------------------
3732void Driver::HandleApplicationCommandHandlerRequest
3733(
3734 uint8* _data,
3735 bool encrypted
3736)
3737{
3738
3739 uint8 status = _data[2];
3740 uint8 nodeId = _data[3];
3741 uint8 classId = _data[5];
3742 Node* node = GetNodeUnsafe( nodeId );
3743
3744 if( ( status & RECEIVE_STATUS_ROUTED_BUSY ) != 0 )
3745 {
3746 m_routedbusy++;
3747 }
3748 if( ( status & RECEIVE_STATUS_TYPE_BROAD ) != 0 )
3749 {
3750 m_broadcastReadCnt++;
3751 }
3752 if( node != NULL )
3753 {
3754 node->m_receivedCnt++;
3755 node->m_errors = 0;
3756 int cmp = memcmp( _data, node->m_lastReceivedMessage, sizeof(node->m_lastReceivedMessage));
3757 if( cmp == 0 && node->m_receivedTS.TimeRemaining() > -500 )
3758 {
3759 // if the exact same sequence of bytes are received within 500ms
3760 node->m_receivedDups++;
3761 }
3762 else
3763 {
3764 memcpy( node->m_lastReceivedMessage, _data, sizeof(node->m_lastReceivedMessage) );
3765 }
3766 node->m_receivedTS.SetTime();
3767 if( m_expectedReply == FUNC_ID_APPLICATION_COMMAND_HANDLER && m_expectedNodeId == nodeId )
3768 {
3769 // Need to confirm this is the correct response to the last sent request.
3770 // At least ignore any received messages prior to the send data request.
3771 node->m_lastResponseRTT = -node->m_sentTS.TimeRemaining();
3772
3773 if( node->m_averageResponseRTT )
3774 {
3775 // if the average has been established, update by averaging the average and the last RTT
3776 node->m_averageResponseRTT = ( node->m_averageResponseRTT + node->m_lastResponseRTT ) >> 1;
3777 }
3778 else
3779 {
3780 // if this is the first observed RTT, set the average to this value
3781 node->m_averageResponseRTT = node->m_lastResponseRTT;
3782 }
3783 Log::Write(LogLevel_Info, nodeId, "Response RTT %d Average Response RTT %d", node->m_lastResponseRTT, node->m_averageResponseRTT );
3784 }
3785 else
3786 {
3787 node->m_receivedUnsolicited++;
3788 }
3789 if ( !node->IsNodeAlive() )

Callers

nothing calls this directly

Calls 7

WriteFunction · 0.85
IsNodeAliveMethod · 0.80
SetNodeAliveMethod · 0.80
TimeRemainingMethod · 0.45
SetTimeMethod · 0.45
HandleMsgMethod · 0.45

Tested by

no test coverage detected