当前位置:网站首页>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);
}边栏推荐
- Summary of reasons for web side automation test failure
- 六月份阶段性大总结之Doris/Clickhouse/Hudi一网打尽
- Velodyne configuration command
- Hands on deep learning (44) -- seq2seq principle and Implementation
- Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
- leetcode1-3
- system design
- Ruby时间格式转换strftime毫秒匹配格式
- AUTOSAR从入门到精通100讲(106)-域控制器中的SOA
- RHCE - day one
猜你喜欢

For programmers, if it hurts the most...

Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)

Architecture introduction

Tables in the thesis of latex learning

基于线性函数近似的安全强化学习 Safe RL with Linear Function Approximation 翻译 1

用数据告诉你高考最难的省份是哪里!

Qtreeview+ custom model implementation example

技术管理进阶——如何设计并跟进不同层级同学的绩效

5g/4g wireless networking scheme for brand chain stores

Normal vector point cloud rotation
随机推荐
How can Huawei online match improve the success rate of player matching
Custom type: structure, enumeration, union
Talk about scalability
2020-03-28
2021-08-10 character pointer
PHP代码审计3—系统重装漏洞
A little feeling
7-17 crawling worms (15 points)
Basic principle of servlet and application of common API methods
基于线性函数近似的安全强化学习 Safe RL with Linear Function Approximation 翻译 1
MySQL develops small mall management system
Realsense of d435i, d435, d415, t265_ Matching and installation of viewer environment
直方图均衡化
Rhsca day 11 operation
Vs201 solution to failure to open source file HPP (or link library file)
RHCE - day one
El Table Radio select and hide the select all box
Tables in the thesis of latex learning
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
Realsense d435 d435i d415 depth camera obtains RGB map, left and right infrared camera map, depth map and IMU data under ROS