mirror of
https://git.aixiao.me/aixiao/Danger-alarm.git
synced 2025-07-29 19:13:39 +08:00
测试WIFI先扫描SID
This commit is contained in:
@@ -194,7 +194,21 @@ static TCP_CLIENT_T* tcp_client_init(void) {
|
||||
DEBUG_printf("failed to allocate state\n"); // 分配失败
|
||||
return NULL;
|
||||
}
|
||||
ip4addr_aton(TEST_TCP_SERVER_IP, &state->remote_addr); // 解析服务器IP地址
|
||||
|
||||
|
||||
// 如果 TEST_TCP_SERVER_IP 是 IP 地址,直接解析为 IP 地址
|
||||
if (ip4addr_aton(TEST_TCP_SERVER_IP, &state->remote_addr) == 0) {
|
||||
// 如果解析失败,尝试作为域名解析
|
||||
DEBUG_printf("Failed to parse IP address, trying DNS resolution\n");
|
||||
|
||||
err_t err = dns_gethostbyname(TEST_TCP_SERVER_IP, &state->remote_addr, NULL, NULL);
|
||||
if (err != ERR_OK) {
|
||||
DEBUG_printf("DNS resolution failed\n");
|
||||
free(state);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user