当前位置:网站首页>Use of WiFi module based on wechat applet
Use of WiFi module based on wechat applet
2022-04-23 14:04:00 【one billion twenty-nine million one hundred and seventy-nine th】
This article is mainly written based on wechat applet wifi Module USES , Mainly write 4 Features ,wifi The initialization 、 Get the surrounding wifi list 、 Connect wifi And get a connection wifi Basic information of .
1、wifi The initialization ,wifi Before using the module , Must be initialized .
2、 Get the surrounding wifi list , Get... Near you wifi Basic information of the list ,wifi name ,mac Address , Basic information such as signal strength , Through these, we can locate .
3、 Connect wifi, know wifi Account and password can connect .
4、 Get the connection wifi Basic information of , You don't need an account and password to get , And the connection above wifi It doesn't matter. . What you get is that the mobile phone is connected wifi.
Here is the specific code
(1)wxml
<view class="scan">
<view class="time-section">
<view class="time">
<view class="hourminuts">
<text>{
{hours}}:{
{minutes}}</text>
</view>
<view class="seconds">
<text>{
{seconds}}</text>
</view>
</view>
<view class="date">
<text>{
{month}} month {
{day}} Japan {
{week}}</text>
</view>
</view>
<view class="footer">
<button class="to-clock" hover-class="hover-to-clock" bindtap="toClock"> initialization wifi</button>
<button class="to-clock" hover-class="hover-to-clock" bindtap="toClock1">WiFi The list of data </button>
<button class="to-clock" hover-class="hover-to-clock" bindtap="toClock2"> Connect wifi</button>
<button class="to-clock" hover-class="hover-to-clock" bindtap="toClock3"> Get connected wifi Information </button>
</view>
<view class="date">
<text>{
{count4}}</text>
</view>
</view>
(2)css
/* pages/scan/scan.wxss */
page {
background-color: #fafafa;
}
.name {
margin-top: 20rpx;
margin-bottom: 40rpx;
line-height: 32px;
font-size: 17.25pt;
color: #000000;
}
.time-section {
margin-top: 110rpx;
}
.time {
display: flex;
flex-direction: row;
justify-content: center;
}
.hourminuts {
line-height: 154rpx;
font-size: 41.25pt;
color: rgba(0, 0, 0, 0.87);
}
.seconds {
line-height: 72rpx;
font-size: 18.75pt;
color: #f5a623;
margin: auto 0rpx 20rpx 0rpx;
}
.date {
margin-top: 12rpx;
text-align: center;
font-weight: 500;
line-height: 22px;
font-size: 12pt;
color: rgba(0, 0, 0, 0.54);
margin-bottom: 120rpx;
}
.footer {
/*display: flex;
flex-direction: column;
justify-content: center;*/
/*align-items: center;*/
margin: 0 auto;
width: 80%;
}
.to-clock {
background-color: #22a1e0;
color: #ffffff;
margin-bottom: 40rpx;
}
.hover-to-clock {
opacity: 0.7;
}
.to-list {
color: rgba(0, 0, 0, 0.54);
margin-bottom: 40rpx;
}
.hover-to-list {
opacity: 0.7;
}
(3)js Code
1)wifi initialization
// initialization wifi
toClock(){
wx.startWifi({
success (res) {
console.log(" initialization wifi Module success "+res.errMsg)
}
})
},
2) Get the surrounding wifi list
//wifi Data list Get the surrounding wifi list
toClock1(){
wx.getWifiList({
success:function(res){
// console.log(" To obtain a list of "+res);
// console.log(" To obtain a list of "+res.wifi);
wx.onGetWifiList(function (res) {
var len=res.wifiList.length
for(var i=0;i<len;i++){
console.log(res.wifiList[i])
}
console.log(res.wifiList[0])// Other business codes
})
},
complete: (res) => {
},
})
},
3) Connect wifi
// Connect wifi
toClock2(){
var pass="Xys147258369."
var zh="XYS1"
wx.connectWifi({
SSID:zh,
password:pass,
success (res) {
console.log(" Connect wifi success ")
},
fail(res){
console.log(" The connection fails "+res.errCode+" "+res.errMsg);
}
})
},
4) Get the connection wifi essential information ( account number 、 Password and signal strength )
// Get connected wifi Information
toClock3(){
var that = this;
wx.getConnectedWifi({
success(res){
console.log(" Successfully get connected wifi Information ")
console.log(res.wifi.SSID+" "+res.wifi.BSSID+" "+res.wifi.secure+" "+res.wifi.signalStrength);
var wifi = res.wifi;
that.setData({
mySSID:wifi.SSID,
myBSSID:wifi.BSSID,
mysecure:wifi.secure,
mysignalStrength:wifi.signalStrength,
})
},
complete: (res) => {
console.log(" Getting information ")
},
})
},
Search for WeChat official account : The small white XBIT
Reply key :wifi
Other keywords :ibeacon、 QR code access control
版权声明
本文为[one billion twenty-nine million one hundred and seventy-nine th]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231401298212.html
边栏推荐
- Yarn online dynamic resource tuning
- Interesting talk about network protocol
- 村上春树 --《当我谈跑步时,我谈些什么》句子摘录
- Program compilation and debugging learning record
- 微信小程序 input隐藏和不可操作的设置
- PATH环境变量
- JS 力扣刷题 103. 二叉树的锯齿形层序遍历
- mysql新表,自增id长达20位,原因竟是......
- Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
- 读了一篇博客,重新理解闭包整理一下
猜你喜欢

Node接入支付宝开放平台的沙箱实现支付功能

Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计

Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)

使用Postman进行Mock测试

1256: bouquet for algenon

Call wechat customer service applet

As a junior college student, I studied hard in closed doors for 56 days, won Ali offer with tears, five rounds of interviews and six hours of soul torture

Basic knowledge learning record

Wechat applet

Jenkins construction and use
随机推荐
Intégration de Clusters CDH Phoenix basée sur la gestion cm
centOS下mysql主从配置
Yarn online dynamic resource tuning
POI operation word template replaces data and exports word
Qt Designer怎样加入资源文件
微信小程序基于udp协议与esp8266进行通信
Quartus prime hardware experimental development (de2-115 board) experiment 1 CPU instruction calculator design
L2-024 tribe (25 points)
Jenkins construction and use
Force deduction brush question 101 Symmetric binary tree
Universal template for scikit learn model construction
趣谈网络协议
Haruki Murakami -- Excerpt from "what do I talk about when I talk about running"
json反序列化匿名数组/对象
JS 力扣刷题 102. 二叉树的层序遍历
How does redis solve the problems of cache avalanche, cache breakdown and cache penetration
FBS(fman build system)打包
Atcoder beginer contest 248c dice sum (generating function)
记录一个奇怪的bug:缓存组件跳转之后出现组件复制
Go语言 RPC通讯