# wx.setWifiList(Object object)
Start from base library version 1.6.0. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Support, need to Mini Program base library version no less than 2.9.1
Set up wifiList
in AP For information about. in onGetWifiList
Called after the callback,IOS specific interface。
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
wifiList | Array.<Object> | yes | Provides default Wi-Fi Information list | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.wifiList Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
SSID | string | no | Wi-Fi of SSID | |
BSSID | string | no | Wi-Fi of BSSID | |
password | string | no | Wi-Fi Device Password |
# error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
12000 | not init | Uncalled startWifi interface |
12001 | system not support | Current system does not support related capabilities |
12002 | password error Wi-Fi | Password error |
12003 | connection timeout | Connection Timeout |
12004 | duplicate request | Repeat connection Wi-Fi |
12005 | wifi not turned on | Android Unique, unopened Wi-Fi switch |
12006 | gps not turned on | Android Unique, unopened GPS Positioning switch |
12007 | user denied | User denied authorization link Wi-Fi |
12008 | invalid SSID | invalid SSID |
12009 | system config err | System Operator Configuration Denial of Connection Wi-Fi |
12010 | system internal error | Other system errors require a errmsg Print the specific reason for the error |
12011 | weapp in background | Application cannot be configured in the background Wi-Fi |
12013 | wifi config may be expired | System saved Wi-Fi Configuration expired, recommended to forget Wi-Fi Retry |
# Be careful
- This interface can be used only in
onGetWifiList
Callback before calling. - At this point, the client hangs up and waits for the Mini Programs to set Wi-Fi Information, be sure to call this interface as soon as possible, and pass in an empty array if no data is available.
- It's possible that with the surrounding area Wi-Fi List refresh, a single process received multiple times with the presence of duplicate Wi-Fi A callback to the list.
# sample code
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()