HomeDocs
跳到主要内容

dlt.onBLEConnectionStateChange(function listener)

简介

监听蓝牙设备连接状态

使用限制

必须在调用 dlt.createBLEConnection 之前注册

参数

function listener

蓝牙设备连接状态变化事件的监听函数

参数

Object res

属性类型说明
addressstring蓝牙设备的 mac 地址
statusnumber当前状态
newStatenumber蓝牙设备连接状态

status 状态说明

status说明
0A GATT operation completed successfully
2GATT read operation is not permitted
3GATT write operation is not permitted
5Insufficient authentication for a given operation
6The given request is not supported
7A read or write operation was requested with an invalid offset
13A write operation exceeds the maximum length of the attribute
15Insufficient encryption for a given operation
143A remote device connection is congested
257A GATT operation failed, errors other than the above

newState 状态说明

newState说明
0The profile is in disconnected state
1The profile is in connecting state
2The profile is in connected state
3The profile is in disconnecting state

示例代码

dlt.onBLEConnectionStateChange(function (res) {
console.log(res);
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.