Skip to main content

BluetoothDevice

BFChainInterfaceBluetoothDeviceLess than 1 minute

Interface used to describe Bluetooth devices;

Property

  • id

    Unique identifier; attribute value is a string;

  • name

    The name of the device; the property value is a string

  • watchingAdvertisements

    Whether to listen to advertisements; the attribute value is a boolean

Method

Event

Example

  import { bluetoothPlugin } from "@plaoc/plugins";

  bluetoothPlugin
  .open()
  .then(res => {
    if(res.success){
      const options = {
        acceptAllDevices: true,
        optionalServices: ["00003802-0000-1000-8000-00805f9b34fb"],
      }
      return bluetoothPlugin.requestAndConnectDevice(options)
    }
  })
  .then(res => {
    if(res.success){
      // 成功的查询和连接了蓝牙设备;
      const bluetoothDevice = res.data.device;
      return bluetoothDevice
    }
  })
  .then(bluetoothDevice => {
    BluetoothDevice.forget()
  })
  .catch(err => console.error(err))

Platform Compatibility

Property/Method/EventAndroidIOSDesktop-DevDesktop
idX
nameX
watchingAdvertisementsX
forgetX
watchAdvertisementsX
event gattserverdisconnectedX
event advertisementreceivedX

BluetoothPlugin

Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v2.15.7