【问题标题】:BluetoothGattCallback - onConnectionStateChange returns status22BluetoothGattCallback - onConnectionStateChange 返回 status22
【发布时间】:2015-10-04 16:30:01
【问题描述】:

我正在开发一个 Android 应用程序来连接蓝牙模块双模式。

由于模块是双模式,我遇到了与here描述的相同的问题。

但是我试图做一个解决方法,因为在第一次连接后回调 onConnectionStateChange() 返回状态 133。总是在 Main Activity 的 onStop() 方法中,我关闭 BluetoothGatt 对象以释放资源。在 bluetooth.close() 之前进一步添加了 bluetoothGatt.disconnect()。

当调用disconnect()时,我的手机与模块建立了更多的连接,但是有时在重新连接后,回调onConnectionStateChange返回状态22。

我在 BluetoothGatt 文档中没有找到关于状态 22 的信息。

更新 BLE callbacks are passed status codes that are not in the public API. 的话题是关于状态 22 等。

谢谢

【问题讨论】:

    标签: android android-bluetooth


    【解决方案1】:

    133 错误代码:连接超时或未找到设备。

    22错误码:蓝牙关闭,设备断开。

    22错误代码:本地主机终止连接错误代码表示本地设备终止了连接。

    【讨论】:

    • 22 由蓝牙标准定义。它的意思是“本地主机终止连接错误代码表示本地设备终止了连接。”
    • 这里有一个文档链接真是太好了。我想处理所有这些状态代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多