BluetoothRemoteGATTServer - 表示远程设备上的 GATT 服务器
非标准
该功能是非标准的。请尽量不要在生产环境中使用它:因为每个用户不一定会正常运行。它的实现可能存在很大的不兼容性,并且将来可能会改变行为。
BluetoothRemoteGATTServer 是 Web 蓝牙 API 的接口,表示远程设备上的 GATT 服务器。
本页面描述了 W3C 社区组 Web 蓝牙 API。有关 Firefox OS Bluetooth API,请参阅
BluetoothGattService。
接口
interface BluetoothRemoteGATTServer {
readonly attribute BluetoothDevice device;
readonly attribute boolean connected;
Promise<BluetoothRemoteGATTServer> connect();
void disconnect();
Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service);
Promise<sequence<BluetoothRemoteGATTService>> getPrimaryServices(optional BluetoothServiceUUID service);
};
属性
BluetoothRemoteGATTServer.connected 只读
一个布尔值,当该脚本执行环境连接到 this.device 时,返回 true。当用户代理通过物理上连接时,可能返回 false。
BluetoothRemoteGATTServer.device 只读
运行服务器的 BluetoothDevice 的引用。
方法
BluetoothRemoteGATTServer.connect()
使脚本执行环境连接到 this.device 。
BluetoothRemoteGATTServer.disconnect()
使脚本执行环境与 this.device 断开连接。
BluetoothRemoteGATTServer.getPrimaryService()
返回蓝牙设备为指定的 BluetoothServiceUUID 提供的主要 BluetoothGATTService 的 Promise 对象。
BluetoothRemoteGATTServer.getPrimaryServices()
返回蓝牙设备为指定的 BluetoothServiceUUID 提供的主要 BluetoothGATTService 对象列表的 Promise 对象。
规范
| 规范 | 状态 | 备注 |
|---|---|---|
| Web Bluetooth | 草稿 | 初始定义。 |
桌面浏览器兼容性
| 特性 | Chrome | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| 基础支持 | 45.0 [1] | ||||
| 52.0 [2] | 未知 | 未知 | 未知 | 未知 |
移动浏览器兼容性
| 特性 | Android | Android Webview | Firefox Mobile | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|---|
| 基础支持 | 不支持 | 不支持 | 未知 | 未知 | 未知 | 未知 | 未知 | 52.0 [2] |
[1] 通过配置控制。仅限 Chrome 操作系统。
[2] 仅限 Chrome 原始试用版。