stm32_ota/USER/main.c

296 lines
17 KiB
C
Raw Normal View History

2023-12-15 06:28:06 +00:00
#include <string.h>
#include <stdio.h>
#include "usb.h"
#include "iap.h"
#include "sys.h"
#include "systick.h"
#include "usart.h"
#include "led.h"
#include "timer.h"
#include "sysport.h"
#include "mac.h"
#include "stm32Temp.h"
#include "watchdog.h"
#include "rtc.h"
#include "user_tcp.h"
#include "user_key.h"
#include "logflash.h"
#include "user_ftp.h"
#include "user_http.h"
#include "ec20module.h"
#include "ec20tcp.h"
#include "ec20http.h"
#include "userapp.h"
#include "user_flash.h"
#include "user_ftp.h"
#include "usercmd.h"
#include "user_oled.h"
/**********************************************************************************
*<EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
**********************************************************************************/
RunResult NetTask(void) ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int main(void)
{
RunResult result = RUNERR ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
uint32_t appAddr = 0 ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>APP FLASH<53><48><EFBFBD>׵<EFBFBD>ַ
InitIapFlashConfig(&uIapFlash) ; //<2F><><EFBFBD><EFBFBD>FLASH<53>е<EFBFBD>Iap<61><70><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>uIapFlash<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>FLASH<53><48>
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4) ; //<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>4 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0~15<31><35><EFBFBD><EFBFBD>16<31><36><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>
InitApplictationState(&gateApp); //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>gateApp
UsbInit(9600) ; //<2F><><EFBFBD>Դ<EFBFBD><D4B4>ڡ<EFBFBD><DAA1><EFBFBD><EFBFBD><EFBFBD>תUSB<53>ڳ<EFBFBD>ʼ<EFBFBD><CABC>
Board_Init() ; //Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>͹<EFBFBD><CDB9>ܿ<EFBFBD><DCBF><EFBFBD>ʼ<EFBFBD><CABC>
Watchdog_Feed() ; //<2F><><EFBFBD>Ź<EFBFBD>ι<EFBFBD><CEB9>
/*
/*ǿ<><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A1A2>ʼ<EFBFBD><CABC>ש<EFBFBD><D7A9><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if( (uIapFlash.sIapFlash.JumpResult == 0x30) ) /*<2A><>תʧ<D7AA>ܻ<EFBFBD><DCBB>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
DisplayInfo("ִ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
Wait_For_Nms(20) ; //<2F><>ʱ2S<32><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
goto SAVEAPPOUT ; //<2F><>ת<EFBFBD><D7AA>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
else /*<2A><>תAPPδ<50><CEB4><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>ñ<EFBFBD>־λjumpResultΪ<74><CEAA>δ<EFBFBD><CEB4>ת<EFBFBD>ɹ<EFBFBD>״
{
uIapFlash.sIapFlash.JumpResult = 0x30 ; //<2F><>λJumpResult<6C><74>־λ
Set_uIapFlash(&uIapFlash) ; //<2F><><EFBFBD><EFBFBD>JumpResult
}
*/
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ש<EFBFBD><D7A9><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
/*<2A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>APP(<28><><EFBFBD>ж<EFBFBD>IapFlag<61><67>־λ)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if( true == IS_IapFlag_ALL_PERIPH(uIapFlash.sIapFlash.IapFlag) ) /*IapFlag<61>Ϸ<EFBFBD>*/ //IapFlag<61><67>־λ<D6BE>Ϸ<EFBFBD><CFB7><EFBFBD>У<EFBFBD><D0A3>
{
if(uIapFlash.sIapFlash.IapFlag == 0x30 ) /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λΪ<CEBB><CEAA>0<EFBFBD><30>, ˵<><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>*/
{
// AppLogPrintf("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>APP%c .", uIapFlash.sIapFlash.RunAppNum) ;
goto APPNUMOUT ; //<2F><>ת<EFBFBD><D7AA>RunAppNum<75><6D>ִ<EFBFBD><D6B4>ԭ<EFBFBD>ȵij<C8B5><C4B3><EFBFBD>
}
}
else /*IapFlag<61><67><EFBFBD>Ϸ<EFBFBD>*/
{
AppLogPrintf("IapFlag=%c,<2C><><EFBFBD>Ϸ<EFBFBD>,<2C><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>APP%c .", uIapFlash.sIapFlash.IapFlag, uIapFlash.sIapFlash.RunAppNum) ;
uIapFlash.sIapFlash.IapFlag = 0x30 ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
Set_uIapFlash(&uIapFlash) ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
goto APPNUMOUT ; //<2F><>ת<EFBFBD><D7AA>RunAppNum<75><6D>ִ<EFBFBD><D6B4>ԭ<EFBFBD>ȵij<C8B5><C4B3><EFBFBD>
}
/*<2A><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
/*<2A><><EFBFBD><EFBFBD>APP(<28><><EFBFBD><EFBFBD>TCP\FTP<54><50><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תAPPP)<29><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
Watchdog_Feed() ; //<2F><><EFBFBD>Ź<EFBFBD>ι<EFBFBD><CEB9>
/*<2A>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>ʼ<EFBFBD>ġġġġġġġġššššššššššššššššššššššššššššššššššššššššššššššššššššššššššššššššššš<C5A1>*/
result = NetTask() ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
if( RUNERR == result ) /*TCP\FTP<54><50>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7> */
{
DisplayInfo("FTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>") ;
TcpUpdata( BOOTTOTCPFRAME, "FTP<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תRunAppNum: APP%c<><63>", uIapFlash.sIapFlash.RunAppNum) ;
Wait_For_Nms(20) ; //<2F><>ʱ2S<32><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
goto APPNUMOUT ; //<2F><>ת<EFBFBD><D7AA>RunAppNum<75><6D>ִ<EFBFBD><D6B4>ԭ<EFBFBD>ȵij<C8B5><C4B3><EFBFBD>
}
/*<2A>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD>ġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġ<C4A1>*/
/*<2A>šŲ<C5A1><C5B2><EFBFBD><EFBFBD>¹̼<C2B9><CCBC><EFBFBD>ʼ<EFBFBD>šššššššġššššššššššššššššššššššššššššššššššššššššššššššššššššššššš<C5A1>*/
TcpUpdata( BOOTTOTCPFRAME, "FTP<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
Watchdog_Feed() ; //<2F><><EFBFBD>Ź<EFBFBD>ι<EFBFBD><CEB9>
result = FindAppFile(&sDownApp) ; //<2F><><EFBFBD><EFBFBD><EFBFBD>¹̼<C2B9>
if( RUNERR == result ) /*δ<>ҵ<EFBFBD><D2B5>¹̼<C2B9>*/
{
TcpUpdata( BOOTTOTCPFRAME, "δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תRunAppNum: APP%c<><63>", uIapFlash.sIapFlash.RunAppNum) ;
Wait_For_Nms(200) ; //<2F><>ʱ2S<32><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
goto APPNUMOUT ; //<2F><>ת<EFBFBD><D7AA>RunAppNum<75><6D>ִ<EFBFBD><D6B4>ԭ<EFBFBD>ȵij<C8B5><C4B3><EFBFBD>
}
/*<2A>ġIJ<C4A1><C4B2><EFBFBD><EFBFBD>¹̼<C2B9><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġ<C4A1>*/
/*<2A>šŻ<C5A1>ȡ<EFBFBD>¹̼<C2B9><CCBC>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1>ʼ<EFBFBD>šššššššġššššššššššššššššššššššššššššššššššššššššššššššššššššššššš<C5A1>*/
sDownApp.fileSize = Ftp_Get_FileSize( sDownApp.fileName ) ; //<2F><>ȡ<EFBFBD>¹̼<C2B9><CCBC>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С
if( sDownApp.fileSize <= 0 ) /*<2A><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Сʧ<D0A1><CAA7>*/
{
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD><EFBFBD>ȡ<EFBFBD>¹̼<EFBFBD><EFBFBD><EFBFBD>Сʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תRunAppNum: APP%c<><63>", uIapFlash.sIapFlash.RunAppNum) ;
goto APPNUMOUT ; //<2F><>ת<EFBFBD><D7AA>RunAppNum<75><6D>ִ<EFBFBD><D6B4>ԭ<EFBFBD>ȵij<C8B5><C4B3><EFBFBD>
}
sDownApp.subPackSum = sDownApp.fileSize/ONCE_DOWN_LEN ;
if( sDownApp.fileSize%ONCE_DOWN_LEN > 0 )
sDownApp.subPackSum = sDownApp.subPackSum + 1 ; //<2F><><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>subPackSum
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD>¹̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С %d bytes ; <20><><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>Ŀ: %d <20><>",sDownApp.fileSize, sDownApp.subPackSum) ;
/*<2A>ġĻ<C4A1>ȡ<EFBFBD>¹̼<C2B9><CCBC>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>ġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġ<C4A1>*/
/*<2A>š<EFBFBD><C5A1>¹̼<C2B9><CCBC>Ϸ<EFBFBD><CFB7><EFBFBD>У<EFBFBD>ʼ<E9BFAA>šššššššġššššššššššššššššššššššššššššššššššššššššššššššššššššššššš<C5A1>*/
int headPos = -1 ;
result = DownSubpackVerify(&sDownApp, &headPos) ; //<2F><><EFBFBD>ص<EFBFBD>һ<EFBFBD><D2BB>subpack<63><6B><EFBFBD><EFBFBD><EFBFBD>й̼<D0B9><CCBC>Ϸ<EFBFBD><CFB7><EFBFBD>У<EFBFBD><D0A3>
if( RUNERR == result ) /*<2A>̼<EFBFBD>У<EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>*/
{
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD>¹̼<EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַУ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>") ;
// char *newName = (char*)portMalloc(MAC_BYTES_LEN*2) ;
// strncat( (char*)newName, (const char*)sDownApp.fileName, 2) ;
// strncat( (char*)newName, "(BinErr)", 8) ;
// strncat( (char*)newName, (const char*)&sDownApp.fileName[2], 26) ;
// Wait_For_Nms(2000) ; //<2F><>ʱ2S<32><53><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><E2B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B7B5>+CME ERROR: 603<30><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Ftp_File_Rename( sDownApp.fileName , (uint8_t *)newName ) ; //<2F>Բ<EFBFBD><D4B2>Ϸ<EFBFBD><CFB7>Ĺ̼<C4B9><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD> <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// portFree(newName) ;
goto APPNUMOUT ; // <20><>ת<EFBFBD><D7AA>RunAppNum<75><6D>ִ<EFBFBD><D6B4>ԭ<EFBFBD>ȵij<C8B5><C4B3><EFBFBD>
}
else if( TIMEOUT == result ) /*<2A>̼<EFBFBD>У<EFBFBD><D0A3>ʧ<EFBFBD><CAA7>*/
{
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD>¹̼<EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַУ<EFBFBD>鳬ʱ<EFBFBD><EFBFBD>") ;
Wait_For_Nms(50) ; //<2F><>ʱ2S<32><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
goto APPNUMOUT ; // <20><>ת<EFBFBD><D7AA>RunAppNum<75><6D>ִ<EFBFBD><D6B4>ԭ<EFBFBD>ȵij<C8B5><C4B3><EFBFBD>
}
/*<2A>ġ<EFBFBD><C4A1>¹̼<C2B9><CCBC>Ϸ<EFBFBD><CFB7><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġ<C4A1>*/
/*<2A>š<EFBFBD><C5A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹̼<C2B9><CCBC><EFBFBD>дFLASH <20><>ʼ<EFBFBD>šššššššġššššššššššššššššššššššššššššššššššššššššššššššššššššššššš<C5A1>*/
// OledPrintf(LINE_LEFT, HIGH_16, LINE3, false, "<22><><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>:%d", sDownApp.subPackSum) ;
// OledPrintf(LINE_LEFT, HIGH_16, LINE4, false, "<22><><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD>:1" ) ;
Erase_App_Area(sDownApp.appFlashAddr) ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>µĴ<C2B5><C4B4><EFBFBD>д<EFBFBD><D0B4>FLASH<53><48><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>APP<50><50><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><D0B4>FLASH<53><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ת<EFBFBD><D7AA>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>1 <20><><EFBFBD><EFBFBD><EFBFBD>سɹ<D8B3><C9B9><EFBFBD>") ;
if( RUNOK == Write_Flash(sDownApp.appFlashAddr, (uint8_t*)(ec20FtpBuf+headPos), ONCE_DOWN_LEN)) /*дFLASH<53>ɹ<EFBFBD>*///<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>subpack1д<31><D0B4>falsh<73><68>
{
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>1 <20><>д<EFBFBD><D0B4>FLASH<53>ɹ<EFBFBD><C9B9><EFBFBD>") ;
}
else /*subpack1д<31><D0B4>FLASHʧ<48><CAA7>*/
{
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD>1 <20><>д<EFBFBD><D0B4>FLASHʧ<48>ܣ<EFBFBD><DCA3><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
goto SAVEAPPOUT ; //<2F><>ת<EFBFBD><D7AA>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
result = DownOtherSubpack(&sDownApp) ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>subpack
if( RUNOK != result ) //<2F><><EFBFBD><EFBFBD>subpack<63><6B><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
{
Erase_App_Area(sDownApp.appFlashAddr) ; //<2F>̼<EFBFBD>д<EFBFBD><D0B4>FLSHAʧ<41>ܣ<EFBFBD><DCA3><EFBFBD>APP<50><50><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>FLASH<53><48>
Wait_For_Nms(50) ; //<2F><>ʱ2S<32><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
goto SAVEAPPOUT ; //<2F><>תӦ<D7AA><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
else /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>subpack<63>̼<EFBFBD><CCBC><EFBFBD><EFBFBD>سɹ<D8B3><C9B9><EFBFBD>д<EFBFBD><D0B4>flash<73>ɹ<EFBFBD>*/
{
// if( sDownApp.eAppType == SelfApp) /*Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>APP<50>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>޸<EFBFBD><DEB8>ļ<EFBFBD><C4BC><EFBFBD>*/
// {
// char *newName = (char*)portMalloc(MAC_BYTES_LEN*2) ;
// strncat( (char*)newName, (const char*)sDownApp.fileName, 2) ;
// strncat( (char*)newName, "(BinOk)", 8) ;
// strncat( (char*)newName, (const char*)&sDownApp.fileName[2], 26) ;
// Wait_For_Nms(2000) ; //<2F><>ʱ2S<32><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
// Ftp_File_Rename( sDownApp.fileName , (uint8_t *)newName ) ;//<2F><><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9>Ĺ̼<C4B9><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD> <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// portFree(newName) ;
// }
goto NEWAPPOUT ; //<2F><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صĹ̼<C4B9><CCBC><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>APP
}
/*<2A>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹̼<C2B9><CCBC><EFBFBD>дFLASH <20><><EFBFBD><EFBFBD><EFBFBD>ġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġġ<C4A1>*/
APPNUMOUT:
appAddr = QueryNewAppArea((u32)uIapFlash.sIapFlash.RunAppNum); //У<><D0A3><EFBFBD>̼<EFBFBD><CCBC>Ϸ<EFBFBD><CFB7>ԡ<EFBFBD><D4A1><EFBFBD>ȡ<EFBFBD><C8A1>ת<EFBFBD><D7AA>FLASH<53><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
NetDisconnetc() ; //<2F>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>ע<EFBFBD><D7A2>FTP<54><50>½
Iap_Load_App(appAddr) ; //ִ<><D6B4>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>
NEWAPPOUT:
uIapFlash.sIapFlash.IapFlag = 0x30 ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
Set_uIapFlash(&uIapFlash) ;
appAddr = QueryNewAppArea(sDownApp.appFlashAddr); //У<><D0A3><EFBFBD>̼<EFBFBD><CCBC>Ϸ<EFBFBD><CFB7>ԡ<EFBFBD><D4A1><EFBFBD>ȡ<EFBFBD><C8A1>ת<EFBFBD><D7AA>FLASH<53><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
NetDisconnetc() ; //<2F>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>ע<EFBFBD><D7A2>FTP<54><50>½
Iap_Load_App(appAddr) ; //ִ<><D6B4>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>
SAVEAPPOUT:
appAddr = QueryNewAppArea(SAVEAPP_AREA_ADDR); //У<><D0A3><EFBFBD>̼<EFBFBD><CCBC>Ϸ<EFBFBD><CFB7>ԡ<EFBFBD><D4A1><EFBFBD>ȡ<EFBFBD><C8A1>ת<EFBFBD><D7AA>FLASH<53><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
NetDisconnetc() ; //<2F>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>ע<EFBFBD><D7A2>FTP<54><50>½
Iap_Load_App(SAVEAPP_AREA_ADDR) ; //ִ<><D6B4>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>
DisplayTitle("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:") ;
DisplayInfo("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
Wait_For_Nms(50) ; //<2F><><EFBFBD><EFBFBD><EFBFBD>ϳ<EFBFBD><CFB3>򲻿<EFBFBD><F2B2BBBF><EFBFBD>ִ<EFBFBD>е<EFBFBD><D0B5>˴<EFBFBD>
SystemSoftReset() ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
RunResult NetTask(void)
{
RunResult runResult = TIMEOUT ; //RunResult<6C><74><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD>ִ<EFBFBD>н<EFBFBD><D0BD><EFBFBD>
int tryTimes = 2 ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
while( tryTimes >= 0 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
tryTimes-- ;
if( MODULEBIT_0 == false ) /*EC20û<30><C3BB>module<6C><65>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>ִ<EFBFBD><D6B4>*/
{
runResult = EC20_Module_Init() ; //<2F><>Ҫ<EFBFBD><D2AA>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹر<D2B9>ģ<EFBFBD><EFBFBD><E9B4AE>ECHO<48>ɹ<EFBFBD>
if( RUNOK == runResult) /*ģ<><C4A3>UART \gpio\POW\ECHO\RELESE<53><45><EFBFBD><EFBFBD><EFBFBD>쳣*/
{
MODULEBIT_0 = true ; //<2F>޸<EFBFBD>MODULEBIT_0״̬<D7B4><CCAC>־λ
AppLogPrintf("<EFBFBD><EFBFBD><EFBFBD>ֳɹ<EFBFBD>") ;
}
else /*EC20_Module_Init<69><74>ʼ<EFBFBD><CABC>ʧ<EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD>EC20_Module_Init()*/
{
AppLogPrintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>") ;
}
}
if( (MODULEBIT_0 == true) &&
(NETREGBIT_1 == false) ) //EC20module<6C><65>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>CSPS<50><53>ʼ<EFBFBD><CABC>δ<EFBFBD><CEB4><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CS<43><53>PS<50><53>ʼ<EFBFBD><CABC>
{
char *errInfo = portMalloc(30) ;
runResult = EC20_Net_Reg(errInfo, 30) ; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӫ<EFBFBD>̺<EFBFBD><CCBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CS SERVER<45><52>PS SERVER
if( RUNOK == runResult) /*EC20_Net_Reg<65><67>SIM/CS/PS<50><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣*/
{
NETREGBIT_1 = true ; //<2F>޸<EFBFBD>NETREGBIT_1״̬<D7B4><CCAC>־λ
}
else /*1<><31>EC20_Net_Reg<65><EFBFBD><ECB3A3><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>½<EFBFBD><C2BD><EFBFBD>EC20_Module_Init; 2<><32>ģ<EFBFBD><C4A3><EFBFBD>ػ<EFBFBD>*/
{
MODULEBIT_0 = false ; //<2F><><EFBFBD><EFBFBD>MODULEBIT_0״̬λΪʧ<CEAA><CAA7>
EC20_CLOSE() ; //EC20<32>ػ<EFBFBD>
}
AppLogPrintf(errInfo) ; //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SIM<49><4D><EFBFBD><EFBFBD>SIMǷ<4D>ѡ<EFBFBD>CSQ
portFree(errInfo) ;
}
if( (MODULEBIT_0 == true) &&
(NETREGBIT_1 == true) &&
(TCPBIT_2 == false) ) /*EC20module<6C><65>EC20_Net_Reg<65><67>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AppTcpInit<69><74>ʼ<EFBFBD><CABC>*/
{
runResult = AppTcpInit() ; //TCP PDP<44><50>ʼ<EFBFBD><CABC> SOCKET<45><54><EFBFBD><EFBFBD>
if( RUNOK == runResult) /*TCP<43><50><EFBFBD>ӳɹ<D3B3>*/
{
TCPBIT_2 =true ; //<2F><><EFBFBD><EFBFBD>TCP<43><50><EFBFBD><EFBFBD>״̬<D7B4><CCAC>־λTCPBIT_2 STATE_OK
TcpUpdata( BOOTTOTCPFRAME, "Device tcp connetced!") ; //<2F>ϴ<EFBFBD>TCP<43><50><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>б<EFBFBD>
AppLogPrintf("TCP<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>") ;
}
else /*TCP<43><50><EFBFBD><EFBFBD>ʧ<EFBFBD>ܲ<EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TCP<43>쳣ֻ<ECB3A3><D6BB><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3><EFBFBD><EFBFBD>*/
{
TCPBIT_2 = false ; //<2F><><EFBFBD><EFBFBD>TCP<43><50><EFBFBD><EFBFBD>״̬<D7B4><CCAC>־λ STATE_ERR
AppLogPrintf("TCP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>") ;
}
}
if( (MODULEBIT_0 == true) &&
(NETREGBIT_1 == true) &&
(FTPBIT_4 == false) ) /*EC20module<6C><65>EC20_Net_Reg<65><67>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AppFtpInit<69><74>ʼ<EFBFBD><CABC>*/
{
DisplayTitle("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:") ;
runResult = AppFtpInit() ; //FTP<54><50>ʼ<EFBFBD><CABC>
if( RUNOK == runResult) //FTP<54><50><EFBFBD>ӳɹ<D3B3>
{
FTPBIT_4 =true ; //<2F><><EFBFBD><EFBFBD>FTP<54><50><EFBFBD><EFBFBD>״̬<D7B4><CCAC>־λFTPBIT_4 STATE_OK
AppLogPrintf("FTP<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>") ;
break ;
}
else
{
FTPBIT_4 = false ; //<2F><><EFBFBD><EFBFBD>FTP<54><50><EFBFBD><EFBFBD>״̬<D7B4><CCAC>־λ STATE_ERR
AppLogPrintf("FTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>") ;
}
}
}
if( (MODULEBIT_0 == true) &&
(NETREGBIT_1 == true) &&
(FTPBIT_4 == true ) ) /*EC20module<6C><65>EC20_Net_Reg<65><67>AppFtpInitȫ<74><C8AB><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>TCPֻ<50><D6BB><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>־<EFBFBD><D6BE>AppTcpInit<69><74>ʼ<EFBFBD><CABC>ʧ<EFBFBD>ܲ<EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
{
runResult = RUNOK ;
EC20_Query_CSQ(sEc20Param.csq) ; //<2F><>ȡCSQ<53><51>ֵ
EC20_Query_Voltage(sEc20Param.ec20Voltage) ; //<2F><>ȡEC20<32><30>ѹֵ
// DisplayStatusBar() ; //״̬<D7B4><CCAC><EFBFBD><EFBFBD>ʾ<EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ѹ
}
else /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣*/
{
runResult = RUNERR ;
}
return (runResult) ;
}