From 974181bcefe299fbed4c1dcd6d39be3e9f674c0e Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期五, 13 六月 2025 18:04:16 +0800
Subject: [PATCH] 成功增加sscom03shell配置指令功能,但是需要输入3次才能进入函数处理未解决

---
 keil/include/main/main.c |   72 +++++++++++++++++++++++++++++++++--
 1 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/keil/include/main/main.c b/keil/include/main/main.c
index afa9faf..58edd5a 100644
--- a/keil/include/main/main.c
+++ b/keil/include/main/main.c
@@ -61,6 +61,8 @@
 #include "HIDO_ATLite.h"
 #include "HIDO_Timer.h"
 #include "TCPClient.h"
+#include "DBG.h"
+#include "Shell.h"
 
 //#define DEBUG_MODE
 extern int simple_main(void);
@@ -587,11 +589,11 @@
 		}
     g_com_map[MODBUS_MODE] = 0;
 		log_4g_enable_flag=g_com_map[LOG_4G_ENABLE];
-    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];
+    ip0 = g_com_map[IP_0];
+    ip1 = g_com_map[IP_1];
+    ip2 = g_com_map[IP_2];
+    ip3 = g_com_map[IP_3];
+    port = g_com_map[PORT];
     g_com_map[VERSION] = (1<<8)|20;
     LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id);
     LOG_INFO(TRACE_MODULE_APP,"固件版本:4G-GPS定位手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff);
@@ -615,6 +617,64 @@
             //UartInit();
         }
 
+				//检测到5V输入
+				     while(1)
+            {
+                nomove_count = 0;
+                wdt_ping(WDT_ID0);//喂狗
+			if(DBG_GetMode() == DBG_MODE_SHELL)
+			{
+			
+//					if(flag_secondtask)
+//					{
+//							flag_secondtask = 0;
+//							SecondTask();
+//					}
+      }
+			if(flag_TCP_reconnectting||IfTCPConnected())
+        {
+					  if(flag_4G_recdata==1)
+            {
+                flag_4G_recdata = 2;
+                Socket_RecvAll();
+            }
+            Internet_Poll();
+            HIDO_ATLitePoll();
+            HIDO_TimerPoll();
+            TCPClient_Poll();
+        }
+                UART_CheckReceive();
+									UserKeyTask();
+									IMUTask();
+                if(flag_secondtask)
+                {
+                    flag_secondtask = 0;
+                    SecondTask();
+                }
+                if(DBG_GetMode() == DBG_MODE_SHELL)
+                {
+                    if(g_com_map[CNT_RESTART]==1)
+                    {
+                        g_com_map[CNT_RESTART]=0;
+                        save_com_map_to_flash();
+                        NVIC_SystemReset();
+
+                    }
+                }
+                else
+                {
+									
+                }
+//                if(input5v_time)
+//                {
+                if(!gpio_pin_get_val(INPUT_5V_Pin))
+                {
+                break;
+                }
+								
+//                }
+            }
+						//NVIC_SystemReset();//重启
         //UART_CheckSend();
     } else {
         if(state5v==1)
@@ -719,6 +779,8 @@
 
     // TODO 4G
     Uart_Register(UART_ID_4G, UART_ID0);
+		Uart_Register(UART_ID_DBG_GPS, UART_ID1);
+    DBG_Init();
     Internet_Init();
     TCPClient_Init();
 

--
Gitblit v1.9.3