The method of utilizing this API is wx.onWifiConnected(function listener).
Attributes | Types | Note |
wifi | Wi-Fi Information |
The method of utilizing this API is wx.onWifiConnected(function listener).
Attributes | Types | Note |
wifi | Wi-Fi Information |
const listener = function (res) { console.log(res) }wx.onWifiConnected(listener)wx.offWifiConnected(listener) // Pass in the same function object as the listener.
The usage method for this API is wx.stopWifi(Object object)
Attributes | Types | Default value | Required | Note |
success | function | - | Not required | Callback function for successful interface invocation |
fail | function | - | Not required | Callback function for unsuccessful interface invocation |
complete | function | - | Not required | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Error Codes | Error Message | Note |
0 | ok | Normal |
12000 | not init | The startWifi interface was not invoked beforehand. |
12001 | system not support | The current system does not support the relevant capabilities. |
12002 | password error Wi-Fi | The password is incorrect. |
12003 | connection timeout | Connection timeout, supported only on Android. |
12004 | duplicate request | Repeated connection to Wi-Fi. |
12005 | wifi not turned on | Exclusive to Android, the Wi-Fi switch has not been turned on. |
12006 | gps not turned on | Exclusive to Android, the GPS location switch has not been turned on. |
12007 | user denied | The user has denied authorization to connect to Wi-Fi. |
12008 | invalid SSID | Invalid SSID. |
12009 | system config err | The system operator configuration has denied the connection to Wi-Fi. |
12010 | system internal error | System miscellaneous error, it is necessary to print the specific error reason in errmsg. |
12011 | weapp in background | The application is unable to configure Wi-Fi while running in the background. |
12013 | wifi config may be expired | The system's saved Wi-Fi configuration has expired. It is recommended to forget the Wi-Fi and retry. This is only supported on Android. |
12014 | invalid WEP / WPA password | Specific to iOS, the WEP/WPA password is invalid. |
wx.stopWifi({success (res) {console.log(res.errMsg)}})
The usage method for this API is wx.startWifi(Object object).
Attributes | Types | Default value | Required | Note |
success | function | - | Not required | Callback function for successful interface invocation |
fail | function | - | Not required | Callback function for unsuccessful interface invocation |
complete | function | - | Not required | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Error Codes | Error Message | Note |
0 | ok | Normal |
12000 | not init | The startWifi interface was not invoked beforehand. |
12001 | system not support | The current system does not support the relevant capabilities. |
12002 | password error Wi-Fi | The password is incorrect. |
12003 | connection timeout | Connection timeout, supported only on Android. |
12004 | duplicate request | Repeated connection to Wi-Fi. |
12005 | wifi not turned on | Exclusive to Android, the Wi-Fi switch has not been turned on. |
12006 | gps not turned on | Exclusive to Android, the GPS location switch has not been turned on. |
12007 | user denied | The user has denied authorization to connect to Wi-Fi. |
12008 | invalid SSID | Invalid SSID. |
12009 | system config err | The system operator configuration has denied the connection to Wi-Fi. |
12010 | system internal error | System miscellaneous error, it is necessary to print the specific error reason in errmsg. |
12011 | weapp in background | The application is unable to configure Wi-Fi while running in the background. |
12013 | wifi config may be expired | The system's saved Wi-Fi configuration has expired. It is recommended to forget the Wi-Fi and retry. This is only supported on Android. |
12014 | invalid WEP / WPA password | Specific to iOS, the WEP/WPA password is invalid. |
wx.startWifi({success (res) {console.log(res.errMsg)}})
The usage method for this API is wx.onGetWifiList(function listener).
Attributes | Types | Note |
wifiList | Array.<WifiInfo> | Wi-Fi List Data |
The usage method for this API is wx.offGetWifiList(function listener).
const listener = function (res) { console.log(res) }wx.onWifiConnected(listener)wx.offWifiConnected(listener) // Pass in the same function object as the listener.
The usage method for this API is wx.getConnectedWifi(Object object).
Attributes | Types | Default value | Required | Note |
partialInfo | boolean | false | Not required | Whether partial Wi-Fi information needs to be returned. |
success | function | - | Not required | Callback function for successful interface invocation |
fail | function | - | Not required | Callback function for unsuccessful interface invocation |
complete | function | - | Not required | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attributes | Types | Note |
wifi | Wi-Fi Information |
Error Codes | Error Message | Note |
0 | ok | Normal |
12000 | not init | The startWifi interface was not invoked beforehand. |
12001 | system not support | The current system does not support the relevant capabilities. |
12002 | password error Wi-Fi | The password is incorrect. |
12003 | connection timeout | Connection timeout, supported only on Android. |
12004 | duplicate request | Repeated connection to Wi-Fi. |
12005 | wifi not turned on | Exclusive to Android, the Wi-Fi switch has not been turned on. |
12006 | gps not turned on | Exclusive to Android, the GPS location switch has not been turned on. |
12007 | user denied | The user has denied authorization to connect to Wi-Fi. |
12008 | invalid SSID | Invalid SSID. |
12009 | system config err | The system operator configuration has denied the connection to Wi-Fi. |
12010 | system internal error | System miscellaneous error, it is necessary to print the specific error reason in errmsg. |
12011 | weapp in background | The application is unable to configure Wi-Fi while running in the background. |
12013 | wifi config may be expired | The system's saved Wi-Fi configuration has expired. It is recommended to forget the Wi-Fi and retry. This is only supported on Android. |
12014 | invalid WEP / WPA password | Specific to iOS, the WEP/WPA password is invalid. |
errCode:12010, errMsg: can't gain current wifi
or no wifi is connected
. If developers do not require a complete WifiInfo object, they can resolve the error issue by adopting the aforementioned strategy.
Was this page helpful?