# wx.startBluetoothDevicesDiscovery(Object object)

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

with Promise style call: Supported

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

Start searching for nearby Bluetooth peripherals.

This operation is more costly system resources, please search to the required equipment after the timely call wx.stopBluetoothDevicesDiscovery Stop the search.

# parameter

# Object object

attribute type Default values Required Introductions
services Array.&ltstring&gt 初始值 To search for the Bluetooth device master service UUID List support 16/32/128 position UUID)。 Some Bluetooth devices broadcast their own host service of UUID。 If this parameter is set, only the broadcast packets are searched for UUID The main service of the Bluetooth device. This parameter is recommended to filter out other Bluetooth devices that do not need to be handled around.
allowDuplicatesKey boolean false no Whether duplicate reporting of the same device is allowed. If duplicate reporting is allowed, the wx.onBlueToothDeviceFound Method will report to the same device multiple times, but RSSI Values will vary.
interval number 0 no Reporting Equipment Interval, Unit ms。 0 Indicates that the new device is reported as soon as it is found, and other values are reported according to the incoming interval.
powerLevel string medium no Scan mode, the higher the scan faster, the more power consumption. Android WeChat client only 7.0.12 And above support.
success function no Interface calls the successful callback function
fail function no Interface calls failed callback functions
complete function no Interface calls the end of the callback function (call success or failure will be executed)

object.powerLevel Legal value

value Introductions Minimum version
low low
medium in
high high

# error

Error code Error message Introductions
0 ok normal
-1 already connect Connected
10000 not init Uninitialized Bluetooth adapter
10001 not available The current Bluetooth adapter is not available
10002 No device Specified device not found
10003 connection fail Connection failure
10004 No service Specified service not found
10005 No characteristic Did not find the specified signature.
10006 No connection Current connection disconnected
10007 property not support Current feature does not support this operation
10008 system error All other system reported anomalies
10009 system not support Android System specific, system version below 4.3 Not supported WAS
10012 operate time out Connection Timeout
10013 invalid_data Connect deviceId Is empty or incorrectly formatted

# sample code

Preview with Developer Tool

// Take the Bluetooth smart light on the hardware platform of WeChat as an example, the main service UUID yes FEE7。 Pass this parameter, search only for the main service UUID for FEE7 Equipment
  services: ['FEE7'],
  success (res) {