Nik*_*ono 6 android bluetooth bluetooth-lowenergy gatt
我正在尝试通过安排计时器并BluetoothGatt.disconnect()手动调用在我的蓝牙 GATT 服务上实现我自己的超时。但是,如果从远程设备触发断开连接,则不会像通常发生的那样调用回调。还有一个日志来自BluetoothGatt调用断开函数
D/BluetoothGatt? cancelOpen() - device: 00:07:80:04:1A:5A
Run Code Online (Sandbox Code Playgroud)
这是我断开连接的代码
private void scheduleDisconnect() {
isTimerRunning = true;
disconnectTimer = new Timer();
disconnectTimer.schedule(new TimerTask() {
@Override
public void run() {
isTimerRunning = false;
disconnect();
}
}, 2000);
}
Run Code Online (Sandbox Code Playgroud)
为什么onConnectionStateChange不叫?它适用于另一个回调和操作
小智 0
要断开设备连接,我使用设备的 gatt 链接,并使用方法 BluetoothGatt.disconnect() 和 BluetoothGatt.close()。
这有效,但没有调用 onConnectionStateChange(),因为我关闭了通量。
| 归档时间: |
|
| 查看次数: |
7575 次 |
| 最近记录: |