dlt.onBLEConnectionStateChange(function listener)
简介
监听蓝牙设备连接状态
使用限制
必须在调用 dlt.createBLEConnection 之前注册
参数
function listener
蓝牙设备连接状态变化事件的监听函数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
address | string | 蓝牙设备的 mac 地址 |
status | number | 当前状态 |
newState | number | 蓝牙设备连接状态 |
status 状态说明
status | 说明 |
---|---|
0 | A GATT operation completed successfully |
2 | GATT read operation is not permitted |
3 | GATT write operation is not permitted |
5 | Insufficient authentication for a given operation |
6 | The given request is not supported |
7 | A read or write operation was requested with an invalid offset |
13 | A write operation exceeds the maximum length of the attribute |
15 | Insufficient encryption for a given operation |
143 | A remote device connection is congested |
257 | A GATT operation failed, errors other than the above |
newState 状态说明
newState | 说明 |
---|---|
0 | The profile is in disconnected state |
1 | The profile is in connecting state |
2 | The profile is in connected state |
3 | The profile is in disconnecting state |
示例代码
dlt.onBLEConnectionStateChange(function (res) {
console.log(res);
});