需要 Scripting PRO
BluetoothService 表示一个 BLE(低功耗蓝牙)服务。服务是外围设备中功能的逻辑分组,包含一个或多个特征值(Characteristic),也可以包含对其他服务的引用(包含服务)。
每个服务都由一个唯一的 UUID 标识,用于描述设备提供的某项功能,例如:
"180F" 表示电池服务服务的主要用途是组织设备提供的数据和操作。
uuid: string服务的 UUID。
peripheralId: string | null所属外围设备的标识符(UUID 字符串)。
nullisPrimary: boolean是否为主服务。
true: 主服务,表示设备核心功能false: 次服务,通常被其他服务引用(嵌套)includedServices: BluetoothService[] | null包含服务(referenced services)的数组。
discoverIncludedServices(),此值为 nullBluetoothPeripheral.discoverIncludedServices(service) 方法获取characteristics: BluetoothCharacteristic[] | null当前服务下包含的特征值数组。
discoverCharacteristics(),此值为 nullBluetoothPeripheral.discoverCharacteristics(service) 方法获取discoverServices() 才能访问 characteristics 和 includedServices。