当前位置:网站首页>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);
}
边栏推荐
- Basic principle of servlet and application of common API methods
- Work order management system OTRs
- Kotlin: collection use
- 智能网关助力提高工业数据采集和利用
- Latex learning insertion number - list of filled dots, bars, numbers
- How can Huawei online match improve the success rate of player matching
- 【Day2】 convolutional-neural-networks
- Exercise 9-1 time conversion (15 points)
- Rhcsa - day 13
- Rhcsa12
猜你喜欢
Three schemes of ZK double machine room
leetcode842. Split the array into Fibonacci sequences
How can people not love the amazing design of XXL job
uniapp 处理过去时间对比现在时间的时间差 如刚刚、几分钟前,几小时前,几个月前
Devop basic command
Some summaries of the third anniversary of joining Ping An in China
Hands on deep learning (38) -- realize RNN from scratch
The time difference between the past time and the present time of uniapp processing, such as just, a few minutes ago, a few hours ago, a few months ago
If the uniapp is less than 1000, it will be displayed according to the original number. If the number exceeds 1000, it will be converted into 10w+ 1.3k+ display
PHP code audit 3 - system reload vulnerability
随机推荐
Check 15 developer tools of Alibaba
El Table Radio select and hide the select all box
2020-03-28
The future education examination system cannot answer questions, and there is no response after clicking on the options, and the answers will not be recorded
Normal vector point cloud rotation
Hands on deep learning (36) -- language model and data set
Number of relationship models
PHP代码审计3—系统重装漏洞
Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
Lavel document reading notes -how to use @auth and @guest directives in lavel
Golang defer
Whether a person is reliable or not, closed loop is very important
For programmers, if it hurts the most...
Basic principle of servlet and application of common API methods
品牌连锁店5G/4G无线组网方案
转载:等比数列的求和公式,及其推导过程
Today's sleep quality record 78 points
Button wizard business running learning - commodity quantity, price reminder, judgment Backpack
Talk about scalability
Ruby time format conversion strftime MS matching format