当前位置:网站首页>Hlk-w801wifi connection
Hlk-w801wifi connection
2022-07-04 10:21:00 【Spring, spring】
Don't talk too much nonsense, just go to the code , Ask me or comment directly if you have any questions .
#include "wm_include.h"
#include "wm_wifi_oneshot.h"
const char ssid[] = "SSID";
const char pwd[] = "PASSWORD";
static void con_net_status_changed_event(u8 status )
{
switch(status)
{
case NETIF_WIFI_JOIN_SUCCESS:
printf("WIFI Network connection successful \n");
break;
case NETIF_WIFI_JOIN_FAILED:
printf("WIFI Network connection failed \n");
break;
case NETIF_WIFI_DISCONNECTED:
printf("WIFI Network disconnected \n");
break;
case NETIF_IP_NET_UP:
{
struct tls_ethif *tmpethif = tls_netif_get_ethif();
print_ipaddr(&tmpethif->ip_addr);
// If there is IPV6, stay demo/wm_demo.h Open it inside TLS_CONFIG_IPV6
#if TLS_CONFIG_IPV6
print_ipaddr(&tmpethif->ip6_addr[0]);
print_ipaddr(&tmpethif->ip6_addr[1]);
print_ipaddr(&tmpethif->ip6_addr[2]);
#endif
}
break;
default:
//printf("UNKONWN STATE:%d\n", status);
break;
}
}
void UserMain(void) {
int demo_connect_net(char *ssid, char *pwd) {
struct tls_param_ip *ip_param = NULL;
u8 wireless_protocol = 0;
if (!ssid) {
return WM_FAILED;
}
printf("\nssid:%s\n", ssid);
printf("password=%s\n", pwd);
tls_wifi_disconnect();
tls_param_get(TLS_PARAM_ID_WPROTOCOL, (void *) &wireless_protocol, TRUE);
if (TLS_PARAM_IEEE80211_INFRA != wireless_protocol) {
tls_wifi_softap_destroy();
wireless_protocol = TLS_PARAM_IEEE80211_INFRA;
tls_param_set(TLS_PARAM_ID_WPROTOCOL, (void *) &wireless_protocol, FALSE);
}
tls_wifi_set_oneshot_flag(0);
ip_param = tls_mem_alloc(sizeof(struct tls_param_ip));
if (ip_param) {
tls_param_get(TLS_PARAM_ID_IP, ip_param, FALSE);
ip_param->dhcp_enable = TRUE;
tls_param_set(TLS_PARAM_ID_IP, ip_param, FALSE);
tls_mem_free(ip_param);
}
tls_netif_add_status_event(con_net_status_changed_event);
tls_wifi_connect((u8 *)ssid, strlen(ssid), (u8 *)pwd, strlen(pwd));
printf("\ Please wait for network connection ......\n");
return WM_SUCCESS;
}
// Connect WIFI
demo_connect_net(ssid,pwd);
}边栏推荐
- 智慧路灯杆水库区安全监测应用
- Latex insert picture, insert formula
- Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
- Golang Modules
- Legion is a network penetration tool
- MySQL develops small mall management system
- What are the advantages of automation?
- Es entry series - 6 document relevance and sorting
- Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
- Hands on deep learning (39) -- gating cycle unit Gru
猜你喜欢
随机推荐
Exercise 7-2 finding the maximum value and its subscript (20 points)
Idea SSH channel configuration
Differences among opencv versions
Basic principle of servlet and application of common API methods
2021-08-10 character pointer
Kotlin 集合操作汇总
2020-03-28
Hands on deep learning (40) -- short and long term memory network (LSTM)
Rhcsa learning practice
Machine learning -- neural network (IV): BP neural network
Safety reinforcement learning based on linear function approximation safe RL with linear function approximation translation 1
Exercise 7-3 store the numbers in the array in reverse order (20 points)
AUTOSAR从入门到精通100讲(106)-域控制器中的SOA
Rhcsa12
leetcode1-3
7-17 crawling worms (15 points)
Es advanced series - 1 JVM memory allocation
PHP code audit 3 - system reload vulnerability
转载:等比数列的求和公式,及其推导过程
2. Data type









