From c0a472466cd8e8e1fa66354b8d8e3fabce758765 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期三, 28 八月 2024 15:30:24 +0800
Subject: [PATCH] Merge branch '安邦测距手环' of http://47.108.70.204:60062/r/ChinaUWBProject into 安邦测距手环

---
 keil/include/main/main.c |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/keil/include/main/main.c b/keil/include/main/main.c
index f696d42..c62a079 100644
--- a/keil/include/main/main.c
+++ b/keil/include/main/main.c
@@ -168,7 +168,7 @@
             bat_percent = ((fVoltage_mv - 3300) /8);
         }
     }
-    LOG_INFO(TRACE_MODULE_APP, "The voltage is %%%d \r\n",bat_percent);
+  //  LOG_INFO(TRACE_MODULE_APP, "The voltage is %%%d \r\n",bat_percent);
 }
 //void UartInit(void)
 //{
@@ -291,6 +291,7 @@
     // flag_4G_recdata = 1;
     // AIR780EUartInit();
 }
+extern uint16_t ip0,ip1,ip2,ip3,port;
 void Program_Init(void)
 {
     Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为
@@ -300,8 +301,7 @@
     tag_frequency = 1000/g_com_map[COM_INTERVAL];//测距频率这个存的是测距时间
     memcpy(&disoffset,&g_com_map[DIST_OFFSET],2);
     g_com_map[ALARM_DISTANCE1] = 40;
-    g_com_map[ALARM_DISTANCE2
-    ] = 40;
+    g_com_map[ALARM_DISTANCE2] = 40;
     warning_distance=g_com_map[ALARM_DISTANCE1];
     prewarning_distance=g_com_map[ALARM_DISTANCE2];
     send_struct.warnDistence=warning_distance;
@@ -315,6 +315,18 @@
     }else{
         UWB_work_state = SEARCH_DEV;
     }
+    if(g_com_map[SEND_4G_SECOND]<60)
+        g_com_map[SEND_4G_SECOND]=60;
+    
+    ip0 = (g_com_map[TCP_IP_0]>>12&0xf)*1000+(g_com_map[TCP_IP_0]>>8&0xf)*100+(g_com_map[TCP_IP_0]>>4&0xf)*10+(g_com_map[TCP_IP_0]&0xf);
+    ip1 = (g_com_map[TCP_IP_1]>>12&0xf)*1000+(g_com_map[TCP_IP_1]>>8&0xf)*100+(g_com_map[TCP_IP_1]>>4&0xf)*10+(g_com_map[TCP_IP_1]&0xf);
+    ip2 = (g_com_map[TCP_IP_2]>>12&0xf)*1000+(g_com_map[TCP_IP_2]>>8&0xf)*100+(g_com_map[TCP_IP_2]>>4&0xf)*10+(g_com_map[TCP_IP_2]&0xf);
+    ip3 = (g_com_map[TCP_IP_3]>>12&0xf)*1000+(g_com_map[TCP_IP_3]>>8&0xf)*100+(g_com_map[TCP_IP_3]>>4&0xf)*10+(g_com_map[TCP_IP_3]&0xf);
+    port = (g_com_map[TCP_PORT]>>12&0xf)*1000+(g_com_map[TCP_PORT]>>8&0xf)*100+(g_com_map[TCP_PORT]>>4&0xf)*10+(g_com_map[TCP_PORT]&0xf);
+    g_com_map[VERSION] = (1<<8)|1;
+    LOG_INFO("设备ID: %x .\r\n",dev_id);
+    LOG_INFO("固件版本:UWB-4G手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff);
+    LOG_INFO("服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port);
 }
 
 
@@ -345,8 +357,8 @@
             uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback);//开启dma
             //UartDeinit();
         }
-        UART_CheckReceive();
     }
+		UART_CheckReceive();
 }
 int bind_check(void)
 {
@@ -369,11 +381,23 @@
             first_search_flag=1;
     }
 }
-
+void boot_deinit(void)
+{
+	//将boot中串口返回普通gpio
+// UART0 TX/RX
+    io_pin_mux_set(IO_PIN_5, IO_FUNC0);
+    io_pin_mux_set(IO_PIN_6, IO_FUNC0);
+    // UART1 RX/TX
+    io_pin_mux_set(IO_PIN_10, IO_FUNC0);
+    io_pin_mux_set(IO_PIN_9, IO_FUNC0);
+	 uart_close(UART_ID1);//解绑原来串口1
+	 uart_close(UART_ID0);//解绑原来串口0
+}
 uint8_t flag_4guart_needinit=0;
 int main(void)
 {
     board_clock_run();
+		boot_deinit();
     board_pins_config();
     board_debug_console_open(TRACE_PORT_UART0);
     // Reset reason
@@ -433,10 +457,10 @@
     sleep_timer_open(true, SLEEP_TIMER_MODE_RELOAD, sleep_timer_callback);
     //sleep_timer_start(__MS_TO_32K_CNT(g_com_map[COM_INTERVAL]));//测试
     sleep_timer_start(__MS_TO_32K_CNT(SLEEP_TIMER_NUM));//测试
-//    board_5V_input_init(voltage_input_handler);
+    board_5V_input_init(voltage_input_handler);
     board_acceleration_detection_init(move_handler);
-
-    //AIR780E_Reset(); //4G模块重启,耗时1.5秒,这个是无法同步的关键
+//		 LOG_INFO(TRACE_MODULE_APP, "测试进入app");
+    AIR780E_Reset(); //4G模块重启,耗时1.5秒,这个是无法同步的关键
     while (1)
     {
         if(flag_TCP_reconnectting||IfTCPConnected())

--
Gitblit v1.9.3