Skip to main content

BluetoothRemoteGATTServer.connect()

BFChainInterfaceBluetoothRemoteGATTServerconnectLess than 1 minute

BluetoothRemoteGATTServer.connect() connects to the current Bluetooth server;

BluetoothRemoteGATTServer.connect()

参数

  • none

返回值

Returns a Promise; resolve fulfills a current BluetoothRemoteGATTServer 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.addEventListener(
        "gattserverdisconnected",
        () => {
          bluetoothRemoteGATTServer.connect();
        }
      )
    }
  })
  .catch(err => console.error(err))

Platform Compatibility

Property/Method/EventAndroidIOSDesktop-DevDesktop
connectX

BluetoothRemoteGATTServer

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