# wx.onBLEConnectionStateChange(function callback)

Start from base library version 1.1.0. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support, need to Mini Program base library version no less than 2.9.1

Listens for Bluetooth low-power connection state change events. Including developers active connection or disconnect, device loss, abnormal connection disconnection, etc.

# parameter

# function callback

Callback function for Bluetooth low power connection state change event

# parameter

# Object object
attribute type Introductions
deviceId string Bluetooth Device id
connected boolean Are you connected?

# sample code

Preview with Developer Tool

wx.onBLEConnectionStateChange(function(res) {
  // This method callback can be used to handle exceptions such as unexpected disconnections
  console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)