# Wireless LAN (Wi-Fi)

In the Mini Program to support the search for the surrounding Wi-Fi Device, and at the same time, the connection can be initiated with a password for the specified device.

This series of interfaces is system native capability. If you want to seeWeChat Link Wi-FiAbility and configuration jump Mini Program, please refer tofile

# 1. Connection Specified Wi-Fi equipment

If you know Wi-Fi Device name and password, and confirm that the device is nearby, you can specify the connection directly in the Mini Program Wi-Fi。

The interface call timing is:

  1. startWifi: to initialize Wi-Fi Modular
  2. connectWifi: Connect Wi-Fi(iOS need 11 The above version is supported)
  3. onWifiConnected: Connect on Wi-Fi The event callback

# 2. Connecting the perimeter Wi-Fi equipment

The Mini Program can be accessed by scanning a nearby Wi-Fi Device, allowing the user to select a device to connect.

Due to system limitations, the timing of interface calls varies on different platforms:

Android

  1. startWifi: to initialize Wi-Fi Modular
  2. getWifiList: Request to get around Wi-Fi list
  3. onGetWifiList: Get to the Wi-Fi List Data Events
  4. connectWifi: Connect Wi-Fi
  5. onWifiConnected: Connect on Wi-Fi The event callback

iOS

  1. startWifi: to initialize Wi-Fi Modular
  2. getWifiList: Request to get around Wi-Fi List. This interface will jump to the system settings in the WeChat settings page, need to guide the user intoWireless LANSettings page, manually connect the device.(iOS 11.0 and 11.1 Version failed due to system problems
  3. onGetWifiList: Get to the Wi-Fi List Data Events
  4. setWifiList: Set up Wi-Fi list in AP To assist the user to connect
  5. onWifiConnected: Connect on Wi-Fi The event callback

# 3. Wi-Fi Device communication under the network

adopt wx.getConnectedWifi Can get the current system connection Wi-Fi Information, after confirming that the current connection is the device Wi-Fi Then (the phone and the device are in the same LAN), you can use the relevant interface to communicate with the device.

# 4. Note

  • Android system 6.0 The above version, when the positioning switch is not turned on, the device will not be able to access the surrounding Wi-Fi Information.
  • Wi-Fi The associated interface is temporarily unavailable wx.canIUse Interface determination.