add wifi icon
authorkyz <kongyuzhong@google.com>
Wed, 10 Dec 2025 09:19:20 +0000 (17:19 +0800)
committerkyz <kongyuzhong@google.com>
Fri, 12 Dec 2025 00:53:26 +0000 (08:53 +0800)
20240801完整版/扳手下位机软件/cpbs-202103-20240423/API/lcdpic.h
20240801完整版/扳手下位机软件/cpbs-202103-20240423/APP/uishow.c
20240801完整版/扳手下位机软件/cpbs-202103-20240423/APP/wifi.c

index 17c68bd562a4bc2a08e2b3eecd66b723641adafb..726ee6b2454ced5976547a9357839b8f1e7c5e45 100644 (file)
@@ -190,3 +190,26 @@ const unsigned char gImage_dusu[200] = { /* 0X00,0X01,0X24,0X00,0X24,0X00, */
 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00
 };
+
+// WiFiͼ±ê 32*32
+const unsigned char pic_wifi_32x32[128] = { /* 0X00,0X01,0X20,0X00,0X20,0X00, */
+0X00,0X07,0XF0,0X00,0X00,0X3F,0XFE,0X00,0X00,0XFF,0XFF,0X00,0X03,0XFF,0XFF,0XC0,
+0X07,0XFF,0XFF,0XE0,0X0F,0XFF,0XFF,0XF8,0X3F,0XE0,0X0F,0XFC,0X7F,0X80,0X01,0XFE,
+0XFF,0X00,0X00,0XFF,0X7C,0X00,0X00,0X3E,0X38,0X00,0X00,0X1E,0X30,0X07,0XE0,0X0C,
+0X00,0X1F,0XF8,0X00,0X00,0X7F,0XFE,0X00,0X00,0XFF,0XFF,0X00,0X01,0XFF,0XFF,0X80,
+0X03,0XFF,0XFF,0XC0,0X03,0XF0,0X0F,0XC0,0X01,0XE0,0X07,0XC0,0X00,0X80,0X01,0X80,
+0X00,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XC0,0X00,0X00,0X07,0XF0,0X00,
+0X00,0X1F,0XF8,0X00,0X00,0X0F,0XF0,0X00,0X00,0X07,0XF0,0X00,0X00,0X07,0XE0,0X00,
+0X00,0X03,0XC0,0X00,0X00,0X01,0XC0,0X00,0X00,0X01,0X80,0X00,0X00,0X00,0X00,0X00,
+};
+
+const unsigned char pic_wifi_err_32x32[128] = { /* 0X00,0X01,0X20,0X00,0X20,0X00, */
+0X00,0X07,0XF0,0X04,0X00,0X3F,0XFE,0X0E,0X00,0XFF,0XFF,0X1E,0X03,0XFF,0XFF,0XFC,
+0X07,0XFF,0XFF,0XF8,0X0F,0XFF,0XFF,0XF8,0X3F,0XE0,0X0F,0XFC,0X7F,0X80,0X03,0XFE,
+0XFF,0X00,0X07,0XFF,0X7C,0X00,0X0F,0X3E,0X38,0X00,0X1E,0X1E,0X30,0X07,0XFC,0X0C,
+0X00,0X1F,0XFC,0X00,0X00,0X7F,0XFE,0X00,0X00,0XFF,0XFF,0X00,0X01,0XFF,0XFF,0X80,
+0X03,0XFF,0XFF,0XC0,0X03,0XFF,0X0F,0XC0,0X01,0XFE,0X07,0XC0,0X00,0XFC,0X01,0X80,
+0X00,0XF8,0X00,0X00,0X00,0XF0,0X00,0X00,0X01,0XE3,0XC0,0X00,0X03,0XC7,0XF0,0X00,
+0X07,0X9F,0XF8,0X00,0X0F,0X0F,0XF0,0X00,0X1E,0X07,0XF0,0X00,0X3C,0X07,0XE0,0X00,
+0X38,0X03,0XC0,0X00,0X10,0X01,0XC0,0X00,0X00,0X01,0X80,0X00,0X00,0X00,0X00,0X00,
+};
index a7329652c24ca8787a962c7a334035156e0581f2..27eb6938c4dc77b5c85b398715d385b16c37151f 100644 (file)
@@ -55,12 +55,26 @@ static void Versions_Interface(void);
 
 static void TorqueAngle_Interface(SetParameter_t* pdata, InterfaceState_t* InterfaceState);  // Å¤¾Ø½Ç¶Èģʽ½çÃæ
 
