当前位置:网站首页>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 error: missing delimiter (. Inserted) {\xi \left( {p,{p_q}} \right)} \right|}}
- Differences among opencv versions
- 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
- uniapp 处理过去时间对比现在时间的时间差 如刚刚、几分钟前,几小时前,几个月前
- Es advanced series - 1 JVM memory allocation
- C language pointer classic interview question - the first bullet
- 用数据告诉你高考最难的省份是哪里!
- Online troubleshooting
- Lavel document reading notes -how to use @auth and @guest directives in lavel
- 使用 C# 提取 PDF 文件中的所有文字(支持 .NET Core)
猜你喜欢

Matlab tips (25) competitive neural network and SOM neural network

MySQL develops small mall management system
What are the advantages of automation?

Application of safety monitoring in zhizhilu Denggan reservoir area

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

Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)

Number of relationship models

【Day2】 convolutional-neural-networks

Hands on deep learning (46) -- attention mechanism

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
随机推荐
Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
智能网关助力提高工业数据采集和利用
品牌连锁店5G/4G无线组网方案
MySQL case
2021-08-10 character pointer
有老师知道 继承RichSourceFunction自定义读mysql怎么做增量吗?
View CSDN personal resource download details
Mmclassification annotation file generation
今日睡眠质量记录78分
2021-08-11 function pointer
Hands on deep learning (38) -- realize RNN from scratch
uniapp---初步使用websocket(长链接实现)
How can people not love the amazing design of XXL job
System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
[200 opencv routines] 218 Multi line italic text watermark
Use C to extract all text in PDF files (support.Net core)
Map container
RHCE day 3
Hands on deep learning (46) -- attention mechanism
Batch distribution of SSH keys and batch execution of ansible