|
@@ -51,7 +51,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
|
(void)pvParameters;
|
|
|
uint32 SendTimerCounter = 0;
|
|
|
uint32 RecvTimerDelay = 0;
|
|
|
- uint8 UartRecvPtr[200];
|
|
|
+ uint8 UartRecvPtr[256];
|
|
|
volatile uint16 tcpErrorCounter = 0;
|
|
|
uint16 pReadLen = 0;
|
|
|
// 4G开机
|
|
@@ -174,20 +174,13 @@ void Uart_4G_Task(void *pvParameters)
|
|
|
{
|
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
|
tcpErrorCounter++;
|
|
|
- if(tcpErrorCounter>60)//无法驻网或者联网,重置4G模组
|
|
|
+ if(tcpErrorCounter>60&&TcpSysReboot == 1)//无法驻网或者联网
|
|
|
{
|
|
|
- Dio_WriteChannel(DioConf_DioChannel_PTD3_GPIO_OUT_MCU_4G_RESET, STD_ON);
|
|
|
+ Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, 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;
|
|
|
+ Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(2500));
|
|
|
+ SystemSoftwareReset();
|
|
|
}
|
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
|
|
|
break;
|
|
@@ -310,9 +303,10 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
|
|
|
// memcpy(WebSiteIp ,ATCmdSend,strlen(ATCmdSend));
|
|
|
// WebSitePort = 14401;
|
|
|
/**/
|
|
|
- sprintf(AtCmdSend, "%d,\"TCP\",%s,%d\r\n", *ConnectId, WebSiteIp, WebSitePort); //此处需要优化
|
|
|
+ sprintf(AtCmdSend, "AT+CIPOPEN=%d,\"TCP\",%s,%d\r\n", *ConnectId, WebSiteIp, WebSitePort); //此处需要优化
|
|
|
AtCmdSendTotalLen = mstrlen(AtCmdSend);
|
|
|
- AtcmdTransmit(AT_CONNECT, (uint8 *)AtCmdSend, AtCmdSendTotalLen, &ATRet,10000);
|
|
|
+ UART_Send_Data(UART_LPUART1, AtCmdSend, AtCmdSendTotalLen, pdMS_TO_TICKS(100));
|
|
|
+ ATRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CIPOPEN: 0,0"),20000);
|
|
|
if (ATRet == 0)
|
|
|
{
|
|
|
ConnectStep++;
|
|
@@ -450,7 +444,7 @@ void InitFunc(void)
|
|
|
{
|
|
|
ATCmdSend = (char *)("AT+SIMEI?\r\n");
|
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
|
|
|
+ UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
|
|
|
if (ReadLen > 0)
|
|
|
{
|
|
|
retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("+SIMEI"));
|
|
@@ -474,7 +468,7 @@ void InitFunc(void)
|
|
|
{
|
|
|
ATCmdSend = (char *)("AT+CTZU=1\r\n");
|
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
|
- UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
|
|
|
+ UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
|
|
|
if (ReadLen > 0)
|
|
|
{
|
|
|
retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("OK"));
|
|
@@ -531,20 +525,18 @@ void InitFunc(void)
|
|
|
static void AtcmdTransmit(sint8 CmdIdx, uint8 *SetValuePtr, uint16 SetValueLen, sint8 *retFunc,uint16 timeout)
|
|
|
{
|
|
|
uint16 ReadLen = 0;
|
|
|
- uint8 *PtrATCmdSend = NULL;
|
|
|
+ uint8 PtrATCmdSend[64];
|
|
|
uint8 ATCmdFixedLen = 0;
|
|
|
uint16 ATCmdTotalLen = 0;
|
|
|
- uint8 UartRecvPtr[100];
|
|
|
+ uint8 UartRecvPtr[256];
|
|
|
ATCmdFixedLen = mstrlen(Atcmdfunc[CmdIdx].str);
|
|
|
ATCmdTotalLen = ATCmdFixedLen + SetValueLen;
|
|
|
- PtrATCmdSend = malloc(ATCmdTotalLen + 1);
|
|
|
memset(PtrATCmdSend, 0x00, ATCmdTotalLen + 1);
|
|
|
memcpy(PtrATCmdSend, Atcmdfunc[CmdIdx].str, ATCmdFixedLen);
|
|
|
if (SetValuePtr != NULL)
|
|
|
{
|
|
|
- memcpy(PtrATCmdSend + ATCmdFixedLen, SetValuePtr, SetValueLen);
|
|
|
+ memcpy(&PtrATCmdSend[ATCmdFixedLen], SetValuePtr, SetValueLen);
|
|
|
}
|
|
|
-
|
|
|
UART_Query_Data(UART_LPUART1, UART_LPUART1, PtrATCmdSend, ATCmdTotalLen, UartRecvPtr, &ReadLen, timeout);
|
|
|
if(ReadLen>0)
|
|
|
{
|
|
@@ -554,11 +546,6 @@ static void AtcmdTransmit(sint8 CmdIdx, uint8 *SetValuePtr, uint16 SetValueLen,
|
|
|
{
|
|
|
*retFunc = -1;
|
|
|
}
|
|
|
- if (PtrATCmdSend != NULL)
|
|
|
- {
|
|
|
- free(PtrATCmdSend);
|
|
|
- }
|
|
|
- PtrATCmdSend = NULL;
|
|
|
return;
|
|
|
}
|
|
|
sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pReadLen)
|
|
@@ -696,6 +683,7 @@ sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pRead
|
|
|
}
|
|
|
void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
|
{
|
|
|
+ UTC8TimeType UTC8TimeTcp;
|
|
|
uint8 DataIdx = 0;
|
|
|
static uint32 TcpSendTimeCounter = 0;
|
|
|
TcpSendTimeCounter++;
|
|
@@ -730,7 +718,6 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
|
DataIdx = 0; //不发送,返回
|
|
|
return;
|
|
|
}
|
|
|
- UTC8TimeType UTC8TimeTcp;
|
|
|
GetUtc8Time(&UTC8TimeTcp); //时间获取
|
|
|
uint8 *SendBuffer = NULL;
|
|
|
switch (DataIdx)
|
|
@@ -1101,7 +1088,7 @@ void GetUtc8Time(UTC8TimeType *UTC8TimeTcp)
|
|
|
uint8 AtCmdLen = mstrlen(AtCmdAsk);
|
|
|
uint8 ReadLen = 0;
|
|
|
uint8 *retptr = NULL;
|
|
|
- uint8 UartRecvPtr[30];
|
|
|
+ uint8 UartRecvPtr[128];
|
|
|
UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdAsk, AtCmdLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
|
|
|
if (ReadLen > 0)
|
|
|
{
|
|
@@ -1370,6 +1357,9 @@ sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDat
|
|
|
outValue = -1;
|
|
|
sendErrConuter++;
|
|
|
}
|
|
|
+#if SEGGER_PRINTF==1
|
|
|
+ SEGGER_RTT_printf("[%d]outValue=%d,sendErrConuter=%d\r\n",__LINE__,outValue,sendErrConuter);
|
|
|
+#endif
|
|
|
}
|
|
|
return outValue;
|
|
|
}
|