蓝牙gatt服务器:如何设置外观特征?

时间:2018-02-09 19:39:02

标签: bluetooth-lowenergy android-things bluetooth-gatt

我在Android上创建了一个蓝牙Gatt服务器:我能够实现/配置一项新服务(感谢https://github.com/androidthings/sample-bluetooth-le-gattserver),但不幸的是,我无法更改&#34 ;外观"服务。

根据我的理解,我需要修改通用访问配置文件(https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile)的外观特征,但是因为它没有退出而被卡住了,如果尝试创建它,它就会失败状态= 133错误。 (https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.1_r13/stack/include/gatt_api.h

final UUID SERVICE_GENERIC_ACCESS = UUID.fromString("00001800-0000-1000-8000-00805f9b34fb");
final UUID CHARACTERISTIC_APPEARANCE = UUID.fromString("00002a01-0000-1000-8000-00805f9b34fb");

BluetoothManager mBluetoothGattServer = mBluetoothManager.openGattServer(this, mGattServerCallback);
BluetoothGattService genericService =  mBluetoothGattServer.getService(SERVICE_GENERIC_ACCESS);
BluetoothGattService genericService = new BluetoothGattService(
            SERVICE_GENERIC_ACCESS,
            BluetoothGattService.SERVICE_TYPE_PRIMARY);
BluetoothGattCharacteristic icon = new BluetoothGattCharacteristic(CHARACTERISTIC_APPEARANCE, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ);
mBluetoothGattServer.addService(genericService);

public void onServiceAdded(int status, BluetoothGattService service) {
// Fails with error 133
}

任何帮助将不胜感激!

干杯

d

0 个答案:

没有答案