From 0b3b6af9776d68c08cadbf5e19adabd690b48a91 Mon Sep 17 00:00:00 2001 From: "lxbpxylps@126.com" Date: Wed, 6 Oct 2021 19:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20WLAN=20=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=20TCP=20=E5=8D=8F=E8=AE=AE=E4=BB=A5?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E6=9C=8D=E5=8A=A1=E7=AB=AF=E5=8F=98=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User/APP_Setting/APP_Setting.c | 21 +++++++++++++-------- User/APP_Weather/APP_Weather.c | 2 +- User/WLAN/WLAN.c | 15 --------------- User/WLAN/WLAN.h | 1 - 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/User/APP_Setting/APP_Setting.c b/User/APP_Setting/APP_Setting.c index 852b783..bc7535a 100644 --- a/User/APP_Setting/APP_Setting.c +++ b/User/APP_Setting/APP_Setting.c @@ -1,5 +1,7 @@ //系统设置应用 +#include "string.h" + #include "sys.h" #include "systick.h" @@ -68,17 +70,20 @@ void APP_Setting_Launcher(void) if (WLAN_CheckNet()) { - uint8_t temp_ip_str[20]; - uint8_t temp_ipaddr_str[40]; + uint8_t temp_ipaddr_str[60]; - Delay_ms(50); - if (WLAN_GetIP(temp_ip_str) != 1) - strcpy(temp_ip_str, "查询失败"); - Delay_ms(50); - if (WLAN_GetIPAddr(temp_ipaddr_str) != 1) + Delay_ms(2000); + if (WLAN_GetIPAddr(temp_ipaddr_str)) + { + char *ret = strrchr(temp_ipaddr_str, '&'); + *ret = '\n'; + } + else + { strcpy(temp_ipaddr_str, "查询失败"); + } - sprintf(temp_str, "网络已连接\n\nIP地址:%s\nIP归属地:%s", temp_ip_str, temp_ipaddr_str); + sprintf(temp_str, "网络已连接\n\nIP地址及归属地:\n%s", temp_ipaddr_str); } else { diff --git a/User/APP_Weather/APP_Weather.c b/User/APP_Weather/APP_Weather.c index a6a3ed0..f99ae22 100644 --- a/User/APP_Weather/APP_Weather.c +++ b/User/APP_Weather/APP_Weather.c @@ -42,7 +42,7 @@ uint8_t APP_Weather_Sync(void); */ void APP_Weather_Launcher(void) { - APP_Weather_SetCity("汉中"); + APP_Weather_SetCity("杭州"); GE_Draw_ClrAll(WHITE); diff --git a/User/WLAN/WLAN.c b/User/WLAN/WLAN.c index 7221c37..89557c0 100644 --- a/User/WLAN/WLAN.c +++ b/User/WLAN/WLAN.c @@ -26,27 +26,12 @@ uint8_t WLAN_CheckNet(void) return 0; } -uint8_t WLAN_GetIP(uint8_t *ip_str) -{ - HC25_ClearReceive; - HC25_SendBuff("ip", 3); - - ip_str[0] = '\0'; - - if (HC25_ReceiveBuffUntil(ip_str, '\n', 1000) && strcmp(ip_str, "OK") == 0) - if (HC25_ReceiveBuffUntil(ip_str, '\n', 1000)) - return 1; - - return 0; -} - uint8_t WLAN_GetIPAddr(uint8_t *ipaddr_str) { HC25_ClearReceive; HC25_SendBuff("ipaddr", 7); ipaddr_str[0] = '\0'; - if (HC25_ReceiveBuffUntil(ipaddr_str, '\n', 1000) && strcmp(ipaddr_str, "OK") == 0) if (HC25_ReceiveBuffUntil(ipaddr_str, '\n', 1000)) return 1; diff --git a/User/WLAN/WLAN.h b/User/WLAN/WLAN.h index 731ad3e..b073866 100644 --- a/User/WLAN/WLAN.h +++ b/User/WLAN/WLAN.h @@ -8,7 +8,6 @@ #include "Clock.h" uint8_t WLAN_CheckNet(void); -uint8_t WLAN_GetIP(uint8_t *ip_str); uint8_t WLAN_GetIPAddr(uint8_t *ipaddr_str); uint8_t WLAN_GetNetClockTime(uint8_t *clock_time_str); uint8_t WLAN_GetWeather(uint8_t *weather_str, uint8_t *city_str);