#include "UDS_85Service_Filter.h"

/**
  *85�����Ƿ�֧�ֹ���Ѱַ
  *����Ѱַ�����θø�����
  *@return ���������
  */
uint8_t UDS_85Service_NRC11(void)
{
    uint8_t NRC = positiveResponse;
    return NRC;
}

/**
  *85����Ự�Ƿ�֧����֤
  *����Ѱַ�����θø�����
  *@return ���������
  */
uint8_t UDS_85Service_NRC7F(void)
{
    uint8_t NRC = positiveResponse;
    if ( getSessionType( ) != ExtendedDiagnosticSession )
    {
        NRC = serviceNotSupportedInActiveSession;
        if(DiagMSG.msgID == DIAG_ID_Rx_PHY)
        {
            UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
        }
    }
    else
    {
        NRC = positiveResponse;
    }
    return NRC;
}

/**
  *85��������ȼ���֤
  *@return ���������
  */
uint8_t UDS_85Service_NRC33(void)
{
    uint8_t NRC = positiveResponse;
    return NRC;
}

/**
  *85������С������֤
  *@return ���������
  */
uint8_t UDS_85Service_NRC13_MinLengthCheck(void)
{
    uint8_t NRC = positiveResponse;
    if ( DiagMSG.msgDLC < 1u )
    {
        NRC = incorrectMessageLength;
        UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
    }
    else
    {
        NRC = positiveResponse;
    }
    return NRC;
}

/**
  *85���񳬳�����Χ��֤
  *����Ѱַ�����θø�����
  *@return ���������
  */
uint8_t UDS_85Service_NRC31(void)
{
    uint8_t NRC = positiveResponse;
    return NRC;
}

/**
  *85�����ܳ��ȳ�����֤
  *@return ���������
  */
uint8_t UDS_85Service_NRC13_TotalLengthCheck(void)
{
    uint8_t NRC = positiveResponse;
    if ( DiagMSG.msgDLC != 1u )
    {
        NRC = incorrectMessageLength;
        UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
    }
    else
    {
        NRC = positiveResponse;
    }
    return NRC;
}

/**
  *85����������֤
  *@return ���������
  */
uint8_t UDS_85Service_NRC22(void)
{
    uint8_t NRC = positiveResponse;
    if ( getSpeed( ) >= 3u )
    {
        NRC = conditionsNotCorrect;
        UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
    }
    else if ( getESpeed( ) > 400u )
    {
        NRC = conditionsNotCorrect;
        UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
    }
    else
    {
        NRC = positiveResponse;
    }
    return NRC;
}

/**
  *85�����ӹ�����С������֤
  *@return ���������
  */
uint8_t UDS_85Service_Sub_NRC13_MinLengthCheck(void)
{
    uint8_t NRC = positiveResponse;
    if ( DiagMSG.msgData.SidDetail.SubID == DTCSettingOn )
    {
        if ( DiagMSG.msgDLC < 1u )
        {
            NRC = incorrectMessageLength;
            UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
        }
        else
        {
            NRC = positiveResponse;
        }
    }
    if ( DiagMSG.msgData.SidDetail.SubID == DTCSettingOff )
    {
        if ( DiagMSG.msgDLC < 1u )
        {
            NRC = incorrectMessageLength;
            UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
        }
        else
        {
            NRC = positiveResponse;
        }
    }
    return NRC;
}

/**
  *85�����ӹ����Ƿ�֧����֤
  *����Ѱַ�����θø�����
  *@return ���������
  */
uint8_t UDS_85Service_Sub_NRC12(void)
{
    uint8_t NRC = positiveResponse;
    if ( (DiagMSG.msgData.SidDetail.SubID == DTCSettingOn) || (DiagMSG.msgData.SidDetail.SubID == DTCSettingOff) )
    {
        NRC = positiveResponse;
    }
    else
    {
        NRC = subFunctionNotSupported;
        if ( DiagMSG.msgID == DIAG_ID_Rx_PHY )
        {
            UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
        }
    }
    return NRC;
}

/**
  *85�����ӹ��ܻỰ�Ƿ�֧����֤
  *����Ѱַ�����θø�����
  *@return ���������
  */
uint8_t UDS_85Service_Sub_NRC7E(void)
{
    uint8_t NRC = positiveResponse;
    return NRC;
}

/**
  *85�����ӹ��ܳ�������Χ��֤
  *����Ѱַ�����θø�����
  *@return ���������
  */
uint8_t UDS_85Service_Sub_NRC31(void)
{
    uint8_t NRC = positiveResponse;
    return NRC;
}

/**
  *85�����ӹ����ܳ��ȳ�����֤
  *@return ���������
  */
uint8_t UDS_85Service_Sub_NRC13_TotalLengthCheck(void)
{
    uint8_t NRC = positiveResponse;
    if ( DiagMSG.msgData.SidDetail.SubID == DTCSettingOn )
    {
        if ( DiagMSG.msgDLC != 1u )
        {
            NRC = incorrectMessageLength;
            UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
        }
        else
        {
            NRC = positiveResponse;
        }
    }
    if ( DiagMSG.msgData.SidDetail.SubID == DTCSettingOff )
    {
        if ( DiagMSG.msgDLC != 1u )
        {
            NRC = incorrectMessageLength;
            UDS_Service_Response(0x85u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, ( uint8_t * )&NRC);
        }
        else
        {
            NRC = positiveResponse;
        }
    }

    return NRC;
}

/**
  *85�����ӹ�������˳����֤
  *@return ���������
  */
uint8_t UDS_85Service_Sub_NRC24(void)
{
    uint8_t NRC = positiveResponse;
    return NRC;
}

/**
  *85�����ӹ���������֤
  *@return ���������
  */
uint8_t UDS_85Service_Sub_NRC22(void)
{
    uint8_t NRC = positiveResponse;
    return NRC;
}