修改ssid,修改tcp连接超时
authorkyz <kongyuzhong@google.com>
Fri, 19 Dec 2025 06:41:30 +0000 (14:41 +0800)
committerkyz <kongyuzhong@google.com>
Fri, 19 Dec 2025 06:41:30 +0000 (14:41 +0800)
20240801完整版/扳手下位机软件/cpbs-202103-20240423/APP/wifi.c
20240801完整版/扳手下位机软件/cpbs-202103-20240423/APP/wifi.h

index b74dbbf8385031bba543bd1b3383021180f99937..5d9da83b1aa372e9926ec1d780a363c608c92e1b 100644 (file)
@@ -546,16 +546,6 @@ static int get_tcp_response(tcp_response_t* resp)
     return 0;
 }
 
-// »ñÈ¡MCU UUIDº¯Êý
-static void get_mcu_uuid(char* uuid_str, int max_len)
-{
-    // STM32F10xϵÁеÄUUIDµØÖ·Îª0x1FFFF7E8
-    uint32_t* uuid = (uint32_t*)0x1FFFF7E8;
-
-    // UUIDÓÉ3¸ö32λÕûÊý×é³É
-    snprintf(uuid_str, max_len, "%08X%08X%08X", uuid[0], uuid[1], uuid[2]);
-}
-
 void ipd_handler(at_urc_ctx_t *ctx)
 {
        int i;
@@ -785,10 +775,25 @@ int wifi_close( at_obj_t *at, int linkid )
     return ret;
 }
 
+char * wifi_softap_ssid( void )
+{
+    static char ssid[32];
+    uint32_t *uuid = (uint32_t*)0x1FFFF7E8;    // STM32F10xϵÁеÄUUIDµØÖ·Îª0x1FFFF7E8
+
+    // ¶ÁÈ¡SSID
+    if( strlen( (char*)TmsKeyData.UserEquipmentNumber) ){
+               //ÓÐÓû§±àºÅ: Ê¹ÓÃÓû§±àºÅ
+        snprintf( ssid, sizeof(ssid),"BTCDBS_%s", TmsKeyData.UserEquipmentNumber);
+    }else{
+               //ûÓÐÓû§±àºÅ: Ê¹ÓÃMCUµÄUUID
+        snprintf( ssid, sizeof(ssid),"BTCDBS_%08X%08X%08X", uuid[0], uuid[1], uuid[2]);
+    }
+    return ssid;
+}
+
 int wifi_init(at_obj_t *at )
 {
        char ssid[64];
-       char uuid_str[25];
        char recvbuf[32];       //½ÓÊÕ»º³åÇø
 
        //ATÓ¦´ð
@@ -805,9 +810,8 @@ int wifi_init(at_obj_t *at )
        else if (at_do_cmd(at, &r, "AT+CWDHCPS=1,2880,\"192.168.4.4\",\"192.168.4.10\"" ) != AT_RET_OK)
                return -1; //AT+CWDHCPS=<enable>,<lease time>,<start IP>,<end IP>
 
-       // ÉèÖôøMCU UUIDµÄsoftAPÃû³Æ
-       get_mcu_uuid(uuid_str, sizeof(uuid_str));
-       snprintf(ssid, sizeof(ssid), "AT+CWSAP=\"BTCDBS_%s\",\"12345678\",5,3", uuid_str);
+       //ÉèÖÃsoftAPÃû³Æ
+       snprintf(ssid, sizeof(ssid), "AT+CWSAP=\"%s\",\"12345678\",5,3", wifi_softap_ssid());
        if (at_do_cmd(at, &r, ssid) != AT_RET_OK)
                return -1;
 
@@ -875,13 +879,12 @@ void wifi_task(void *pvParameters)
         } else {
             // ³¬Ê±´¥·¢£¬¼ì²éÁ¬½Ó³¬Ê±
             uint32_t current_ts = xTaskGetTickCount();
-            const uint32_t timeout_ms = 1 * 60 * 1000; // 1·ÖÖÓ³¬Ê±
 
             for (i = 0; i < 5; i++) {
                 if (g_srv.dev[i].connected) {
-                    if ((current_ts - g_srv.dev[i].active_ts) > pdMS_TO_TICKS(timeout_ms)) {
+                    if ((current_ts - g_srv.dev[i].active_ts) > pdMS_TO_TICKS( TCP_TIMEOUT_MS )) {
 
-                        // Á¬½Ó³¬Ê±£¬¹Ø±ÕÁ¬½Ó
+                        //Á¬½Ó5·ÖÖÓ³¬Ê±£¬¹Ø±ÕÁ¬½Ó
                         printf("Link %d timeout, closing...\n", i);
                         if( wifi_close(&wifi_at, i) == 0 ){
                             // ¸üÐÂÁ¬½Ó״̬
index 8945704afa0e393482ebd811cde046ef4c37ee5c..d9252b142e51affe45e5cd87597e7478d2edcc04 100644 (file)
@@ -7,6 +7,8 @@
 #include "lcdshow.h"
 #include "Buttonmenu.h"
 
+#define TCP_TIMEOUT_MS (5 * 60 * 1000) // 5·ÖÖÓ³¬Ê±
+
 extern char SN[]; //VN²ÎÊý´æ´¢Çø
 
 //1. ¶ÁÐÅÏ¢ ÃüÁîRSVI »ØÓ¦ASVI