From adfc7e798b9cbdd022bf8df971843436912a0fe5 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期日, 20 七月 2025 16:58:30 +0800 Subject: [PATCH] 成功移植g_com_map表逻辑,初步测试能读能写,并且TDOA效果和官方一致 --- keil/include/src/TCPClient.c | 53 +++++++++++++++++++++++++++++++++++------------------ 1 files changed, 35 insertions(+), 18 deletions(-) diff --git a/keil/include/src/TCPClient.c b/keil/include/src/TCPClient.c index 7c1ab71..1fa347c 100644 --- a/keil/include/src/TCPClient.c +++ b/keil/include/src/TCPClient.c @@ -20,6 +20,7 @@ #include "mk_4G.h" #include "mk_trace.h" #include "dw_app_anchor.h" +#include "PCA9555.h" /******************************************************************************* * Macro * *******************************************************************************/ @@ -73,12 +74,17 @@ char applyid[10]; uint16_t receive_id; uint16_t g_com_position; +uint16_t g_com_num; static HIDO_INT32 TCPClient_DataProc(HIDO_UINT8 *_u8Data, HIDO_UINT32 _u32Len) { HIDO_CHAR *apcSplitStr[12]; HIDO_UINT32 u32SplitCnt = 0; HIDO_CHAR acResponse[200]; + HIDO_CHAR temp_acResponse[200]; + HIDO_CHAR acReadponse[200]; + HIDO_UINT32 datalenth; HIDO_UINT32 u32ResponseLen; + HIDO_UINT32 u32ReadResponseLen; LOG_INFO(TRACE_MODULE_APP, "收到数据\r\n"); @@ -87,15 +93,20 @@ { u32ResponseLen = snprintf(acResponse, sizeof(acResponse), "$setparaok,%s\r\n", \ _u8Data); - Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acResponse, u32ResponseLen); + memcpy(temp_acResponse,acResponse,sizeof(acResponse)); + u32SplitCnt = HIDO_UtilStrSplit((HIDO_CHAR *)_u8Data, ',', apcSplitStr, HIDO_ARRARY_COUNT(apcSplitStr)); receive_id = HIDO_UtilHexStrToInt(apcSplitStr[1]); if(g_com_map[DEV_ID]==receive_id) { - g_com_position=HIDO_UtilStrToInt(apcSplitStr[2]); - g_com_map[g_com_position]=HIDO_UtilStrToInt(apcSplitStr[3]); - if(g_com_map[SEND_4G_SECOND]<30) + g_com_position=HIDO_UtilStrToInt(apcSplitStr[2]); + if(g_com_position!=CNT_RESTART&&g_com_position!=0&&g_com_position!=CNT_UPDATE) + { + Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)temp_acResponse, u32ResponseLen); + g_com_map[g_com_position]=HIDO_UtilStrToInt(apcSplitStr[3]); + } + if(g_com_map[SEND_4G_SECOND]<30) { gps_open_flag=0; gps_wait_count=0; @@ -170,6 +181,16 @@ receive_id = HIDO_UtilHexStrToInt(apcSplitStr[1]); if(g_com_map[DEV_ID]==receive_id) { + g_com_position=HIDO_UtilStrToInt(apcSplitStr[2]); + g_com_num= HIDO_UtilStrToInt(apcSplitStr[3]); + u32ReadResponseLen = snprintf(acReadponse, sizeof(acReadponse), "$replypara,%04x,%d", \ + receive_id,g_com_position); + for(uint16_t i=0;i<g_com_num;i++) + { + datalenth = sprintf((HIDO_CHAR *)&acReadponse[u32ReadResponseLen],",%d",g_com_map[g_com_position+i]); + u32ReadResponseLen += datalenth; + } + Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acReadponse, u32ReadResponseLen); } } return HIDO_OK; @@ -250,7 +271,7 @@ extern uint8_t GPS_GGAmessage[150],userkey_state,gps_timeout_flag; extern uint16_t g_spsum,g_snum,ave_sp; void UDPClient_UploadGPS(void) -{ air780_led_on(); +{ HIDO_CHAR acHeart[200]; HIDO_UINT32 u32HeartLen; ave_sp = g_spsum/g_snum; @@ -269,7 +290,6 @@ GPS_GGAmessage,g_com_map[DEV_ID],bat_percent,userkey_state,gps_timeout_flag); userkey_state = 0; Socket_Send(l_i32TCPClientID, (HIDO_UINT8 *)acHeart, u32HeartLen); - air780_led_off(); } void TCPHeartBeatUpload(void) @@ -339,17 +359,13 @@ } else if (TCP_CLIENT_STATE_CONNECTED == l_eTCPClientState) { - - - - - //if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(15)||flag_first_TCPconnect) - if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(g_com_map[SEND_4G_SECOND])||flag_first_TCPconnect) + if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(60)||flag_first_TCPconnect) + //if ((u32CurTick - l_u32HeartBeatTick) >= HIDO_TIMER_TICK_S(g_com_map[SEND_4G_SECOND])||flag_first_TCPconnect) { flag_first_TCPconnect = 0; l_u32HeartBeatTick = u32CurTick; // 这里是自定义心跳 - //TCPHeartBeatUpload(); + TCPHeartBeatUpload(); //UDPClient_UploadGPS();//先不弄心跳 // HIDO_CHAR acHeart[128]; // HIDO_UINT32 u32HeartLen = snprintf(acHeart, sizeof(acHeart), "$message heart,%04x,00001,1,50,50,50,,,,\r\n", g_com_map[DEV_ID]); @@ -412,13 +428,14 @@ char str[17]= {"AT+IPR=9600;&W\r\n"}; void AIR780E_Reset(void) { - gps_air780_power_change(gps_power_state,0);//开启gps,4G - delay_us(1500000); - gps_air780_power_change(gps_power_state,1);//开启gps,4G -// delay_us(3000000); -// Uart_ReConfigBaudRate(UART_ID_4G,115200); + PCA9555_Set_One_Value_Output(AIR780E_ENBALE,0);//关闭4G + delay_ms(1500); + PCA9555_Set_One_Value_Output(AIR780E_ENBALE,1);//打开4G + delay_ms(3000); +// Uart_ReConfigBaudRate(UART_ID_4G,115200); // uart_send(UART_ID0, str,17, NULL); // Uart_ReConfigBaudRate(UART_ID_4G,9600); + } uint8_t IfTCPConnected(void) { -- Gitblit v1.9.3