preface
Recently, the project team involved wechat applets with bluetooth device connection requirements, now the whole connection development process is recorded as follows:
-
Wx. OpenBluetoothAdapter (OBJECT)
-
Obtain bluetooth adapter status, determine whether bluetooth is available wx. OpenBluetoothAdapter (OBJECT)
-
Began to search the bluetooth wx. StartBluetoothDevicesDiscovery (OBJECT)
-
Get all discovered Bluetooth devices wx.getBluetoothDevices(OBJECT)
-
Listen to find new equipment event wx. OnBluetoothDeviceFound (the CALLBACK)
-
Enable obtaining a Connected Bluetooth device. After obtaining the device successfully, connect the low-power Bluetooth device according to the characteristic value. Wx.createbleconnection (OBJECT)
-
Get all services wx.getBleDeviceservices (OBJECT)
-
Get a bluetooth device in a service all characteristic (eigenvalues) wx. GetBLEDeviceCharacteristics (OBJECT)
-
Enable low-power bluetooth device feature values change notify wx. NotifyBLECharacteristicValueChange (OBJECT)
-
Bluetooth to wx. WriteBLECharacteristicValue (OBJECT)
Development flow chart
reference
Wechat applets development document