BluetoothGattCallback永远不会发生?状态= 0?

Kev*_*ins 6 android bluetooth bluetooth-lowenergy android-bluetooth

更新:问题无关紧要.仔细的调试表明它正在达到连接状态的变化.我只需要了解更多android-studio内置的工具.阅读android网站上的GATT文档显示Status = 0表示连接成功,而不是我认为的某些空状态.

对于其他关注GATT状态的人,可以在此处找到文档:https: //developer.android.com/reference/android/bluetooth/BluetoothGatt.html

原文:我正在尝试使用Android studio连接到蓝牙LE设备,并且能够找到它并尝试连接到它.设备停止闪烁,表示它仍然连接,但我无法让代码到达我的BluetoothGattCallback.日志也会读取

D/BluetoothGatt: onSearchComplete() = Device=F4:B8:5E:A6:CE:D0 Status=0
06-06 16:35:09.682 17511-19374/com.somesite.dl503.vacuumgauge D/BluetoothGatt: onClientConnParamsChanged() - Device=F4:B8:5E:A6:CE:D0 interval=39 status=0
06-06 16:35:13.112 17511-17522/com.somesite.dl503.vacuumgauge D/BluetoothGatt: onClientConnParamsChanged() - Device=F4:B8:5E:A6:CE:D0 interval=15 status=0
Run Code Online (Sandbox Code Playgroud)

有没有其他人遇到Status = 0或者它从未进入Gatt回调?

通过代码连接:

mConnectedGatt = device.connectGatt(this, false, mGattCallback, BluetoothDevice.TRANSPORT_AUTO);
Run Code Online (Sandbox Code Playgroud)

我的Gatt回调onConncectionStateChange应该首先调用,对吧?

@Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {

            if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_CONNECTED) {
                gatt.discoverServices();
            } else if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_DISCONNECTED) {

            } else if (status != BluetoothGatt.GATT_SUCCESS) {

                gatt.disconnect();
            }
        }
Run Code Online (Sandbox Code Playgroud)