/*************************************************
* Function: PCT_HandleOtaFileEndMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_HandleOtaFileEndMsg(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    ZC_Printf("Ota File End\n");

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    PCT_SendAckToCloud(pstruMsg->MsgId);

}
Esempio n. 2
0
/*************************************************
* Function: PCT_HandleOtaBeginMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_HandleOtaBeginMsg(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    ZC_Printf("Ota Begin\n");
    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    PCT_SendAckToCloud(pstruMsg->MsgId);    
    
    PCT_SendNotifyMsg(ZC_CODE_ZOTA_BEGIN);
    return;
}
Esempio n. 3
0
/*************************************************
* Function: PCT_ResetNetWork
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_ResetNetWork(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;

    ZC_ConfigResetAccess();
    PCT_SendAckToCloud(pstruMsg->MsgId);
    pstruContoller->pstruMoudleFun->pfunSetTimer(PCT_TIMER_REBOOT,
            PCT_TIMER_INTERVAL_REBOOT, &pstruContoller->u8RebootTimer);
    return;
}
/*************************************************
* Function: PCT_ResetNetWork
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_ResetNetWork(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;

    ZC_ConfigInitPara();
    PCT_DisConnectCloud(pstruContoller);

    PCT_SendEmptyMsg(pstruMsg->MsgId, ZC_SEC_ALG_AES);
    PCT_SendAckToCloud(pstruMsg->MsgId);
    
    return;
}
/*************************************************
* Function: PCT_HandleMoudleMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_SetTokenKey(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    ZC_TokenSetReq *pstruSetKey;

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    pstruSetKey = (ZC_TokenSetReq *)(pstruMsg + 1);

    ZC_StoreTokenKey(pstruSetKey->TokenKey);

    PCT_SendEmptyMsg(pstruMsg->MsgId, ZC_SEC_ALG_AES);
    PCT_SendAckToCloud(pstruMsg->MsgId);
    
    return;
}
Esempio n. 6
0
/*************************************************
* Function: PCT_HandleMoudleMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_SetTokenKey(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    ZC_TokenSetReq *pstruSetKey;

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    pstruSetKey = (ZC_TokenSetReq *)(pstruMsg + 1);

    if (PCT_LOCAL_DYNAMIC_TOKEN == g_struProtocolController.u32LocalTokenFlag)
    {
        ZC_StoreTokenKey(pstruSetKey->TokenKey);
    }

    PCT_SendAckToCloud(pstruMsg->MsgId);
    
    return;
}
Esempio n. 7
0
/*************************************************
* Function: PCT_HandleOtaFileEndMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_HandleOtaEndMsg(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    u32 u32RetVal;
    ZC_Printf("Ota End\n");

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    u32RetVal = pstruContoller->pstruMoudleFun->pfunUpdateFinish(pstruContoller->struOtaInfo.u32TotalLen);
    if (ZC_RET_ERROR == u32RetVal)
    {
        PCT_SendErrorMsg(pstruMsg->MsgId, NULL, 0);
    }
    else
    {
        PCT_SendAckToCloud(pstruMsg->MsgId);
        PCT_SendNotifyMsg(ZC_CODE_ZOTA_END);
    }
}
/*************************************************
* Function: PCT_HandleOtaFileChunkMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_HandleOtaFileChunkMsg(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    ZC_OtaFileChunkReq *pstruOta;
    u32 u32FileLen;
    u32 u32RetVal;
    u32 u32RecvOffset;

    ZC_Printf("Ota File Chunk\n");

    
    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    pstruOta = (ZC_OtaFileChunkReq *)(pstruMsg + 1);
    u32FileLen = ZC_HTONS(pstruMsg->Payloadlen) - sizeof(ZC_OtaFileChunkReq);
    u32RecvOffset = ZC_HTONL(pstruOta->u32Offset);
    
    /*check para*/
    if ((u32RecvOffset != pstruContoller->struOtaInfo.u32RecvOffset)
        || ((u32RecvOffset + u32FileLen) > pstruContoller->struOtaInfo.u32TotalLen)
      || (u32FileLen > ZC_OTA_MAX_CHUNK_LEN))
    {
        ZC_Printf("recv error %d,%d,%d,%d,\n", u32RecvOffset, 
            pstruContoller->struOtaInfo.u32RecvOffset,
            pstruContoller->struOtaInfo.u32TotalLen,
            u32FileLen);
        PCT_SendErrorMsg(pstruMsg->MsgId, NULL, 0);
        return;
    }

    u32RetVal = pstruContoller->pstruMoudleFun->pfunUpdate((u8*)(pstruOta + 1), u32RecvOffset, u32FileLen);
    //u32RetVal = ZC_RET_OK;
    ZC_Printf("offset = %d, len = %d\n", u32RecvOffset, u32FileLen);

    if (ZC_RET_ERROR == u32RetVal)
    {
        ZC_Printf("OTA Fail\n");
        PCT_SendErrorMsg(pstruMsg->MsgId, NULL, 0);
        return;
    }

    /*update file offset*/
    pstruContoller->struOtaInfo.u32RecvOffset = pstruContoller->struOtaInfo.u32RecvOffset + u32FileLen;
    PCT_SendAckToCloud(pstruMsg->MsgId);
}
/*************************************************
* Function: PCT_HandleOtaFileBeginMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_HandleOtaFileBeginMsg(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    ZC_OtaFileBeginReq *pstruOta;
    ZC_Printf("Ota File Begin\n");
    

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    pstruOta = (ZC_OtaFileBeginReq *)(pstruMsg + 1);
    
    pstruContoller->struOtaInfo.u32RecvOffset = 0;
    pstruContoller->struOtaInfo.u32TotalLen = ZC_HTONL(pstruOta->u32FileTotalLen);
    pstruContoller->struOtaInfo.u8Crc[0] = pstruOta->u8TotalFileCrc[0];
    pstruContoller->struOtaInfo.u8Crc[1] = pstruOta->u8TotalFileCrc[1];    
    PCT_SendAckToCloud(pstruMsg->MsgId);


    return;
}
Esempio n. 10
0
/*************************************************
* Function: PCT_HandleOtaFileEndMsg
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_HandleOtaEndMsg(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    ZC_MessageHead *pstruMsg;
    u32 u32RetVal;
    ZC_Printf("Ota End\n");

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    u32RetVal = pstruContoller->pstruMoudleFun->pfunUpdateFinish(pstruContoller->struOtaInfo.u32TotalLen);
    if (ZC_RET_ERROR == u32RetVal)
    {
        PCT_SendErrorMsg(pstruMsg->MsgId, NULL, 0);
    }
    else
    {
        PCT_SendAckToCloud(pstruMsg->MsgId);
        pstruContoller->pstruMoudleFun->pfunSetTimer(PCT_TIMER_REBOOT, 
            PCT_TIMER_INTERVAL_REBOOT, &pstruContoller->u8RebootTimer);
    }
}
Esempio n. 11
0
/*************************************************
* Function: PCT_SetLicense
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_SetLicense(PTC_ProtocolCon *pstruContoller, MSG_Buffer *pstruBuffer)
{
    s32 ret = 0;
    ZC_MessageHead *pstruMsg;
    u8 *pu8License;

    pstruMsg = (ZC_MessageHead*)pstruBuffer->u8MsgBuffer;
    pu8License = (u8 *)(pstruMsg + 1);

    ret = ZC_ConfigLicense(pu8License, ZC_HTONS(pstruMsg->Payloadlen));
    if (ZC_RET_OK == ret)
    {
        PCT_SendAckToCloud(pstruMsg->MsgId);
    }
    else 
    {
        PCT_SendErrorMsg(pstruMsg->MsgId, NULL, 0);        
    }

    pstruContoller->pstruMoudleFun->pfunSetTimer(PCT_TIMER_REBOOT, 
            PCT_TIMER_INTERVAL_REBOOT, &pstruContoller->u8RebootTimer);
    return;
}