+void wifi_icon_update( int force )
+{
+    static int last_wifi_state = -1;
+    int wifi_state;
 
+    wifi_state = Get_Wifi_Status();
+    if( !force && last_wifi_state == wifi_state ){
+            return;
+    }
 
+    last_wifi_state = wifi_state;
 
-
-
-
+    if( wifi_state == -1 ){
+        LCD_Picture(204,4,32,32,pic_wifi_err_32x32, GRAY);
+    }else if( wifi_state == 0 ){
+        LCD_Picture(204,4,32,32,pic_wifi_32x32, LIGHTBLUE);
+    }else{
+        LCD_Picture(204,4,32,32,pic_wifi_32x32, 0x0A80);
+    }
+}
 
 /*******************************************************************************
 * Function Name  : UiShow_task
@@ -1078,7 +1092,10 @@ void Setting_Interface(SetParameter_t* pdata,_calendar_obj* Time,InterfaceState_
         LCD_ShowInt_U32(0,48*4,p_UsageCounter,6,BLUE,BACKGROUND);  
         
         LastInterfaceID = SET_INTERFACE_ID;
+
+        wifi_icon_update( 1 );
     } else {
+        wifi_icon_update( 0 );
         if(LastLanguage != p_Language || LastStandard != p_Standard || LastCurPos != 
                 I_CursorPosition  || LastSelectState != I_SelectedState)
         {
index 72ec56c9f7460e2786ad707bad6cf80e57ab38eb..f8725558b84ac11416787700d520316b43771f48 100644 (file)
 #include "../FreeRTOS/include/FreeRTOS.h"
 #include "../FreeRTOS/include/task.h"
 
+static int g_wifi_st = -1;
 
 TaskHandle_t WifiTask_Handler = NULL;
 TaskHandle_t AtTask_Handler = NULL;
 
+typedef struct{
+       uint8_t data;
+}wrench_server_t;
+
 // ÃüÁî½âÎöÏà¹Ø¶¨Òå
 typedef struct {
     char mid[5];      // ÃüÁîID£¬ÈçRSVI¡¢RSTSµÈ
@@ -310,11 +315,31 @@ void ipd_handler(at_urc_ctx_t *ctx)
     }
 }
 
+void connect_handler(at_urc_ctx_t *ctx)
+{
+       int linkid;
+    printf("connect handler, ctx:%p\n", ctx);
+       if( sscanf( ctx->buf, "%d,CONNECT", &linkid ) == 1 ){
+               printf( "LINK:%d    ---> CONNECT!\n", linkid );
+        g_wifi_st = 1;
+       }
+}
+
+void closed_handler(at_urc_ctx_t *ctx)
+{
+       int linkid;
+    printf("closed handler, ctx:%p\n", ctx);
+       if( sscanf( ctx->buf, "%d,CLOSED", &linkid ) == 1 ){
+               printf( "LINK:%d    ---> CLOSED!\n", linkid );
+        g_wifi_st = 0;
+       }
+}
+
 urc_item_t wifi_utc_tbl[]={
-       {
+       { "+IPD", "\r\n", ipd_handler },
+       { "CONNECT", "\r\n", connect_handler },
+    { "CLOSED", "\r\n", closed_handler },
 
-               "+IPD", "\r\n", ipd_handler
-       },
 };
 
 
@@ -405,6 +430,41 @@ static bool wifi_tcp_send( const void *buf, unsigned int len)
        return at_do_work(&wifi_at, (at_work)tcp_send_handler, &tx_data);
 }
 
+int wifi_cipstate( at_obj_t *at )
+{
+       int ret = 0;
+    //AT+CIPSTATE?
+    //ÏìÓ¦£ºµ±ÓÐÁ¬½Óʱ£¬ AT ·µ»Ø£º
+    //+CIPSTATE:<link ID>,<"type">,<"remote IP">,<remote port>,<local port>,<tetype>
+    //OK
+    //µ±Ã»ÓÐÁ¬½Óʱ£¬ AT ·µ»Ø£º
+    //OK
+    //return 0: Î´Á¬½Ó    ´óÓÚ0: Á¬½ÓÊý    -1: Ä£¿éͨÐŹÊÕÏ
+       //½ÓÊÕ»º³åÇø
+    char *p;
+    int linkid;
+       char recvbuf[256];
+       //ATÓ¦´ð
+       at_respond_t r = {"OK", NULL, sizeof(recvbuf), 3000};
+       r.recvbuf = recvbuf;
+       //
+       if (at_do_cmd(at, &r, "AT+CIPSTATE?") != AT_RET_OK){
+               ret = -1;
+       }else{
+               ret  = 0;
+               p = strstr( recvbuf, "+CIPSTATE:");
+               while(p){
+                       if( sscanf(p, "+CIPSTATE:%d", &linkid) == 1){
+                               printf( "read wifi cipstate, linkid:%d\n", linkid );
+                               ret++;
+                       }
+                       p = strstr( p+10, "+CIPSTATE:");
+               }
+       }
+    return ret;
+
+}
+
 int wifi_init(at_obj_t *at )
 {
        //½ÓÊÕ»º³åÇø
@@ -427,6 +487,7 @@ int wifi_init(at_obj_t *at )
        else if (at_do_cmd(at, &r, "AT+CIPSERVER=1,8888") != AT_RET_OK)
                return -1;      //AT+CIPSERVER=1
 
+    g_wifi_st = 0;
        printf( "wifi init ok\n" );
        return 0;
 }
@@ -490,8 +551,15 @@ void wifi_task(void *pvParameters)
             size_t min_free_heap = xPortGetMinimumEverFreeHeapSize();
             printf("FreeRTOS Heap Status - Free: %u bytes, Min Free: %u bytes\n", 
                    (unsigned int)free_heap, (unsigned int)min_free_heap);
+
+            wifi_cipstate(&wifi_at); //check wifi connection status
         }
 
         vTaskDelay(10);
     }
 }
+
+int Get_Wifi_Status( void )
+{
+    return g_wifi_st;
+}