本文介绍了Android ble设备有时未断开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 完成可断开设备的连接后,我得到了断开回调.但是一段时间仍然没有断开.在某些层连接状态保持不变.这样我就无法重新连接.

我已经在android 5&中进行了测试安卓6.在HTC One A9中,Moto x播放,Moto G4

i have tested in android 5 & android 6.in HTC One A9, Moto x play, Moto G4

  • 如果我做蓝牙,请关闭电源.然后再次出现断开回调,设备实际上正在断开连接.-请提出解决问题的建议.
  • 我正在按照以下步骤操作
  • 1.发现ble设备.
  • If i do bluetooth turn on off. then again disconnect callback is coming and device is disconnecting actually.-Please give some suggestion for resolve issue.
  • I am doing below steps for ble operation
  • 1.Discover ble device.
  1. 连接到设备.
  2. onConnectionStateChange(已连接),我正在做gatt.discoverServices()
  3. onServicesDiscovered回调我正在读取特性5.onCharacteristicRead回调我正在做写特性.6.onCharacteristicWrite回调我正在做gatt.disconnect()
  4. onConnectionStateChange(已断开连接),我正在做gatt.close()
  1. Connect to device.
  2. onConnectionStateChange (connected) i am doing gatt.discoverServices()
  3. onServicesDiscovered callback i am reading characteristics5.onCharacteristicRead callback i am doing write characteristics.6.onCharacteristicWrite call back i am doing gatt.disconnect()
  4. onConnectionStateChange (disconnected) i am doing gatt.close()

在后台设备扫描的整个过程中.

In this full process in background device scanning is going on.

推荐答案

可以通过不调用stopScan()方法来解决此问题.请参阅SoroushA的评论完全断开蓝牙低功耗设备

this problem can be connected with not calling stopScan() method.see comment from SoroushATotally Disconnect a Bluetooth Low Energy Device

这篇关于Android ble设备有时未断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 03:58