小编Sun*_*nny的帖子

BLE Gatt onConnectionStateChange 失败,状态 133 和 257

我正在尝试将我的信标连接到 Gattservice。在回调 onConnectionStateChange 中,它总是失败,我得到了

状态代码 133 和 257。

Somehwere 写道,133 代表许多联系。在我的代码中,有一些带有 gatt.disconnect() 的行。我不知道如何解决它,因为所有其他 gatt 示例都是相同的。如果发现错误很重要,我正在使用 Android 6.0.1 版本和 API 23。这是我的代码:

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

        if(status == BluetoothGatt.GATT_SUCCESS) {
            switch (newState) {
                case BluetoothProfile.STATE_CONNECTED:
                    mBleDevices.add(gatt.getDevice());
                    Log.i("Beacons", "STATE_CONNECTED");

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mBluetoothGatt.discoverServices();
                        }
                    });
                    break;
                case BluetoothProfile.STATE_DISCONNECTED:
                    Log.e("Beacons", "STATE_DISCONNECTED");
                    mBleDevices.remove(gatt.getDevice());
                    mBluetoothGatt.disconnect();
                    mBluetoothGatt = null;
                    break;
                default:
                    Log.e("Beacons", "STATE_OTHER");
            }
        } else {
            Log.e("Beacons", "ERROR WITH CONNECTING " + status);
            mBleDevices.remove(gatt.getDevice());
        }
 } …
Run Code Online (Sandbox Code Playgroud)

android bluetooth-lowenergy gatt beacon

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

beacon ×1

bluetooth-lowenergy ×1

gatt ×1