May 19, 2021 WeChat Mini Program Development Document
Base library 1.6.0 starts to support, and low versions need to be compatible.
Turn off the Wi-Fi module.
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Error code | The error message | Description |
---|---|---|
0 | Ok | Normal |
12000 | not init |
The
startWifi
first
|
12001 | system not support | The current system does not support related capabilities |
12002 | password error Wi-Fi | The password is wrong |
12003 | connection timeout | The connection timed out |
12004 | duplicate request | Connect Wi-Fi repeatedly |
12005 | wifi not turned on | Android is special and the Wi-Fi switch is not turned on |
12006 | gps not turned on | Android is special and the GPS positioning switch is not turned on |
12007 | user denied | The user refuses to authorize the link Wi-Fi |
12008 | invalid SSID | The SSID is not valid |
12009 | system config err | The system carrier configuration refuses to connect to Wi-Fi |
12010 | system internal error | System other errors that need to be printed in errmsg for specific error reasons |
12011 | weapp in background | The app cannot configure Wi-Fi in the background |
12013 | wifi config may be expired | The System Saved Wi-Fi configuration is out of date and it is recommended to try again after forgetting Wi-Fi |
wx.stopWifi({
success (res) {
console.log(res.errMsg)
}
})
Base library 1.6.0 starts to support, and low versions need to be compatible.
Initialize the Wi-Fi module.
Attributes | type | Defaults | Required | illustrate |
---|---|---|---|---|
success | function | no | Interface call successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Error code | The error message | Description |
---|---|---|
0 | Ok | Normal |
12000 | not init |
The
startWifi
first
|
12001 | system not support | The current system does not support related capabilities |
12002 | password error Wi-Fi | The password is wrong |
12003 | connection timeout | The connection timed out |
12004 | duplicate request | Connect Wi-Fi repeatedly |
12005 | wifi not turned on | Android is special and the Wi-Fi switch is not turned on |
12006 | gps not turned on | Android is special and the GPS positioning switch is not turned on |
12007 | user denied | The user refuses to authorize the link Wi-Fi |
12008 | invalid SSID | The SSID is not valid |
12009 | system config err | The system carrier configuration refuses to connect to Wi-Fi |
12010 | system internal error | System other errors that need to be printed in errmsg for specific error reasons |
12011 | weapp in background | The app cannot configure Wi-Fi in the background |
12013 | wifi config may be expired | The System Saved Wi-Fi configuration is out of date and it is recommended to try again after forgetting Wi-Fi |
wx.startWifi({
success (res) {
console.log(res.errMsg)
}
})
Base library 1.6.0 starts to support, and low versions need to be compatible.
Set up information about the AP in wifiList. Called after the onGetWifiList callback, iOS has a special interface.
Property | Type | The default | Required | Description |
---|---|---|---|---|
wifiList | Array.<Object> | Is | Provides a preset list of Wi-Fi information | |
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
The structure of object.wifiList
Property | Type | The default | Required | Description |
---|---|---|---|---|
Ssid | string | Whether | The SSID for Wi-Fi | |
BSSID | string | Whether | BSSID for Wi-Fi | |
password | string | Whether | Wi-Fi device password |
Error code | The error message | Description |
---|---|---|
0 | Ok | Normal |
12000 | not init |
The
startWifi
first
|
12001 | system not support | The current system does not support related capabilities |
12002 | password error Wi-Fi | The password is wrong |
12003 | connection timeout | The connection timed out |
12004 | duplicate request | Connect Wi-Fi repeatedly |
12005 | wifi not turned on | Android is special and the Wi-Fi switch is not turned on |
12006 | gps not turned on | Android is special and the GPS positioning switch is not turned on |
12007 | user denied | The user refuses to authorize the link Wi-Fi |
12008 | invalid SSID | The SSID is not valid |
12009 | system config err | The system carrier configuration refuses to connect to Wi-Fi |
12010 | system internal error | System other errors that need to be printed in errmsg for specific error reasons |
12011 | weapp in background | The app cannot configure Wi-Fi in the background |
12013 | wifi config may be expired | The System Saved Wi-Fi configuration is out of date and it is recommended to try again after forgetting Wi-Fi |
wx.onGetWifiList(function(res) {
if (res.wifiList.length) {
wx.setWifiList({
wifiList: [{
SSID: res.wifiList[0].SSID,
BSSID: res.wifiList[0].BSSID,
password: '123456'
}]
})
} else {
wx.setWifiList({
wifiList: []
})
}
})
wx.getWifiList()
Base library 1.6.0 starts to support, and low versions need to be compatible.
Listen for Wi-Fi events on the connection
The callback function for events connected to Wi-Fi
Property | Type | Description |
---|---|---|
Wifi | WifiInfo | Wi-Fi information |
Base library 1.6.0 starts to support, and low versions need to be compatible.
Listen to get data events to the Wi-Fi list
Gets the callback function to the Wi-Fi list data event
Property | Type | Description |
---|---|---|
wifiList | Array.<WifiInfo> | Wi-Fi list data |
Base library 2.9.0 starts to support, and low versions need to be compatible.
Cancels listening for Wi-Fi events on the connection.
The callback function for events connected to Wi-Fi
Base library 2.9.0 starts to support, and low versions need to be compatible.
Cancel listening to get data events to Wi-Fi lists.
Gets the callback function to the Wi-Fi list data event
Base library 1.6.0 starts to support, and low versions need to be compatible.
Request a list of Wi-Fi. R eturn wifiList data in a callback registered onGetWifiList. The user authorization scope.userLocation is required before android calls can be made.
iOS will jump to the system's Wi-Fi interface, and Android won't. B oth versions of iOS 11.0 and iOS 11.1 failed due to system problems. However, it was fixed in iOS 11.2.
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Error code | The error message | Description |
---|---|---|
0 | Ok | Normal |
12000 | not init |
The
startWifi
first
|
12001 | system not support | The current system does not support related capabilities |
12002 | password error Wi-Fi | The password is wrong |
12003 | connection timeout | The connection timed out |
12004 | duplicate request | Connect Wi-Fi repeatedly |
12005 | wifi not turned on | Android is special and the Wi-Fi switch is not turned on |
12006 | gps not turned on | Android is special and the GPS positioning switch is not turned on |
12007 | user denied | The user refuses to authorize the link Wi-Fi |
12008 | invalid SSID | The SSID is not valid |
12009 | system config err | The system carrier configuration refuses to connect to Wi-Fi |
12010 | system internal error | System other errors that need to be printed in errmsg for specific error reasons |
12011 | weapp in background | The app cannot configure Wi-Fi in the background |
12013 | wifi config may be expired | The System Saved Wi-Fi configuration is out of date and it is recommended to try again after forgetting Wi-Fi |
Base library 1.6.0 starts to support, and low versions need to be compatible.
Gets Wi-Fi information in connection.
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Property | Type | Description |
---|---|---|
Wifi | WifiInfo | Wi-Fi information |
Error code | The error message | Description |
---|---|---|
0 | Ok | Normal |
12000 | not init |
The
startWifi
first
|
12001 | system not support | The current system does not support related capabilities |
12002 | password error Wi-Fi | The password is wrong |
12003 | connection timeout | The connection timed out |
12004 | duplicate request | Connect Wi-Fi repeatedly |
12005 | wifi not turned on | Android is special and the Wi-Fi switch is not turned on |
12006 | gps not turned on | Android is special and the GPS positioning switch is not turned on |
12007 | user denied | The user refuses to authorize the link Wi-Fi |
12008 | invalid SSID | The SSID is not valid |
12009 | system config err | The system carrier configuration refuses to connect to Wi-Fi |
12010 | system internal error | System other errors that need to be printed in errmsg for specific error reasons |
12011 | weapp in background | The app cannot configure Wi-Fi in the background |
12013 | wifi config may be expired | The System Saved Wi-Fi configuration is out of date and it is recommended to try again after forgetting Wi-Fi |
Base library 1.6.0 starts to support, and low versions need to be compatible.
Connect to Wi-Fi. I f Wi-Fi information is known, the interface can be used directly to connect. Only android and iOS 11 versions are supported.
Property | Type | The default | Required | Description | The lowest version |
---|---|---|---|---|---|
Ssid | string | Is | Wi-Fi device SSID | ||
BSSID | string | Whether | Wi-Fi device BSSID | ||
password | string | Is | Wi-Fi device password | ||
maunal | boolean | false | Whether | Jump to the system settings page to connect, android only | 2.12.0 |
success | function | Whether | The interface calls a successful callback function | ||
fail | function | Whether | The interface calls the failed callback function | ||
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Error code | The error message | Description |
---|---|---|
0 | Ok | Normal |
12000 | not init |
The
startWifi
first
|
12001 | system not support | The current system does not support related capabilities |
12002 | password error Wi-Fi | The password is wrong |
12003 | connection timeout | The connection timed out |
12004 | duplicate request | Connect Wi-Fi repeatedly |
12005 | wifi not turned on | Android is special and the Wi-Fi switch is not turned on |
12006 | gps not turned on | Android is special and the GPS positioning switch is not turned on |
12007 | user denied | The user refuses to authorize the link Wi-Fi |
12008 | invalid SSID | The SSID is not valid |
12009 | system config err | The system carrier configuration refuses to connect to Wi-Fi |
12010 | system internal error | System other errors that need to be printed in errmsg for specific error reasons |
12011 | weapp in background | The app cannot configure Wi-Fi in the background |
12013 | wifi config may be expired | The System Saved Wi-Fi configuration is out of date and it is recommended to try again after forgetting Wi-Fi |
wx.connectWifi({
SSID: '',
password: '',
success (res) {
console.log(res.errMsg)
}
})
Wifi information
The SSID for Wi-Fi
BSSID for Wi-Fi
Whether Wi-Fi is secure
Wi-Fi signal strength
Base library 2.12.0 starts to support, and low versions need to be compatible.
Wi-Fi band unit MHz