/*****************************************************************************
Copyright: 2013-2018, MIAO XUN TECH. Co., Ltd.
File name:ps_order.c
Description: 网管协议栈监控命令
Author: 周涛
Version: 0.0.01
Date: 2022-4-15
History:
*****************************************************************************/
#include "includes.h"

// MCP层上行命令处理接口
// pbyData:  接收到得数据,bySource:  数据来源,wLen:  数据长度,
uint8 ps_up_mcp_in_req(uint8 *pbyData, uint8 bySource, uint16 wLen)
{
    PS_HEAD_T *pstHead = (PS_HEAD_T *)pbyData;
    uint8 byFlag = 0;

    // 解析MCP层命令标识
    switch (pstHead->stMcpHead.byComd)
    {
    case MCP_A_QUERY: // MCP查询命令
        byFlag = ps_up_mcp_query(pbyData, bySource, wLen);
        break;
    case MCP_A_CONFIGURE: // MCP设置命令
        byFlag = ps_up_mcp_set(pbyData, bySource, wLen);
        break;
    default: // 命令类型错误
        byFlag = 1;
        break;
    }

    if (byFlag)
    {
        return byFlag;
    }
    return 0;
}

// 网管对设备请求的应答处理接口
// pbyData: 网管对设备请求的应答数据,wLen:  数据长度,bySource:  数据来源
uint8 ps_up_mcp_in_res(uint8 *pbyData, uint8 bySource, uint16 wLen)
{
    PS_HEAD_T *pstHead = (PS_HEAD_T *)pbyData;

    // 解析MCP层应答标识
    switch (pstHead->stMcpHead.byResp)
    {
    case MCP_RESP_SUCC: // 成功
        ps_up_mcp_report_resp_ok(pbyData, bySource, wLen);
        break;
    case MCP_RESP_ERR: // 失败
    default:           // 应答类型错误
        return 1;
    }

    return 0;
}
