|
@@ -44,24 +44,26 @@ void GetUtc8Time(UTC8TimeType *UTC8TimeTcp);
|
|
|
static void AtcmdTransmit(sint8 CmdIdx, uint8 *SetValuePtr, uint16 SetValueLen, sint8 *retFunc,uint16 timeout);
|
|
|
static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen);
|
|
|
static void GetCSQValue(uint8 *out);
|
|
|
-void Fota_Ftp(void);
|
|
|
+void Fota_Ftp(uint8 *dataPtrIn);
|
|
|
void tcpUdsFunc(Ptr,TcpCmdAnswer);
|
|
|
void Uart_4G_Task(void *pvParameters)
|
|
|
{
|
|
|
(void)pvParameters;
|
|
|
+ uint32 SendTimerCounter = 0;
|
|
|
+ uint32 RecvTimerDelay = 0;
|
|
|
+ uint8 *UartRecvPtr=NULL;
|
|
|
+ volatile uint16 tcpErrorCounter = 0;
|
|
|
+ uint16 pReadLen = 0;
|
|
|
// 4G开机
|
|
|
+ Dio_LevelType _4G_Status = 0; // 0-关机,1-开机
|
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(50));
|
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
|
|
|
- Dio_LevelType _4G_Status = 0; // 0-关机,1-开机
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(50));
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(10000));
|
|
|
+ Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
|
|
|
_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
|
|
|
- // LED测试
|
|
|
- Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
|
|
|
- vTaskDelay(pdMS_TO_TICKS(5000));
|
|
|
- uint16 pReadLen = 0;
|
|
|
InitFunc(); // 4G模块初始化,注:AT同步不通过,没有进行次数判定及跳转
|
|
|
- uint32 SendTimerCounter = 0;
|
|
|
- uint32 RecvTimerDelay = 0;
|
|
|
- uint8 *UartRecvPtr=NULL;
|
|
|
for (;;)
|
|
|
{
|
|
|
switch (gProcess_Tcp_Task)
|
|
@@ -140,6 +142,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
|
if (SendRet == 0)
|
|
|
{
|
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
|
|
|
+ tcpErrorCounter = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -175,10 +178,24 @@ void Uart_4G_Task(void *pvParameters)
|
|
|
}
|
|
|
case PROCESS_TCP_ERROR: //错误状态
|
|
|
{
|
|
|
-// Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
|
|
|
-// vTaskDelay(pdMS_TO_TICKS(100));
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(1000));
|
|
|
+ tcpErrorCounter++;
|
|
|
+ if(tcpErrorCounter>60)//无法驻网或者联网,重置4G模组
|
|
|
+ {
|
|
|
+ Dio_WriteChannel(DioConf_DioChannel_PTD3_GPIO_OUT_MCU_4G_RESET, STD_ON);
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(2500));
|
|
|
+ Dio_WriteChannel(DioConf_DioChannel_PTD3_GPIO_OUT_MCU_4G_RESET, STD_OFF);
|
|
|
+ _4G_Status = 0;
|
|
|
+ tcpErrorCounter = 0;
|
|
|
+ while(_4G_Status!=1&&tcpErrorCounter<60)
|
|
|
+ {
|
|
|
+ tcpErrorCounter++;
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(500));
|
|
|
+ _4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
|
|
|
+ }
|
|
|
+ tcpErrorCounter = 0;
|
|
|
+ }
|
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
|
|
|
-// Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -721,27 +738,27 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
|
static uint32 TcpSendTimeCounter = 0;
|
|
|
TcpSendTimeCounter++;
|
|
|
|
|
|
- if (TcpSendTimeCounter%60 == 0)
|
|
|
+ if (TcpSendTimeCounter%60 == 1)
|
|
|
{
|
|
|
DataIdx = VerMsg; //版本信息发送
|
|
|
}
|
|
|
- else if (TcpSendTimeCounter % 10 == 0)
|
|
|
+ else if (TcpSendTimeCounter % 10 == 1)
|
|
|
{
|
|
|
DataIdx = BattMsg; //电池信息发送
|
|
|
}
|
|
|
- else if ((TcpSendTimeCounter+1) % 10 == 0)
|
|
|
+ else if ((TcpSendTimeCounter) % 10 == 2)
|
|
|
{
|
|
|
DataIdx = 0x83; //储能开关信息发送
|
|
|
}
|
|
|
- else if ((TcpSendTimeCounter+2) % 240 == 0)
|
|
|
+ else if ((TcpSendTimeCounter) % 240 == 3)
|
|
|
{
|
|
|
DataIdx = GpsMsg; //定位信息发送
|
|
|
}
|
|
|
- else if ((TcpSendTimeCounter+3) % 240 == 0)
|
|
|
+ else if ((TcpSendTimeCounter) % 240 == 4)
|
|
|
{
|
|
|
DataIdx = 0x93; //储能电量信息发送
|
|
|
}
|
|
|
- else if ((TcpSendTimeCounter+4) % 60 == 0)
|
|
|
+ else if ((TcpSendTimeCounter) % 60 == 5)
|
|
|
{
|
|
|
DataIdx = 0x8A; //累计信息发送
|
|
|
}
|
|
@@ -1226,7 +1243,15 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
|
|
|
TcpCmdAnswer[2] = TCP_CONCMD_SYM;
|
|
|
if (*(Ptr + 30) == 0x83) //远程升级指令
|
|
|
{
|
|
|
- Fota_Ftp();
|
|
|
+ TcpCmdAnswer[3] = 0x01;
|
|
|
+ memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
|
|
|
+ TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
|
|
|
+ TcpCmdAnswer[22] = 0x00;
|
|
|
+ TcpCmdAnswer[23] = 0x06;
|
|
|
+ memcpy(&TcpCmdAnswer[24], (Ptr + 24), 6);
|
|
|
+ TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer, 30);
|
|
|
+ tcpipConnectionSend(SocketId, TcpCmdAnswer, 31);
|
|
|
+ Fota_Ftp(Ptr + 32);
|
|
|
}
|
|
|
else if (*(Ptr + 30) == 0x80) //远程锁定命令
|
|
|
{
|
|
@@ -1287,7 +1312,6 @@ void tcpUdsFunc(uint8 *Ptr,uint8 *AnsPtr)
|
|
|
uint16 DIDBuffer = 0;
|
|
|
uint8 udsType_SID = 0;
|
|
|
uint8 DataBuffer[10];
|
|
|
- uint8 *DataBufferPtr = NULL;
|
|
|
contrlType = *(Ptr + 30);
|
|
|
udsDataLen = *(Ptr + 31);
|
|
|
udsType_SID = *(Ptr + 32);
|
|
@@ -1411,18 +1435,16 @@ sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDat
|
|
|
UartRecvPtr1 = NULL;
|
|
|
return outValue;
|
|
|
}
|
|
|
-void Fota_Ftp(void)
|
|
|
+void Fota_Ftp(uint8 *dataPtrIn)
|
|
|
{
|
|
|
- uint8 ftp_process = 0;
|
|
|
- uint8 ftp_EndFlg = 0;
|
|
|
- uint8 ftp_ErrCnt = 0;
|
|
|
+ static uint8 ftp_process = 0;
|
|
|
char *ATCmdSend = NULL;
|
|
|
- uint8 ATCmdSendLen = 0;
|
|
|
+ sint8 recvRet = -1;
|
|
|
char ATSendDataBuffer[100] = {0};
|
|
|
uint8 *UartRecvPtr = NULL;
|
|
|
uint16 ReadLen = 0;
|
|
|
uint8 *retptr = NULL;
|
|
|
- char temp[70]=",qx,qx900,120.27.243.131,21,0,0.0.1.5,0.0.1.5,/Debug/V0.0.1.5.bin,";
|
|
|
+// char temp[70]=",qx,qx900,120.27.243.131,21,0,0.0.1.5,0.0.1.5,/Debug/V0.0.1.5.bin,";
|
|
|
/*URL信息解析*/
|
|
|
char *databuffer[20];
|
|
|
char *accountPtr;
|
|
@@ -1433,8 +1455,9 @@ void Fota_Ftp(void)
|
|
|
char *filenamePtr;
|
|
|
char keyFilename[20]={0};
|
|
|
char *p = NULL;
|
|
|
- p = strtok(temp, ",");
|
|
|
+ p = strtok((char *)dataPtrIn, ",");
|
|
|
uint8 index = 0;
|
|
|
+ uint8 ftp_EndFlg = 0;
|
|
|
while (p)
|
|
|
{
|
|
|
databuffer[index] = p;
|
|
@@ -1461,190 +1484,104 @@ void Fota_Ftp(void)
|
|
|
while(!ftp_EndFlg)
|
|
|
{
|
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
|
- if(ftp_ErrCnt>5)
|
|
|
- {
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- ftp_EndFlg = 1;
|
|
|
- }
|
|
|
+#if UARTPRINTF==1
|
|
|
+ myPrintf("ftpProcess-%d",ftp_process);
|
|
|
+#endif
|
|
|
switch(ftp_process)
|
|
|
{
|
|
|
case 0://start
|
|
|
{
|
|
|
ATCmdSend = (char *)("AT+CFTPSSTART\r\n");
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
|
|
|
- if (ReadLen > 0)
|
|
|
+ UART_Send_Data(UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), pdMS_TO_TICKS(100));
|
|
|
+ recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSSTART: 0"),2000);
|
|
|
+ if(recvRet==0)
|
|
|
{
|
|
|
- retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("OK"));
|
|
|
- if (retptr)
|
|
|
- {
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- ftp_process++;
|
|
|
- }
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ftp_ErrCnt++;
|
|
|
- }
|
|
|
- if(UartRecvPtr != NULL)
|
|
|
- {
|
|
|
- free(UartRecvPtr);
|
|
|
+ ftp_EndFlg=1;
|
|
|
}
|
|
|
- UartRecvPtr = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case 1://login
|
|
|
{
|
|
|
- uint8 *UartData = NULL;
|
|
|
+ memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
|
|
|
sprintf(ATSendDataBuffer, "AT+CFTPSLOGIN=\"%s\",%s,\"%s\",\"%s\",0\r\n", ftpServerIpPtr, ftpServerPort,accountPtr,passwordPtr);
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
|
|
|
- while (1)
|
|
|
+ UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
|
|
|
+ recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSLOGIN: 0"),30000);
|
|
|
+ if(recvRet==0)
|
|
|
{
|
|
|
- UART_Receive_Data(UART_LPUART1,&UartData, &ReadLen,10000);
|
|
|
- retptr = (uint8 *)strstr((char *)UartData, (char *)("+CFTPSLOGIN: 0"));
|
|
|
- if (retptr)
|
|
|
- {
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- ftp_process++;
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ftp_ErrCnt++;
|
|
|
- }
|
|
|
- if(UartData != NULL)
|
|
|
- {
|
|
|
- free(UartData);
|
|
|
- }
|
|
|
- UartData = NULL;
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
- if(UartRecvPtr != NULL)
|
|
|
+ else
|
|
|
{
|
|
|
- free(UartRecvPtr);
|
|
|
+ ftp_EndFlg=1;
|
|
|
}
|
|
|
- UartRecvPtr = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case 2://transmit bin file from server to module
|
|
|
{
|
|
|
uint8 *UartData = NULL;
|
|
|
+ memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
|
|
|
sprintf(ATSendDataBuffer, "AT+CFTPSGETFILE=\"%s/%s\"\r\n", filePathPtr,filenamePtr);
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
|
|
|
- while (1)
|
|
|
+ UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
|
|
|
+ recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSGETFILE: 0"),10000);
|
|
|
+ if(recvRet==0)
|
|
|
{
|
|
|
- UART_Receive_Data(UART_LPUART1,&UartData, &ReadLen,10000);
|
|
|
- retptr = (uint8 *)strstr((char *)UartData, (char *)("+CFTPSGETFILE: 0"));
|
|
|
- if (retptr)
|
|
|
- {
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- ftp_process++;
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ftp_ErrCnt++;
|
|
|
- }
|
|
|
- if(ftp_ErrCnt>5)
|
|
|
- {
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- ftp_process++;
|
|
|
- break;
|
|
|
- }
|
|
|
- if(UartData != NULL)
|
|
|
- {
|
|
|
- free(UartData);
|
|
|
- }
|
|
|
- UartData = NULL;
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
- if(UartRecvPtr != NULL)
|
|
|
+ else
|
|
|
{
|
|
|
- free(UartRecvPtr);
|
|
|
+ ftp_EndFlg=1;
|
|
|
}
|
|
|
- UartRecvPtr = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case 3://transmit zl file from server to module
|
|
|
{
|
|
|
uint8 *UartData = NULL;
|
|
|
+ memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
|
|
|
sprintf(ATSendDataBuffer, "AT+CFTPSGETFILE=\"%s/%s\"\r\n", filePathPtr,keyFilename);
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
|
|
|
- while (1)
|
|
|
+ UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
|
|
|
+ recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSGETFILE: 0"),10000);
|
|
|
+ if(recvRet==0)
|
|
|
{
|
|
|
- UART_Receive_Data(UART_LPUART1,&UartData, &ReadLen,10000);
|
|
|
- retptr = (uint8 *)strstr((char *)UartData, (char *)("+CFTPSGETFILE: 0"));
|
|
|
- if (retptr)
|
|
|
- {
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- ftp_process++;
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ftp_ErrCnt++;
|
|
|
- }
|
|
|
- if(ftp_ErrCnt>5)
|
|
|
- {
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- ftp_process++;
|
|
|
- break;
|
|
|
- }
|
|
|
- if(UartData != NULL)
|
|
|
- {
|
|
|
- free(UartData);
|
|
|
- }
|
|
|
- UartData = NULL;
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
- if(UartRecvPtr != NULL)
|
|
|
+ else
|
|
|
{
|
|
|
- free(UartRecvPtr);
|
|
|
+ ftp_EndFlg=1;
|
|
|
}
|
|
|
- UartRecvPtr = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case 4://logout
|
|
|
{
|
|
|
ATCmdSend = (char *)("AT+CFTPSLOGOUT\r\n");
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
|
|
|
- if (ReadLen > 0)
|
|
|
+ UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
|
|
|
+ recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSLOGOUT: 0"),2000);
|
|
|
+ if(recvRet==0)
|
|
|
{
|
|
|
- retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("OK"));
|
|
|
- if (retptr)
|
|
|
- {
|
|
|
- ftp_process++;
|
|
|
- ftp_ErrCnt = 0;
|
|
|
- }
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ftp_ErrCnt++;
|
|
|
- }
|
|
|
- if(UartRecvPtr != NULL)
|
|
|
- {
|
|
|
- free(UartRecvPtr);
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
- UartRecvPtr = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case 5://stop
|
|
|
{
|
|
|
ATCmdSend = (char *)("AT+CFTPSSTOP\r\n");
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
|
|
|
- if (ReadLen > 0)
|
|
|
+ UART_Send_Data(UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), pdMS_TO_TICKS(100));
|
|
|
+ recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("CFTPSSTOP: 0"),2000);
|
|
|
+ if(recvRet==0)
|
|
|
{
|
|
|
- retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("OK"));
|
|
|
- if (retptr)
|
|
|
- {
|
|
|
- ftp_process++;
|
|
|
- }
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ftp_ErrCnt++;
|
|
|
- }
|
|
|
- if(UartRecvPtr != NULL)
|
|
|
- {
|
|
|
- free(UartRecvPtr);
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
- UartRecvPtr = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case 6://get data from module
|
|
@@ -1658,21 +1595,24 @@ void Fota_Ftp(void)
|
|
|
uint32 FlashAddStart = 0;
|
|
|
uint32 appReceviedCRC;
|
|
|
uint16 getDataLenErrCount = 0;
|
|
|
- sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\",0,6\r\n\r\n",keyFilename);
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartData, &ReadLen, pdMS_TO_TICKS(5000));
|
|
|
- if (ReadLen == (6+45))
|
|
|
+ memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
|
|
|
+ sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\"\r\n",keyFilename);
|
|
|
+ UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(5000));
|
|
|
+ if (ReadLen == (4+45))
|
|
|
{
|
|
|
retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("+CFTRANTX: DATA"));
|
|
|
if (retptr)
|
|
|
{
|
|
|
- fileLen = (*(retptr+22)<<24)|(*(retptr+23)<<16)|(*(retptr+24)<<8)|(*(retptr+25)<<0);
|
|
|
- appReceviedCRC = (*(retptr+20)<<8)|(*(retptr+21)<<0);
|
|
|
+ fileLen = (*(retptr+21)<<24)|(*(retptr+22)<<16)|(*(retptr+23)<<8)|(*(retptr+24)<<0);
|
|
|
+ appReceviedCRC = (*(retptr+19)<<8)|(*(retptr+20)<<0);
|
|
|
Hal_FlsGetAppVectorTableStartAddr(&FlashAddStart);
|
|
|
- Hal_FlsErase(FlashAddStart,fileLen + FLS_INTERNAL_WRITE_SIZE, 50);
|
|
|
+ Hal_OTAFlashAppInfoInit();
|
|
|
+ Hal_FlsErase(0,FlashAddStart + fileLen + FLS_INTERNAL_WRITE_SIZE, 100);
|
|
|
Hal_SetAppInfo(fileLen, appReceviedCRC, CONTROLLER_SELF);
|
|
|
while(readLenAsk!=0)
|
|
|
{
|
|
|
- sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\",%d,%d\r\n\r\n", filenamePtr,currentAddr, readLenAsk);
|
|
|
+ memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
|
|
|
+ sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\",%d,%d\r\n", filenamePtr,currentAddr, readLenAsk);
|
|
|
UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartData, &ReadLen, pdMS_TO_TICKS(5000));
|
|
|
sprintf(findDataBuffer, "+CFTRANTX: DATA,%d", readLenAsk);
|
|
|
if (ReadLen == (readLenAsk+45))
|
|
@@ -1702,20 +1642,35 @@ void Fota_Ftp(void)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(getDataLenErrCount<500&&Hal_FlsCheckIsTransferSucceed()==TRUE){
|
|
|
- Fota_update_flag = TRUE;
|
|
|
+ if(getDataLenErrCount<500&&Hal_FlsCheckIsTransferSucceed()==TRUE)
|
|
|
+ {
|
|
|
+ ftp_process++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ftp_ErrCnt++;
|
|
|
+ ftp_EndFlg = 1;
|
|
|
+ }
|
|
|
+ if(UartRecvPtr != NULL)
|
|
|
+ {
|
|
|
+ free(UartRecvPtr);
|
|
|
}
|
|
|
+ UartRecvPtr = NULL;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 7://delete the bin and zl files
|
|
|
+ {
|
|
|
+ memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
|
|
|
+ sprintf(ATSendDataBuffer, "AT+FSDEL=*.*\r\n");
|
|
|
+ UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(5000));
|
|
|
if(UartRecvPtr != NULL)
|
|
|
{
|
|
|
free(UartRecvPtr);
|
|
|
}
|
|
|
UartRecvPtr = NULL;
|
|
|
+ ftp_process++;
|
|
|
+ Fota_update_flag = TRUE;
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
@@ -1723,4 +1678,8 @@ void Fota_Ftp(void)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ if(ftp_process<6)
|
|
|
+ {
|
|
|
+ Fota_error_flag = 1;
|
|
|
+ }
|
|
|
}
|