Android蓝牙LE:连接后没有发现服务

时间:2014-06-03 21:46:34

标签: android bluetooth bluetooth-lowenergy android-bluetooth

我正在尝试使用Android的蓝牙低功耗与BLE设备进行通信。我第一次连接时,一切正常(连接到GATT服务器工作,发现所有服务和特性等)但是,如果我断开连接并尝试重新连接,它将连接到GATT服务器,但不会能够发现这些服务。我必须杀死应用程序并重新启动它,有时即使这样也行不通。

这是我用来与设备断开连接的代码:

public void close(View view) {
    if (mBluetoothGatt == null) {
        return;
    }
    mBluetoothGatt.close();
    mBluetoothGatt = null;
}

断开连接时还有什么需要做的吗?当我尝试重新连接时,似乎仍然存在一些仍然连接的资源阻止了服务的发现。

1 个答案:

答案 0 :(得分:2)

我似乎找到了解决方案:您需要同时拨打BluetoothGatt.disconnect()BluetoothGatt.close()

相关问题