当前位置:网站首页>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
边栏推荐
- Basic knowledge learning record
- AtCoder Beginner Contest 248C Dice Sum (生成函数)
- 全局变量能否放在头文件中定义
- 基于ibeacons三点定位(微信小程序)
- Universal template for scikit learn model construction
- switch使用(微信小程序)
- 室内外地图切换(室内基于ibeacons三点定位)
- mysql通过binlog文件恢复数据
- Record a strange bug: component copy after cache component jump
- Cdh6 based on CM management 3.2 cluster integration atlas 2 one
猜你喜欢
修改ddt生成的测试用例名称
PyMySQL
记录一个奇怪的bug:缓存组件跳转之后出现组件复制
Lin Lin, product manager of Lenovo: network failure of local network operator in Tianjin. The background server of Zui system can't work normally for the time being
Choreographer full resolution
微信小程序获取登录用户信息、openid和access_token
Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
1256:献给阿尔吉侬的花束
Wechat applet
mysql新表,自增id长达20位,原因竟是......
随机推荐
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
JS 力扣刷题 102. 二叉树的层序遍历
Expression「Func「TSource, object」」 转Expression「Func「TSource, object」」[]
About note 1
程序编译调试学习记录
分库分表 & ShardingSphere
scikit-learn構建模型的萬能模板
基于CM管理的CDH集群集成Phoenix
基于CM管理的CDH6.3.2集群集成Atlas2.1.0
33 million IOPs, 39 microsecond delay, carbon footprint certification, who is serious?
request模块
基于Ocelot的gRpc网关
微信小程序获取登录用户信息、openid和access_token
Strange bug of cnpm
FBS(fman build system)打包
金蝶云星空API调用实践
Jacob print word
修改ddt生成的测试用例名称
Universal template for scikit learn model construction
JMeter pressure test tool