3

我在 Android 上创建了蓝牙 Gatt 服务器:我能够实现/配置新服务(感谢https://github.com/androidthings/sample-bluetooth-le-gattserver),但不幸的是,我不是能够改变服务的“外观”。

据我了解,我需要修改通用访问配置文件(https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile)的外观特征,但我被卡住了,因为它没有退出,如果尝试创建它,它会失败并出现 status=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

4

0 回答 0