my.getBluetoothDevices

Use this API to get all the bluetooth devices that are discovered, including those that are connected to the current device.

Instructions:

  • You may not get the advertisData and RSSI in the simulator. Please debug in the production environment.
  • For Integrated Development Environment (IDE) and Android devices, the device ID is the MAC address of the device; for iOS devie, the device ID is the UUID of the device. Therefore, do not hard code the device ID. You need to process the device ID on different platforms; iOS devices can be dynamically matched based on properties such as localName, advertisData, and manufacturerData.

Note:
Currently simulation in IDE is not supported. Please debug in the production environment.

Code Sample

copy
my.getBluetoothDevices({
  success: (res) => {
    console.log(res)
  },
  fail:(res) => {
  },
  complete: (res)=>{
  }
});

Parameters

The input parameters are displayed in the following table:

PropertyTypeRequiredDescription
successFunctionNoThe callback function for a successful API call.
failFunctionNoThe callback function for a failed API call.
completeFunctionNoThe callback function for a completed API call (Regardless of whether the call is successful or not).

Success Callback Function

The input parameters are displayed in the following table:

PropertyTypeDescription
devicesArrayA list of all the devices that are discovered.

Device Object

PropertyTypeDescription
nameStringName of the bluetooth device.(For some devices, there's no name.)
deviceName(Compatibal with initial version)StringName of the bluetooth device.
localNameStringName of the local device.
deviceIdStringDevice ID
RSSINumberReceived Signal Strength Indicator
advertisDataHex StringAdvertisement data of the device
manufacturerDataHex StringManufacturer data of the device