BluetoothRemoteGATTService.getCharacteristic()
InterfaceBluetoothRemoteGATTServicegetCharacteristicLess than 1 minute
BluetoothRemoteGATTService.getCharacteristic() queries the characteristic object of a certain service in the Bluetooth device;
BluetoothRemoteGATTService.getCharacteristic(uuid)
参数
uuid
The identifier of the bluetooth characteristic that needs to be queried;
The type of the parameter value is a string;
返回值
Returns a Promise, resolves to a BluetoothRemoteGATTCharacteristic 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;
return bluetoothRemoteGATTServer
.getPrimaryService("00003802-0000-1000-8000-00805f9b34fb")
}
})
.then(res => {
if(res.success){
const bluetoothRemoteGATTService = res.data;
bluetoothRemoteGATTService.getCharacteristic("00004a02-0000-1000-8000-00805f9b34fb")
}
})
.catch(err => console.error(err))
Platform Compatibility
Property/Method/Event | Android | IOS | Desktop-Dev | Desktop |
---|---|---|---|---|
getCharacteristic | ✅ | ✅ | ✅ | X |
Related Links
Powered by Waline v2.15.7