# wx.onBLECharacteristicValueChange(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

Monitor eigenvalue change events for Bluetooth low-power devices. Must be invoked first wx.notifyBLECharacteristicValueChange Interface to receive the device push notification。

# parameter

# function callback

Callback Functions for Eigenvalue Change Events of Bluetooth Low Power Devices

# parameter

# Object res
attribute type Introductions
deviceId string Bluetooth Device id
serviceId string Bluetooth Feature Corresponding Service UUID
characteristicId string Bluetooth characteristic UUID
value ArrayBuffer Characteristic latest value

# sample code

Preview with Developer Tool

// ArrayBuffer to hexadecimal string example
function ab2hex(buffer) {
  let hexArr = Array.prototype.map.call(
    new Uint8Array(buffer),
    function(bit) {
      return ('00' + bit.toString(16)).slice(-2)
    }
  )
  return hexArr.join('')
}
wx.onBLECharacteristicValueChange(function(res) {
  console.log(`characteristic ${res.characteristicId} has changed, now is ${res.value}`)
  console.log(ab2hex(res.value))
})