|
@@ -9,8 +9,8 @@
|
|
*/
|
|
*/
|
|
/*
|
|
/*
|
|
* AppTaskUart2.c
|
|
* AppTaskUart2.c
|
|
- * 4GµÄ´®¿Úº¯Êý
|
|
|
|
- * Created on: 2022Äê2ÔÂ10ÈÕ
|
|
|
|
|
|
+ * 4G的串�函数
|
|
|
|
+ * Created on: 2022年2月10日
|
|
* Author: QiXiang_CHENJIE
|
|
* Author: QiXiang_CHENJIE
|
|
*/
|
|
*/
|
|
#include "AppTaskUart1.h"
|
|
#include "AppTaskUart1.h"
|
|
@@ -56,8 +56,8 @@ void Uart_4G_Task(void *pvParameters)
|
|
uint8 UartRecvPtr[512];
|
|
uint8 UartRecvPtr[512];
|
|
volatile uint16 tcpErrorCounter = 0;
|
|
volatile uint16 tcpErrorCounter = 0;
|
|
uint16 pReadLen = 0;
|
|
uint16 pReadLen = 0;
|
|
- // 4G¿ª»ú
|
|
|
|
- Dio_LevelType _4G_Status = 0; // 0-¹Ø»ú£¬1-¿ª»ú
|
|
|
|
|
|
+ // 4G开机
|
|
|
|
+ Dio_LevelType _4G_Status = 0; // 0-关机,1-开机
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
|
|
vTaskDelay(pdMS_TO_TICKS(50));
|
|
vTaskDelay(pdMS_TO_TICKS(50));
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
|
|
@@ -65,7 +65,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
AtcmdDelayRecvFunc(UART_LPUART1,(char *)("SMS DONE"),30000);
|
|
AtcmdDelayRecvFunc(UART_LPUART1,(char *)("SMS DONE"),30000);
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
|
|
_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
|
|
_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
|
|
- InitFunc(); // 4GÄ£¿é³õʼ»¯,×¢£ºATͬ²½²»Í¨¹ý£¬Ã»ÓнøÐдÎÊýÅж¨¼°Ìø×ª
|
|
|
|
|
|
+ InitFunc(); // 4G模å�—åˆ�始化,注:ATå�Œæ¥ä¸�通过,没有进行次数判定å�Šè·³è½¬
|
|
TimerHandle_t monitorTimer1000ms;
|
|
TimerHandle_t monitorTimer1000ms;
|
|
monitorTimer1000ms = xTimerCreate("monitor1000ms",1000,pdTRUE,(void *)0,vTimer1000msCallback);
|
|
monitorTimer1000ms = xTimerCreate("monitor1000ms",1000,pdTRUE,(void *)0,vTimer1000msCallback);
|
|
xTimerStart(monitorTimer1000ms,0);
|
|
xTimerStart(monitorTimer1000ms,0);
|
|
@@ -73,9 +73,9 @@ void Uart_4G_Task(void *pvParameters)
|
|
{
|
|
{
|
|
switch (gProcess_Tcp_Task)
|
|
switch (gProcess_Tcp_Task)
|
|
{
|
|
{
|
|
- case PROCESS_TCP_IDLE: //¿ÕÏÐ״̬
|
|
|
|
|
|
+ case PROCESS_TCP_IDLE: //空闲状�
|
|
{
|
|
{
|
|
- UART_Receive_Data(UART_LPUART1, UartRecvPtr, &pReadLen, 100);//100ms¼ì²â
|
|
|
|
|
|
+ UART_Receive_Data(UART_LPUART1, UartRecvPtr, &pReadLen, 100);//100ms检测
|
|
if (SocketId < 0)
|
|
if (SocketId < 0)
|
|
{
|
|
{
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_REGCHK);
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_REGCHK);
|
|
@@ -90,7 +90,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
SendTimerFlg = false;
|
|
SendTimerFlg = false;
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_SEND);
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_SEND);
|
|
}
|
|
}
|
|
- if((TimerCounter-RecvTimerDelay)>=30000 && TcpWorkState==1)//10sÄÚûÓÐÃüÁîÏ·¢£¬½øÐÐÕý³£·¢ËÍÈÎÎñ
|
|
|
|
|
|
+ if((TimerCounter-RecvTimerDelay)>=30000 && TcpWorkState==1)//10s内没有命令下å�‘,进行æ£å¸¸å�‘é€�任务
|
|
{
|
|
{
|
|
TcpWorkState = 0;
|
|
TcpWorkState = 0;
|
|
}
|
|
}
|
|
@@ -110,10 +110,10 @@ void Uart_4G_Task(void *pvParameters)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case PROCESS_TCP_REGCHK: //×¤Íø¼ì²é£¬°üÀ¨SIM£¬CPIN¼ì²é,ICCID»ñÈ¡
|
|
|
|
|
|
+ case PROCESS_TCP_REGCHK: //驻网检查,包括SIM,CPIN检查,ICCID获�
|
|
{
|
|
{
|
|
RegChkRet = TcpRegisterChkFunc();
|
|
RegChkRet = TcpRegisterChkFunc();
|
|
- if (RegChkRet > 0) //¼ì²éͨ¹ý£¬SIM¿¨ÒѾÍÐ÷£¬ÒѽøÐÐ×¤Íø
|
|
|
|
|
|
+ if (RegChkRet > 0) //检查通过,SIM�已就绪,已进行驻网
|
|
{
|
|
{
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_CONNECT);
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_CONNECT);
|
|
}
|
|
}
|
|
@@ -123,7 +123,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case PROCESS_TCP_CONNECT: //ÍøÂçÁ¬½Ó£¬°üÀ¨ÓòÃûת»»
|
|
|
|
|
|
+ case PROCESS_TCP_CONNECT: //网络连接,包括域�转�
|
|
{
|
|
{
|
|
if (SocketId < 0)
|
|
if (SocketId < 0)
|
|
{
|
|
{
|
|
@@ -140,7 +140,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case PROCESS_TCP_SEND: //ÍøÂçÊý¾Ý·¢ËÍ
|
|
|
|
|
|
+ case PROCESS_TCP_SEND: //网络数���
|
|
{
|
|
{
|
|
sint8 SendRet = -1;
|
|
sint8 SendRet = -1;
|
|
SendRet = TcpDataSendFunc(SocketId);
|
|
SendRet = TcpDataSendFunc(SocketId);
|
|
@@ -156,7 +156,7 @@ void Uart_4G_Task(void *pvParameters)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case PROCESS_TCP_RECV: //ÍøÂçÊý¾Ý½ÓÊÕ,100ms¿ÕÏÐ״̬ϼ´¿É½ÓÊÕ
|
|
|
|
|
|
+ case PROCESS_TCP_RECV: //网络数�接收,100ms空闲状�下��接收
|
|
{
|
|
{
|
|
Dio_FlipChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1);
|
|
Dio_FlipChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1);
|
|
|
|
|
|
@@ -167,19 +167,19 @@ void Uart_4G_Task(void *pvParameters)
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case PROCESS_TCP_HEART: //ÐÄÌø°ü·¢ËÍ
|
|
|
|
|
|
+ case PROCESS_TCP_HEART: //心跳包��
|
|
{
|
|
{
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case PROCESS_TCP_SLEEP: //ÍøÂçÐÝÃß״̬
|
|
|
|
|
|
+ case PROCESS_TCP_SLEEP: //ç½‘ç»œä¼‘çœ çŠ¶æ€�
|
|
{
|
|
{
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case PROCESS_TCP_ERROR: //´íÎó״̬
|
|
|
|
|
|
+ case PROCESS_TCP_ERROR: //错误状�
|
|
{
|
|
{
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
tcpErrorCounter++;
|
|
tcpErrorCounter++;
|
|
- if(tcpErrorCounter>60&&TcpSysReboot == 1)//ÎÞ·¨×¤Íø»òÕßÁªÍø
|
|
|
|
|
|
+ if(tcpErrorCounter>60&&TcpSysReboot == 1)//æ— æ³•é©»ç½‘æˆ–è€…è�”网
|
|
{
|
|
{
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
|
|
Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
|
|
vTaskDelay(pdMS_TO_TICKS(2500));
|
|
vTaskDelay(pdMS_TO_TICKS(2500));
|
|
@@ -208,12 +208,12 @@ sint8 TcpDataSendFunc(sint8 ConnectId)
|
|
sint8 outValue = -1;
|
|
sint8 outValue = -1;
|
|
uint32 pSendDataAddr = 0;
|
|
uint32 pSendDataAddr = 0;
|
|
uint16 DataSendLen = 0;
|
|
uint16 DataSendLen = 0;
|
|
- TcpDataEncode(&pSendDataAddr, &DataSendLen); //Êý¾Ý×é°ü£¬mallocÉêÇëÔÚÀïÃæ,pSendDataÖ¸ÏòÉêÇëµÄµØÖ·
|
|
|
|
|
|
+ TcpDataEncode(&pSendDataAddr, &DataSendLen); //数�组包,malloc申请在里�,pSendData指�申请的地�
|
|
if (DataSendLen == 0)
|
|
if (DataSendLen == 0)
|
|
{
|
|
{
|
|
- return 0; //ÔÝʱÎÞÊý¾Ý¿ÉÒÔ·¢
|
|
|
|
|
|
+ return 0; //æš‚æ—¶æ— æ•°æ�®å�¯ä»¥å�‘
|
|
}
|
|
}
|
|
- outValue = tcpipConnectionSend(ConnectId, (uint8 *)pSendDataAddr, DataSendLen); //·¢Ëͺ¯Êý
|
|
|
|
|
|
+ outValue = tcpipConnectionSend(ConnectId, (uint8 *)pSendDataAddr, DataSendLen); //��函数
|
|
if (pSendDataAddr != 0)
|
|
if (pSendDataAddr != 0)
|
|
{
|
|
{
|
|
vPortFree((uint8 *)(pSendDataAddr));
|
|
vPortFree((uint8 *)(pSendDataAddr));
|
|
@@ -228,14 +228,14 @@ sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDat
|
|
uint16 ReadLen = 0;
|
|
uint16 ReadLen = 0;
|
|
char AtCmdSend[30] = {0};
|
|
char AtCmdSend[30] = {0};
|
|
uint8 AtCmdSendTotalLen = 0;
|
|
uint8 AtCmdSendTotalLen = 0;
|
|
- uint8 UartRecvPtr[128];//ÔÝ´æbuffer¸Ä´ó
|
|
|
|
|
|
+ uint8 UartRecvPtr[128];//æš‚å˜buffer改大
|
|
uint8 ret = 0;
|
|
uint8 ret = 0;
|
|
sprintf(AtCmdSend, "AT+CIPSEND=%d,%d\r\n", TcpConnectId, SendDataLen);
|
|
sprintf(AtCmdSend, "AT+CIPSEND=%d,%d\r\n", TcpConnectId, SendDataLen);
|
|
AtCmdSendTotalLen = mstrlen(AtCmdSend);
|
|
AtCmdSendTotalLen = mstrlen(AtCmdSend);
|
|
while(outValue!=0&&sendErrConuter<3)
|
|
while(outValue!=0&&sendErrConuter<3)
|
|
{
|
|
{
|
|
ret = UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdSend, AtCmdSendTotalLen, UartRecvPtr, &ReadLen, 1000);
|
|
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Ìõ¼þĬÈÏͨ¹ý
|
|
|
|
|
|
+ if (((ret==0)&&(ReadLen>0)&&((uint8 *)strstr((char *)UartRecvPtr, (char *)(">"))))||1)//æ¤IFæ�¡ä»¶é»˜è®¤é€šè¿‡
|
|
{
|
|
{
|
|
UART_Send_Data(UART_LPUART1, (uint8 *)SendDataPtr, SendDataLen, 1000);
|
|
UART_Send_Data(UART_LPUART1, (uint8 *)SendDataPtr, SendDataLen, 1000);
|
|
sint8 ret = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CIPSEND"),2000);
|
|
sint8 ret = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CIPSEND"),2000);
|
|
@@ -274,7 +274,7 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
|
|
{
|
|
{
|
|
switch (ConnectStep)
|
|
switch (ConnectStep)
|
|
{
|
|
{
|
|
- case 0: // ATÖ¸Áîͬ²½
|
|
|
|
|
|
+ case 0: // AT指令å�Œæ¥
|
|
{
|
|
{
|
|
char *ATCmdSend = (char *)("ATE0\r\n");
|
|
char *ATCmdSend = (char *)("ATE0\r\n");
|
|
uint8 ATCmdSendLen = mstrlen(ATCmdSend);
|
|
uint8 ATCmdSendLen = mstrlen(ATCmdSend);
|
|
@@ -315,9 +315,9 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 2: //Á¬½Ó¼ì²é
|
|
|
|
|
|
+ case 2: //连接检查
|
|
{
|
|
{
|
|
- AtcmdTransmit(AT_CONNECTCHK, NULL, 0, &ATRet,1000); // ATret·µ»ØµÄÖµÊÇÁ¬½Óid£¬Èç¹ûδÁ¬½Ó·µ»Ø-1
|
|
|
|
|
|
+ AtcmdTransmit(AT_CONNECTCHK, NULL, 0, &ATRet,1000); // ATret返回的值是连接id,如果未连接返回-1
|
|
if (ATRet >= 0)
|
|
if (ATRet >= 0)
|
|
{
|
|
{
|
|
*ConnectId = ATRet;
|
|
*ConnectId = ATRet;
|
|
@@ -329,7 +329,7 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 3: //ÓòÃûת»»
|
|
|
|
|
|
+ case 3: //域�转�
|
|
{
|
|
{
|
|
char AtCmdSend[30] = {0};
|
|
char AtCmdSend[30] = {0};
|
|
uint8 AtCmdSendLen = 0;
|
|
uint8 AtCmdSendLen = 0;
|
|
@@ -349,18 +349,18 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 4: //´´½¨Á¬½Ó
|
|
|
|
|
|
+ case 4: //创建连接
|
|
{
|
|
{
|
|
char AtCmdSend[50] = {0};
|
|
char AtCmdSend[50] = {0};
|
|
uint8 AtCmdSendTotalLen = 0;
|
|
uint8 AtCmdSendTotalLen = 0;
|
|
*ConnectId = 0;
|
|
*ConnectId = 0;
|
|
- /*IP²âÊÔ¸ü¸Ä*/
|
|
|
|
|
|
+ /*IP测试更改*/
|
|
// char *ATCmdSend = (char *)("\"120.26.68.165\"");
|
|
// char *ATCmdSend = (char *)("\"120.26.68.165\"");
|
|
// memset(WebSiteIp,0x00,sizeof(WebSiteIp));
|
|
// memset(WebSiteIp,0x00,sizeof(WebSiteIp));
|
|
// memcpy(WebSiteIp ,ATCmdSend,strlen(ATCmdSend));
|
|
// memcpy(WebSiteIp ,ATCmdSend,strlen(ATCmdSend));
|
|
// WebSitePort = 14401;
|
|
// WebSitePort = 14401;
|
|
/**/
|
|
/**/
|
|
- sprintf(AtCmdSend, "AT+CIPOPEN=%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);
|
|
AtCmdSendTotalLen = mstrlen(AtCmdSend);
|
|
UART_Send_Data(UART_LPUART1, AtCmdSend, AtCmdSendTotalLen, pdMS_TO_TICKS(100));
|
|
UART_Send_Data(UART_LPUART1, AtCmdSend, AtCmdSendTotalLen, pdMS_TO_TICKS(100));
|
|
ATRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CIPOPEN: 0,0"),20000);
|
|
ATRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CIPOPEN: 0,0"),20000);
|
|
@@ -385,13 +385,13 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
|
|
sint8 TcpRegisterChkFunc(void)
|
|
sint8 TcpRegisterChkFunc(void)
|
|
{
|
|
{
|
|
uint8 RegChkStep = 0;
|
|
uint8 RegChkStep = 0;
|
|
- sint8 ChkState = 0; //ĬÈÏΪ0
|
|
|
|
|
|
+ sint8 ChkState = 0; //默认为0
|
|
sint8 ATRet = -1;
|
|
sint8 ATRet = -1;
|
|
while (1)
|
|
while (1)
|
|
{
|
|
{
|
|
switch (RegChkStep)
|
|
switch (RegChkStep)
|
|
{
|
|
{
|
|
- case 0: // ATÖ¸Áîͬ²½
|
|
|
|
|
|
+ case 0: // AT指令å�Œæ¥
|
|
{
|
|
{
|
|
AtcmdTransmit(AT_CMD_TEST, NULL, 0, &ATRet,100);
|
|
AtcmdTransmit(AT_CMD_TEST, NULL, 0, &ATRet,100);
|
|
if (ATRet == 0)
|
|
if (ATRet == 0)
|
|
@@ -405,7 +405,7 @@ sint8 TcpRegisterChkFunc(void)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 1: // CPIN¼ì²é
|
|
|
|
|
|
+ case 1: // CPIN检查
|
|
{
|
|
{
|
|
AtcmdTransmit(AT_SIMREADY, NULL, 0, &ATRet,100);
|
|
AtcmdTransmit(AT_SIMREADY, NULL, 0, &ATRet,100);
|
|
if (ATRet == 0)
|
|
if (ATRet == 0)
|
|
@@ -421,7 +421,7 @@ sint8 TcpRegisterChkFunc(void)
|
|
}
|
|
}
|
|
case 2:
|
|
case 2:
|
|
{
|
|
{
|
|
- AtcmdTransmit(AT_CGREG, NULL, 0, &ATRet,1000); //×¤Íø¼ì²é£¬·µ»ØÖµ1ºÍ5ÊÇ×¤Íø³É¹¦
|
|
|
|
|
|
+ AtcmdTransmit(AT_CGREG, NULL, 0, &ATRet,1000); //驻网检查,返回值1和5是驻网�功
|
|
if (ATRet == 1 || ATRet == 5)
|
|
if (ATRet == 1 || ATRet == 5)
|
|
{
|
|
{
|
|
RegChkStep++;
|
|
RegChkStep++;
|
|
@@ -442,7 +442,7 @@ sint8 TcpRegisterChkFunc(void)
|
|
}
|
|
}
|
|
void InitFunc(void)
|
|
void InitFunc(void)
|
|
{
|
|
{
|
|
- // 4GÄ£¿é³õʼ»¯
|
|
|
|
|
|
+ // 4G模��始化
|
|
uint8 _4G_InitStep = 0;
|
|
uint8 _4G_InitStep = 0;
|
|
sint8 ATRet = -1;
|
|
sint8 ATRet = -1;
|
|
uint16 ReadLen = 0;
|
|
uint16 ReadLen = 0;
|
|
@@ -455,7 +455,7 @@ void InitFunc(void)
|
|
{
|
|
{
|
|
switch (_4G_InitStep)
|
|
switch (_4G_InitStep)
|
|
{
|
|
{
|
|
- case 0: // ATÖ¸Áîͬ²½
|
|
|
|
|
|
+ case 0: // AT指令å�Œæ¥
|
|
{
|
|
{
|
|
AtcmdTransmit(AT_CMD_TEST, NULL, 0, &ATRet,100);
|
|
AtcmdTransmit(AT_CMD_TEST, NULL, 0, &ATRet,100);
|
|
if (ATRet == 0)
|
|
if (ATRet == 0)
|
|
@@ -474,7 +474,7 @@ void InitFunc(void)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 1: //¹Ø±Õ»ØÏÔ
|
|
|
|
|
|
+ case 1: //å…³é—回显
|
|
{
|
|
{
|
|
ATCmdSend = (char *)("ATE0\r\n");
|
|
ATCmdSend = (char *)("ATE0\r\n");
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
@@ -497,7 +497,7 @@ void InitFunc(void)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 2: // IMEI»ñÈ¡
|
|
|
|
|
|
+ case 2: // IMEI获�
|
|
{
|
|
{
|
|
ATCmdSend = (char *)("AT+SIMEI?\r\n");
|
|
ATCmdSend = (char *)("AT+SIMEI?\r\n");
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
@@ -521,7 +521,7 @@ void InitFunc(void)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 3: // ´ò¿ªÊ±¼ä×Ô¶¯¸üÐÂ
|
|
|
|
|
|
+ case 3: // 打开时间自动更新
|
|
{
|
|
{
|
|
ATCmdSend = (char *)("AT+CTZU=1\r\n");
|
|
ATCmdSend = (char *)("AT+CTZU=1\r\n");
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
ATCmdSendLen = mstrlen(ATCmdSend);
|
|
@@ -540,7 +540,7 @@ void InitFunc(void)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 4: // ICCID»ñÈ¡
|
|
|
|
|
|
+ case 4: // ICCID获�
|
|
{
|
|
{
|
|
AtcmdTransmit(AT_GETICCID, NULL, 0, &ATRet,1000);
|
|
AtcmdTransmit(AT_GETICCID, NULL, 0, &ATRet,1000);
|
|
if (ATRet == 0)
|
|
if (ATRet == 0)
|
|
@@ -670,7 +670,7 @@ sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pRead
|
|
{
|
|
{
|
|
OutValue = 0;
|
|
OutValue = 0;
|
|
}
|
|
}
|
|
- retptr = (uint8 *)strstr((char *)pReadStr, (char *)("opened")); //ÖØ¸´´ò¿ª
|
|
|
|
|
|
+ retptr = (uint8 *)strstr((char *)pReadStr, (char *)("opened")); //��打开
|
|
if (retptr)
|
|
if (retptr)
|
|
{
|
|
{
|
|
OutValue = 0;
|
|
OutValue = 0;
|
|
@@ -748,54 +748,54 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
#endif
|
|
#endif
|
|
if (TcpSendTimeCounter == 5)
|
|
if (TcpSendTimeCounter == 5)
|
|
{
|
|
{
|
|
- DataIdx = VerMsg; //°æ±¾ÐÅÏ¢·¢ËÍ
|
|
|
|
|
|
+ DataIdx = VerMsg; //版本信���
|
|
}
|
|
}
|
|
else if (TcpSendTimeCounter % 10 == 1)
|
|
else if (TcpSendTimeCounter % 10 == 1)
|
|
{
|
|
{
|
|
- DataIdx = BattMsg; //µç³ØÐÅÏ¢·¢ËÍ
|
|
|
|
|
|
+ DataIdx = BattMsg; //ç”µæ± ä¿¡æ�¯å�‘é€�
|
|
}
|
|
}
|
|
else if ((TcpSendTimeCounter) % 10 == 2)
|
|
else if ((TcpSendTimeCounter) % 10 == 2)
|
|
{
|
|
{
|
|
- DataIdx = 0x83; //´¢ÄÜ¿ª¹ØÐÅÏ¢·¢ËÍ
|
|
|
|
|
|
+ DataIdx = 0x83; //储能开关信���
|
|
}
|
|
}
|
|
else if ((TcpSendTimeCounter) % 240 == 3)
|
|
else if ((TcpSendTimeCounter) % 240 == 3)
|
|
{
|
|
{
|
|
- DataIdx = GpsMsg; //¶¨Î»ÐÅÏ¢·¢ËÍ
|
|
|
|
|
|
+ DataIdx = GpsMsg; //定�信���
|
|
}
|
|
}
|
|
else if ((TcpSendTimeCounter) % 240 == 4)
|
|
else if ((TcpSendTimeCounter) % 240 == 4)
|
|
{
|
|
{
|
|
- DataIdx = 0x93; //´¢ÄܵçÁ¿ÐÅÏ¢·¢ËÍ
|
|
|
|
|
|
+ DataIdx = 0x93; //储能电�信���
|
|
}
|
|
}
|
|
else if ((TcpSendTimeCounter) % 60 == 5)
|
|
else if ((TcpSendTimeCounter) % 60 == 5)
|
|
{
|
|
{
|
|
- DataIdx = 0x8A; //ÀÛ¼ÆÐÅÏ¢·¢ËÍ
|
|
|
|
|
|
+ DataIdx = 0x8A; //累计信���
|
|
}
|
|
}
|
|
else if ((TcpSendTimeCounter) % (60*60*2) == 6)
|
|
else if ((TcpSendTimeCounter) % (60*60*2) == 6)
|
|
{
|
|
{
|
|
- DataIdx = 0x01; //ʱ¼äУ׼
|
|
|
|
|
|
+ DataIdx = 0x01; //æ—¶é—´æ ¡å‡†
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
*SendLen = 0;
|
|
*SendLen = 0;
|
|
- DataIdx = 0; //²»·¢ËÍ,·µ»Ø
|
|
|
|
|
|
+ DataIdx = 0; //���,返回
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
#if SEGGER_PRINTF==1
|
|
#if SEGGER_PRINTF==1
|
|
SEGGER_RTT_printf("\r\n[%d] DataIdx -%X\r\n",__LINE__,DataIdx);
|
|
SEGGER_RTT_printf("\r\n[%d] DataIdx -%X\r\n",__LINE__,DataIdx);
|
|
#endif
|
|
#endif
|
|
memcpy(TcpbattSN, AppConfigInfo.deviceSn, 17);
|
|
memcpy(TcpbattSN, AppConfigInfo.deviceSn, 17);
|
|
- GetUtc8Time(&UTC8TimeTcp); //ʱ¼ä»ñÈ¡
|
|
|
|
|
|
+ GetUtc8Time(&UTC8TimeTcp); //时间获�
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
switch (DataIdx)
|
|
switch (DataIdx)
|
|
{
|
|
{
|
|
- case 0x01://ʱ¼äУ׼
|
|
|
|
|
|
+ case 0x01://æ—¶é—´æ ¡å‡†
|
|
{
|
|
{
|
|
char *ATCmdSend = (char *)("AT+CNTP\r\n");
|
|
char *ATCmdSend = (char *)("AT+CNTP\r\n");
|
|
uint8 ATCmdSendLen = mstrlen(ATCmdSend);
|
|
uint8 ATCmdSendLen = mstrlen(ATCmdSend);
|
|
uint8 ReadLen = 0;
|
|
uint8 ReadLen = 0;
|
|
uint8 UartRecvPtr[20];
|
|
uint8 UartRecvPtr[20];
|
|
UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen,UartRecvPtr, &ReadLen, pdMS_TO_TICKS(500));
|
|
UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen,UartRecvPtr, &ReadLen, pdMS_TO_TICKS(500));
|
|
- *SendLen = 0;//²»·¢ËÍ£¬³¤¶ÈΪ0
|
|
|
|
|
|
+ *SendLen = 0;//���,长度为0
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
case 0x82:
|
|
case 0x82:
|
|
@@ -846,7 +846,7 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
memcpy(xyzDatacahce, xyzData, 3);
|
|
memcpy(xyzDatacahce, xyzData, 3);
|
|
for (uint8 i = 0; i < 3; i++)
|
|
for (uint8 i = 0; i < 3; i++)
|
|
{
|
|
{
|
|
- if (xyzDatacahce[i] > 0x8000) // Êý¾ÝΪ¸º
|
|
|
|
|
|
+ if (xyzDatacahce[i] > 0x8000) // 数�为负
|
|
{
|
|
{
|
|
xyzDatacahce[i] = (uint16)((uint16)(~(xyzDatacahce[i])) + 1);
|
|
xyzDatacahce[i] = (uint16)((uint16)(~(xyzDatacahce[i])) + 1);
|
|
xyzDatacahce[i] = 20000U - xyzDatacahce[i];
|
|
xyzDatacahce[i] = 20000U - xyzDatacahce[i];
|
|
@@ -929,74 +929,74 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
{
|
|
{
|
|
uint16 ErrorTemp;
|
|
uint16 ErrorTemp;
|
|
ErrorTemp = GetErrorNum(ErrorArray,sizeof(ErrorArray)/2);
|
|
ErrorTemp = GetErrorNum(ErrorArray,sizeof(ErrorArray)/2);
|
|
- uint8 ProtocolHeaderLen = 25; //µç³ØÐÅÏ¢ÐÒéÍ·²¿¼ÓУÑéÂ볤¶È£¬´Ë³¤¶È²»¸ü¸Ä
|
|
|
|
- uint8 ProtocolFixedLen = 60; //µç³ØÐÅÏ¢ÐÒé¹Ì¶¨×ܳ¤¶È ÈçÐÒéÐÂÔö£¬ÐèÒª¸ü¸Ä´Ë³¤¶È
|
|
|
|
- uint16 ProtocolFluctedLen = AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp; //µç³ØÐÅÏ¢ÐÒé±ä¶¯³¤¶È
|
|
|
|
|
|
+ uint8 ProtocolHeaderLen = 25; //ç”µæ± ä¿¡æ�¯å��è®®å¤´éƒ¨åŠ æ ¡éªŒç �长度,æ¤é•¿åº¦ä¸�更改
|
|
|
|
+ uint8 ProtocolFixedLen = 60; //ç”µæ± ä¿¡æ�¯å��议固定总长度 如å��议新增,需è¦�更改æ¤é•¿åº¦
|
|
|
|
+ uint16 ProtocolFluctedLen = AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp; //ç”µæ± ä¿¡æ�¯å��è®®å�˜åŠ¨é•¿åº¦
|
|
uint16 DataLen;
|
|
uint16 DataLen;
|
|
*SendLen = ProtocolFixedLen + ProtocolFluctedLen;
|
|
*SendLen = ProtocolFixedLen + ProtocolFluctedLen;
|
|
SendBuffer = pvPortMalloc(*SendLen);
|
|
SendBuffer = pvPortMalloc(*SendLen);
|
|
GetCSQValue(&CSQValue);
|
|
GetCSQValue(&CSQValue);
|
|
- *(SendBuffer + 0) = TCP_START_SYM1; //ÆðʼÂë-1
|
|
|
|
- *(SendBuffer + 1) = TCP_START_SYM2; //ÆðʼÂë-2
|
|
|
|
- *(SendBuffer + 2) = TCP_CMD_SYM; //ÃüÁî±êʶ-3
|
|
|
|
- *(SendBuffer + 3) = TCP_ANS_SYM; //Ó¦´ð±êʶ-4
|
|
|
|
- memcpy(SendBuffer + 4, TcpbattSN, BATT_SN_LEN); // SNÂë 5-21
|
|
|
|
- *(SendBuffer + 21) = TCP_ENCPT_DISABLE; //¼ÓÃÜ·½Ê½-22
|
|
|
|
- DataLen = ProtocolFixedLen + ProtocolFluctedLen - ProtocolHeaderLen; //µç³ØÐÅÏ¢µ¥ÔªÐÒé¹Ì¶¨³¤¶È
|
|
|
|
- *(SendBuffer + 22) = (DataLen >> 8) & 0xFF; //Êý¾Ý³¤¶ÈH-23
|
|
|
|
- *(SendBuffer + 23) = DataLen & 0xFF; //Êý¾Ý³¤¶ÈL-24
|
|
|
|
|
|
+ *(SendBuffer + 0) = TCP_START_SYM1; //èµ·å§‹ç �-1
|
|
|
|
+ *(SendBuffer + 1) = TCP_START_SYM2; //èµ·å§‹ç �-2
|
|
|
|
+ *(SendBuffer + 2) = TCP_CMD_SYM; //å‘½ä»¤æ ‡è¯†-3
|
|
|
|
+ *(SendBuffer + 3) = TCP_ANS_SYM; //åº”ç”æ ‡è¯†-4
|
|
|
|
+ memcpy(SendBuffer + 4, TcpbattSN, BATT_SN_LEN); // SNç � 5-21
|
|
|
|
+ *(SendBuffer + 21) = TCP_ENCPT_DISABLE; //åŠ å¯†æ–¹å¼�-22
|
|
|
|
+ DataLen = ProtocolFixedLen + ProtocolFluctedLen - ProtocolHeaderLen; //ç”µæ± ä¿¡æ�¯å�•å…ƒå��议固定长度
|
|
|
|
+ *(SendBuffer + 22) = (DataLen >> 8) & 0xFF; //数�长度H-23
|
|
|
|
+ *(SendBuffer + 23) = DataLen & 0xFF; //数�长度L-24
|
|
*(SendBuffer + 24) = (UTC8TimeTcp.year) & 0xFF; // year-25
|
|
*(SendBuffer + 24) = (UTC8TimeTcp.year) & 0xFF; // year-25
|
|
*(SendBuffer + 25) = UTC8TimeTcp.month & 0xFF; // month-26
|
|
*(SendBuffer + 25) = UTC8TimeTcp.month & 0xFF; // month-26
|
|
*(SendBuffer + 26) = UTC8TimeTcp.day & 0xFF; // day-27
|
|
*(SendBuffer + 26) = UTC8TimeTcp.day & 0xFF; // day-27
|
|
*(SendBuffer + 27) = UTC8TimeTcp.hour & 0xFF; // hour-28
|
|
*(SendBuffer + 27) = UTC8TimeTcp.hour & 0xFF; // hour-28
|
|
*(SendBuffer + 28) = UTC8TimeTcp.minute & 0xFF; // mins-29
|
|
*(SendBuffer + 28) = UTC8TimeTcp.minute & 0xFF; // mins-29
|
|
*(SendBuffer + 29) = UTC8TimeTcp.second & 0xFF; // sec-30
|
|
*(SendBuffer + 29) = UTC8TimeTcp.second & 0xFF; // sec-30
|
|
- *(SendBuffer + 30) = DataIdx; //µç³ØÐÅÏ¢·¢ËÍ-31
|
|
|
|
|
|
+ *(SendBuffer + 30) = DataIdx; //ç”µæ± ä¿¡æ�¯å�‘é€�-31
|
|
*(SendBuffer + 31) = (UTC8TimeTcp.year) & 0xFF; // year-32
|
|
*(SendBuffer + 31) = (UTC8TimeTcp.year) & 0xFF; // year-32
|
|
*(SendBuffer + 32) = UTC8TimeTcp.month & 0xFF; // month-33
|
|
*(SendBuffer + 32) = UTC8TimeTcp.month & 0xFF; // month-33
|
|
*(SendBuffer + 33) = UTC8TimeTcp.day & 0xFF; // day-34
|
|
*(SendBuffer + 33) = UTC8TimeTcp.day & 0xFF; // day-34
|
|
*(SendBuffer + 34) = UTC8TimeTcp.hour & 0xFF; // hour-35
|
|
*(SendBuffer + 34) = UTC8TimeTcp.hour & 0xFF; // hour-35
|
|
*(SendBuffer + 35) = UTC8TimeTcp.minute & 0xFF; // mins-36
|
|
*(SendBuffer + 35) = UTC8TimeTcp.minute & 0xFF; // mins-36
|
|
*(SendBuffer + 36) = UTC8TimeTcp.second & 0xFF; // sec-37
|
|
*(SendBuffer + 36) = UTC8TimeTcp.second & 0xFF; // sec-37
|
|
- *(SendBuffer + 37) = CSQValue; //ÐźÅÇ¿¶È-38
|
|
|
|
- *(SendBuffer + 38) = 0; //¹ÊÕϵȼ¶-39
|
|
|
|
- *(SendBuffer + 39) = ErrorTemp >> 8; //¹ÊÕÏ´úÂëH-40
|
|
|
|
- *(SendBuffer + 40) = ErrorTemp & 0xFF; //¹ÊÕÏ´úÂëL-41
|
|
|
|
- *(SendBuffer + 41) = battI >> 8; //µçÁ÷-42
|
|
|
|
- *(SendBuffer + 42) = battI & 0xFF; //µçÁ÷-43
|
|
|
|
- *(SendBuffer + 43) = battPackVol >> 8; //µçѹ-44
|
|
|
|
- *(SendBuffer + 44) = battPackVol & 0xFF; //µçѹ-45
|
|
|
|
- *(SendBuffer + 45) = battPackVol >> 8; //µçѹ-46
|
|
|
|
- *(SendBuffer + 46) = battPackVol & 0xFF; //µçѹ-47
|
|
|
|
- *(SendBuffer + 47) = battMOSSwitchState; // mos״̬-48
|
|
|
|
|
|
+ *(SendBuffer + 37) = CSQValue; //信�强度-38
|
|
|
|
+ *(SendBuffer + 38) = 0; //æ•…éšœç‰çº§-39
|
|
|
|
+ *(SendBuffer + 39) = ErrorTemp >> 8; //故障代ç �H-40
|
|
|
|
+ *(SendBuffer + 40) = ErrorTemp & 0xFF; //故障代ç �L-41
|
|
|
|
+ *(SendBuffer + 41) = battI >> 8; //电�-42
|
|
|
|
+ *(SendBuffer + 42) = battI & 0xFF; //电�-43
|
|
|
|
+ *(SendBuffer + 43) = battPackVol >> 8; //电压-44
|
|
|
|
+ *(SendBuffer + 44) = battPackVol & 0xFF; //电压-45
|
|
|
|
+ *(SendBuffer + 45) = battPackVol >> 8; //电压-46
|
|
|
|
+ *(SendBuffer + 46) = battPackVol & 0xFF; //电压-47
|
|
|
|
+ *(SendBuffer + 47) = battMOSSwitchState; // mos状�-48
|
|
*(SendBuffer + 48) = (uint8)(battSOC); // soc-49
|
|
*(SendBuffer + 48) = (uint8)(battSOC); // soc-49
|
|
*(SendBuffer + 49) = (uint8)(battSOH); // soh-50
|
|
*(SendBuffer + 49) = (uint8)(battSOH); // soh-50
|
|
*(SendBuffer + 50) = (battBalanceoInfo >> 24) & 0xFF;
|
|
*(SendBuffer + 50) = (battBalanceoInfo >> 24) & 0xFF;
|
|
*(SendBuffer + 51) = (battBalanceoInfo >> 16) & 0xFF;
|
|
*(SendBuffer + 51) = (battBalanceoInfo >> 16) & 0xFF;
|
|
*(SendBuffer + 52) = (battBalanceoInfo >> 8) & 0xFF;
|
|
*(SendBuffer + 52) = (battBalanceoInfo >> 8) & 0xFF;
|
|
- *(SendBuffer + 53) = battBalanceoInfo & 0xFF; //¾ùºâ״̬-51-54
|
|
|
|
- *(SendBuffer + 54) = AppDataInfo.BattCellCount; //µçѹ¸öÊý-55
|
|
|
|
- for (uint8 i = 0; i < AppDataInfo.BattCellCount; i++) //µ¥Ìåµçѹ
|
|
|
|
|
|
+ *(SendBuffer + 53) = battBalanceoInfo & 0xFF; //�衡状�-51-54
|
|
|
|
+ *(SendBuffer + 54) = AppDataInfo.BattCellCount; //电压个数-55
|
|
|
|
+ for (uint8 i = 0; i < AppDataInfo.BattCellCount; i++) //�体电压
|
|
{
|
|
{
|
|
*(SendBuffer + 54 + i * 2 + 1) = (battCellU[i] >> 8) & 0xFF;
|
|
*(SendBuffer + 54 + i * 2 + 1) = (battCellU[i] >> 8) & 0xFF;
|
|
*(SendBuffer + 54 + i * 2 + 2) = battCellU[i] & 0xFF;
|
|
*(SendBuffer + 54 + i * 2 + 2) = battCellU[i] & 0xFF;
|
|
}
|
|
}
|
|
- *(SendBuffer + 55 + AppDataInfo.BattCellCount * 2) = AppDataInfo.BattTempCount; //Ä£×éζȸöÊý
|
|
|
|
- memcpy((SendBuffer + 55 + AppDataInfo.BattCellCount * 2 + 1), &battCellTemp, AppDataInfo.BattTempCount); //Ä£×éζÈ
|
|
|
|
- *(SendBuffer + 56 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battWorkState; //µç³Ø¹¤×÷״̬
|
|
|
|
- *(SendBuffer + 57 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battHeatEnableState; //µç³Ø¼ÓÈÈʹÄÜ״̬
|
|
|
|
- *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = BmsOtherTemp + OtherTemp; //ÆäËûζȸöÊý
|
|
|
|
- // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 1) = MOSTemp; // mosζÈ
|
|
|
|
- // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 2) = packTemp; //»·¾³Î¶È
|
|
|
|
- // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 3) = fastChargeTemp; //¿ì³äζÈ
|
|
|
|
- // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 4) = normalChargeTemp; //Âý³äζÈ
|
|
|
|
- // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 5) = heatTemp1; //¼ÓÈÈζÈ1
|
|
|
|
- // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 6) = heatTemp2; //¼ÓÈÈζÈ2
|
|
|
|
- *(SendBuffer + 59 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp) = bcc_chk(SendBuffer, ProtocolFixedLen + ProtocolFluctedLen - 1); //УÑéÂë
|
|
|
|
|
|
+ *(SendBuffer + 55 + AppDataInfo.BattCellCount * 2) = AppDataInfo.BattTempCount; //模组温度个数
|
|
|
|
+ memcpy((SendBuffer + 55 + AppDataInfo.BattCellCount * 2 + 1), &battCellTemp, AppDataInfo.BattTempCount); //模组温度
|
|
|
|
+ *(SendBuffer + 56 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battWorkState; //ç”µæ± å·¥ä½œçŠ¶æ€�
|
|
|
|
+ *(SendBuffer + 57 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battHeatEnableState; //ç”µæ± åŠ çƒä½¿èƒ½çжæ€�
|
|
|
|
+ *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = BmsOtherTemp + OtherTemp; //其他温度个数
|
|
|
|
+ // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 1) = MOSTemp; // mos温度
|
|
|
|
+ // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 2) = packTemp; //环境温度
|
|
|
|
+ // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 3) = fastChargeTemp; //快充温度
|
|
|
|
+ // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 4) = normalChargeTemp; //慢充温度
|
|
|
|
+ // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 5) = heatTemp1; //åŠ çƒæ¸©åº¦1
|
|
|
|
+ // *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 6) = heatTemp2; //åŠ çƒæ¸©åº¦2
|
|
|
|
+ *(SendBuffer + 59 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp) = bcc_chk(SendBuffer, ProtocolFixedLen + ProtocolFluctedLen - 1); //æ ¡éªŒç �
|
|
*PtrSendAddr = (uint32)SendBuffer;
|
|
*PtrSendAddr = (uint32)SendBuffer;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 0x83://´¢Äܳ¡¾°µÄ¿ª¹ØÐÅÏ¢
|
|
|
|
|
|
+ case 0x83://储能场景的开关信�
|
|
{
|
|
{
|
|
StorageInfoToTcp StorageInfo;
|
|
StorageInfoToTcp StorageInfo;
|
|
*SendLen = sizeof(StorageInfo);
|
|
*SendLen = sizeof(StorageInfo);
|
|
@@ -1033,7 +1033,7 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
|
|
*PtrSendAddr = (uint32)SendBuffer;
|
|
*PtrSendAddr = (uint32)SendBuffer;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case 0x93://´¢Äܳ¡¾°µÄµçÁ¿ÐÅÏ¢
|
|
|
|
|
|
+ case 0x93://储能场景的电�信�
|
|
{
|
|
{
|
|
StorageInfoToTcp2 StorageInfo2;
|
|
StorageInfoToTcp2 StorageInfo2;
|
|
*SendLen = sizeof(StorageInfo2);
|
|
*SendLen = sizeof(StorageInfo2);
|
|
@@ -1234,12 +1234,12 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
|
|
if (TcpDataLen > 0)
|
|
if (TcpDataLen > 0)
|
|
{
|
|
{
|
|
Ptr = retptr + 2;
|
|
Ptr = retptr + 2;
|
|
- if ((*(Ptr + 0) == TCP_START_SYM1) && (*(Ptr + 1) == TCP_START_SYM2)) //·þÎñÆ÷ÆðʼÐÅÏ¢
|
|
|
|
|
|
+ if ((*(Ptr + 0) == TCP_START_SYM1) && (*(Ptr + 1) == TCP_START_SYM2)) //�务器起始信�
|
|
{
|
|
{
|
|
- Tcp_Cmd = *(Ptr + 2); //ÃüÁî±êÖ¾
|
|
|
|
|
|
+ Tcp_Cmd = *(Ptr + 2); //å‘½ä»¤æ ‡å¿—
|
|
if (*(Ptr + 3) == 0xFE)
|
|
if (*(Ptr + 3) == 0xFE)
|
|
{
|
|
{
|
|
- TcpWorkState = 0x01;//ÐèÒªÔÝÍ£·¢ËÍ£¬½øÐÐÃüÁîÓ¦´ðµÄ±êÖ¾
|
|
|
|
|
|
+ TcpWorkState = 0x01;//需è¦�æš‚å�œå�‘é€�,进行命令应ç”çš„æ ‡å¿—
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1256,7 +1256,7 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
|
|
TcpCmdAnswer[0] = TCP_START_SYM1;
|
|
TcpCmdAnswer[0] = TCP_START_SYM1;
|
|
TcpCmdAnswer[1] = TCP_START_SYM1;
|
|
TcpCmdAnswer[1] = TCP_START_SYM1;
|
|
TcpCmdAnswer[2] = TCP_CONCMD_SYM;
|
|
TcpCmdAnswer[2] = TCP_CONCMD_SYM;
|
|
- if (*(Ptr + 30) == 0x83) //Ô¶³ÌÉý¼¶Ö¸Áî
|
|
|
|
|
|
+ if (*(Ptr + 30) == 0x83) //远程�级指令
|
|
{
|
|
{
|
|
TcpCmdAnswer[3] = 0x01;
|
|
TcpCmdAnswer[3] = 0x01;
|
|
memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
|
|
memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
|
|
@@ -1269,7 +1269,7 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
|
|
vTaskDelay(pdMS_TO_TICKS(5000));
|
|
vTaskDelay(pdMS_TO_TICKS(5000));
|
|
Fota_Ftp(Ptr + 32);
|
|
Fota_Ftp(Ptr + 32);
|
|
}
|
|
}
|
|
- else if (*(Ptr + 30) == 0x80) //Ô¶³ÌËø¶¨ÃüÁî
|
|
|
|
|
|
+ else if (*(Ptr + 30) == 0x80) //远程�定命令
|
|
{
|
|
{
|
|
TcpCmdAnswer[3] = 0x01;
|
|
TcpCmdAnswer[3] = 0x01;
|
|
memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
|
|
memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
|
|
@@ -1278,13 +1278,13 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
|
|
TcpCmdAnswer[23] = 0x06;
|
|
TcpCmdAnswer[23] = 0x06;
|
|
memcpy(&TcpCmdAnswer[24], (Ptr + 24), 6);
|
|
memcpy(&TcpCmdAnswer[24], (Ptr + 24), 6);
|
|
TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer, 30);
|
|
TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer, 30);
|
|
- if (*(Ptr + 31) == 0x01) // 0x01´ú±íËø¶¨
|
|
|
|
|
|
+ if (*(Ptr + 31) == 0x01) // 0x01代表�定
|
|
{
|
|
{
|
|
battSeparateEnable = 1;
|
|
battSeparateEnable = 1;
|
|
battSeparateCtlState = 1;
|
|
battSeparateCtlState = 1;
|
|
tcpipConnectionSend(SocketId, TcpCmdAnswer, 31 );
|
|
tcpipConnectionSend(SocketId, TcpCmdAnswer, 31 );
|
|
}
|
|
}
|
|
- else if (*(Ptr + 31) == 0x02) // 0x02´ú±í½âËø
|
|
|
|
|
|
+ else if (*(Ptr + 31) == 0x02) // 0x02代表解�
|
|
{
|
|
{
|
|
battSeparateEnable = 1;
|
|
battSeparateEnable = 1;
|
|
battSeparateCtlState = 0;
|
|
battSeparateCtlState = 0;
|
|
@@ -1415,7 +1415,7 @@ void Fota_Ftp(uint8 *dataPtrIn)
|
|
uint16 ReadLen = 0;
|
|
uint16 ReadLen = 0;
|
|
uint8 *retptr = NULL;
|
|
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ÐÅÏ¢½âÎö*/
|
|
|
|
|
|
+ /*URL信�解�*/
|
|
char *databuffer[20];
|
|
char *databuffer[20];
|
|
char *accountPtr;
|
|
char *accountPtr;
|
|
char *passwordPtr;
|
|
char *passwordPtr;
|
|
@@ -1431,7 +1431,7 @@ void Fota_Ftp(uint8 *dataPtrIn)
|
|
while (p&&index<20)
|
|
while (p&&index<20)
|
|
{
|
|
{
|
|
databuffer[index] = p;
|
|
databuffer[index] = p;
|
|
- p = strtok(NULL, ",");//±¨Ó²¼þ´íÎó
|
|
|
|
|
|
+ p = strtok(NULL, ",");//报硬件错误
|
|
index++;
|
|
index++;
|
|
}
|
|
}
|
|
accountPtr = databuffer[0];
|
|
accountPtr = databuffer[0];
|