|
@@ -47,10 +47,11 @@ static void GetCSQValue(uint8 *out);
|
|
|
void Fota_Ftp(uint8 *dataPtrIn);
|
|
|
void tcpUdsFunc(uint8 *Ptr,uint8 *AnsPtr);
|
|
|
static void vTimer1000msCallback(TimerHandle_t pxTimer);
|
|
|
+bool SendTimerFlg = false;
|
|
|
+static uint32 TcpSendTimeCounter = 0;
|
|
|
void Uart_4G_Task(void *pvParameters)
|
|
|
{
|
|
|
(void)pvParameters;
|
|
|
- uint32 SendTimerCounter = 0;
|
|
|
uint32 RecvTimerDelay = 0;
|
|
|
uint8 UartRecvPtr[512];
|
|
|
volatile uint16 tcpErrorCounter = 0;
|
|
@@ -66,7 +67,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
|
_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
|
|
|
InitFunc(); // 4G模块初始化,注:AT同步不通过,没有进行次数判定及跳转
|
|
|
TimerHandle_t monitorTimer1000ms;
|
|
|
- monitorTimer1000ms = xTimerCreate("monitor1ms",1,pdTRUE,(void *)0,vTimer1000msCallback);
|
|
|
+ monitorTimer1000ms = xTimerCreate("monitor1000ms",1000,pdTRUE,(void *)0,vTimer1000msCallback);
|
|
|
xTimerStart(monitorTimer1000ms,0);
|
|
|
for (;;)
|
|
|
{
|
|
@@ -84,15 +85,12 @@ void Uart_4G_Task(void *pvParameters)
|
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_RECV);
|
|
|
RecvTimerDelay = TimerCounter;
|
|
|
}
|
|
|
- else if (AppConfigInfo.eolFlg == 1 && (TimerCounter - SendTimerCounter) >= 1000 && TcpWorkState==0)
|
|
|
+ else if (AppConfigInfo.eolFlg == 1 && TcpWorkState==0 && SendTimerFlg==true)
|
|
|
{
|
|
|
-#if SEGGER_PRINTF==1
|
|
|
- SEGGER_RTT_printf("[%d] SendTimerCounter=%d\r\n",__LINE__,SendTimerCounter);
|
|
|
-#endif
|
|
|
- SendTimerCounter = TimerCounter;
|
|
|
+ SendTimerFlg = false;
|
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_SEND);
|
|
|
}
|
|
|
- if((TimerCounter-RecvTimerDelay)>=10000 && TcpWorkState==1)//10s内没有命令下发,进行正常发送任务
|
|
|
+ if((TimerCounter-RecvTimerDelay)>=30000 && TcpWorkState==1)//10s内没有命令下发,进行正常发送任务
|
|
|
{
|
|
|
TcpWorkState = 0;
|
|
|
}
|
|
@@ -199,13 +197,17 @@ static void vTimer1000msCallback(TimerHandle_t pxTimer)
|
|
|
{
|
|
|
uint32 ulTimerID;
|
|
|
ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
|
|
|
+ if(ulTimerID==0)
|
|
|
+ {
|
|
|
+ SendTimerFlg = true;
|
|
|
+ TcpSendTimeCounter++;
|
|
|
+ }
|
|
|
}
|
|
|
sint8 TcpDataSendFunc(sint8 ConnectId)
|
|
|
{
|
|
|
sint8 outValue = -1;
|
|
|
uint32 pSendDataAddr = 0;
|
|
|
uint16 DataSendLen = 0;
|
|
|
- memcpy(TcpbattSN, AppConfigInfo.deviceSn, 17);
|
|
|
TcpDataEncode(&pSendDataAddr, &DataSendLen); //数据组包,malloc申请在里面,pSendData指向申请的地址
|
|
|
if (DataSendLen == 0)
|
|
|
{
|
|
@@ -698,9 +700,9 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
|
static UTC8TimeType UTC8TimeTcp;
|
|
|
uint8 *SendBuffer = NULL;
|
|
|
uint8 DataIdx = 0;
|
|
|
- static uint32 TcpSendTimeCounter = 0;
|
|
|
- TcpSendTimeCounter++;
|
|
|
-
|
|
|
+#if SEGGER_PRINTF==1
|
|
|
+ SEGGER_RTT_printf("[%d] TcpSendTimeCounter -%d\r\n",__LINE__,TcpSendTimeCounter);
|
|
|
+#endif
|
|
|
if (TcpSendTimeCounter == 1)
|
|
|
{
|
|
|
DataIdx = VerMsg; //版本信息发送
|
|
@@ -731,6 +733,10 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
|
DataIdx = 0; //不发送,返回
|
|
|
return;
|
|
|
}
|
|
|
+#if SEGGER_PRINTF==1
|
|
|
+ SEGGER_RTT_printf("[%d] DataIdx -%d\r\n",__LINE__,DataIdx);
|
|
|
+#endif
|
|
|
+ memcpy(TcpbattSN, AppConfigInfo.deviceSn, 17);
|
|
|
GetUtc8Time(&UTC8TimeTcp); //时间获取
|
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
|
switch (DataIdx)
|
|
@@ -1355,7 +1361,7 @@ sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDat
|
|
|
AtCmdSendTotalLen = mstrlen(AtCmdSend);
|
|
|
while(outValue!=0&&sendErrConuter<3)
|
|
|
{
|
|
|
- ret = UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdSend, AtCmdSendTotalLen, UartRecvPtr, &ReadLen, 5000);
|
|
|
+ ret = UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdSend, AtCmdSendTotalLen, UartRecvPtr, &ReadLen, 1000);
|
|
|
if (((ret==0)&&(ReadLen>0)&&((uint8 *)strstr((char *)UartRecvPtr, (char *)(">"))))||1)//此IF条件默认通过
|
|
|
{
|
|
|
UART_Send_Data(UART_LPUART1, (uint8 *)SendDataPtr, SendDataLen, 1000);
|