/*
 * @Description: 红外模块-app层
 * @Author: yangsw
 * @Date: 2021-06-25 17:00:17
 * @LastEditTime: 2023-10-12 16:23:25
 * @LastEditors: LiDa
 * @Reference: 
 */
#include "app_ir.h"
#include "../../com/svc/svc_com_core.h"
#include "../../ota/svc/svc_ota.h"
#include "../../log/svc/svc_log.h"
// #include "../../iwdg/bsp/bsp_iwdg.h"
/**
 * @brief: 红外模块线程
 * @param  {void}
 * @return {void}
 * @note: 
 * @see: 
 */
void App_Ir_Task(void){
    //Svc_Com_Core_Func_Init((gw_u8*)__FUNCTION__);
    Bsp_Iwdg_Feed();//喂狗<<
    Svc_Ir_Uart_Recv();
}

void App_Ir_OtaTask(void)
{
    Bsp_Iwdg_Feed();//喂狗<<
    E_OTA_Event_Enum e_event=E_OTA_EVENT_NO;
    e_event=Svc_Ota_Get_Pending_Event();    //获取处于等待处理的最高优先级事件
    if(Svc_Ota_Event_Is_Changed(e_event)==E_CHECK_FAIL){//事件未改变，不需要重新触发
        return;
    }
    switch (e_event)
    {
        case E_OTA_EVENT_REQUEST_OTA:
            Svc_Ota_Lock_Event(E_OTA_EVENT_REQUEST_OTA);//锁定当前云事件请求OTA数据
            Svc_Ir_Protocol_Request_Ota(); //请求OTA数据命令生成      
            break;
        case E_OTA_EVENT_REQUEST_OTA_DATA:
            Svc_Ota_Lock_Event(E_OTA_EVENT_REQUEST_OTA_DATA);//锁定当前云事件请求OTA数据
            Svc_Ir_Protocol_Request_Ota_Data(); //请求OTA数据命令生成                       
            break;
        default:
            return;
    }
    #if LOG_FUNC_ENABLE
        Svc_Log_Printf(LOG_INFO,"%s->cloud event:0x%04X",__FUNCTION__,e_event);
    #endif
}