我想知道如何显示服务

时间:2019-01-29 11:02:11

标签: java android bluetooth

我目前正在开发bluetooth芯片,我想展示其功能。

我正在尝试方法getService();,但是此方法返回给我null

private final BluetoothGattCallback mGattCallback =
        new BluetoothGattCallback() {
            @Override
            public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
                String intentAction;
                if (newState == BluetoothProfile.STATE_CONNECTED) {
                    intentAction = ACTION_GATT_CONNECTED;
                    mConnectionState = STATE_CONNECTED;
                    broadcastUpdate(intentAction);
                    Log.i(TAG, "Connected to GATT server.");
                    Log.i(TAG, "Attempting to start service discovery:" +
                            mBluetoothGatt.discoverServices());
                    Log.i(TAG, "Attempting to start service discovery:" +
                            mBluetoothGatt.getService(UUID.fromString(SampleGattAttributes.UUID_Address)));


                } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                    intentAction = ACTION_GATT_DISCONNECTED;
                    mConnectionState = STATE_DISCONNECTED;
                    Log.i(TAG, "Disconnected from GATT server.");
                    broadcastUpdate(intentAction);
                }
            }
        };

我想在日志中显示特征列表。 预先感谢您的帮助

0 个答案:

没有答案