WeChat small program Bluetooth
May 18, 2021
WeChat Mini Program Development Document
Table of contents
Bluetooth
iOS WeChat Client version 6.5.6 is supported and Android 6.5.7 version is starting to be supported
The Bluetooth adapter module has an
effective cycle of calling wx.openBluetoothAdapter until
the call
wx.closeBluetoothAdapter or
small program is destroyed.
During the period when the small program Bluetooth adapter module takes effect, the developer is able to call the Bluetooth-related small program API normally and receive a callback to the event related to the Bluetooth module.
Attention
-
Due to system limitations, the deviceId obtained on Android is the device MAC address, and on iOS is the device uuid.
Therefore, deviceId cannot be hard-coded into code.
-
Currently does not support the debugging of Bluetooth function on developer tools, you need to use a real machine to call the small program Bluetooth interface normally.
Bluetooth Low Energy (BLE) considerations
-
Read, write, notify operations on feature values on iOS, because the system needs to get instances of feature values, the incoming serviceId and characteristicId must be obtained by wx.getBLEDevice Services and wx.getBLEDeviceCharacteristics before they can be used.
It is recommended that dual-platform unification perform wx.getBLEDeviceServices and wx.getBLEDeviceCharacteristics before interacting with data from Bluetooth devices.