Skip to main content

BluetoothRemoteGATTServer.getPrimaryService()

BFChainInterfaceBluetoothRemoteGATTServergetPrimaryServiceLess than 1 minute

Query a specific main service from the Bluetooth server

 BluetoothRemoteGATTServer.getPrimaryService(uuid)

参数

  • uuid

    The main service identifier to be queried; the type of the parameter value is BluetoothServiceUUID;

返回值

Returns a Promise object; resolve honors a BluetoothRemoteGATTService object

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 bluetoothRemoteGATTServer = res.data;
      bluetoothRemoteGATTServer
      .getPrimaryService("00003802-0000-1000-8000-00805f9b34fb")
    }
  })
  .catch(err => console.error(err))

Platform Compatibility

Property/Method/EventAndroidIOSDesktop-DevDesktop
getPrimaryServiceX

BluetoothRemoteGATTServer

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