Я пытаюсь создать службу BLE (для Android) с несколькими характеристиками со свойствами READ и NOTIFY. Пока что я могу подключиться к серверу GATT и читать данные по каждой характеристике c. Также я могу подписаться на уведомления одного из них. Однако другая характеристика c, которая также имеет свойство NOTIFY, не позволяет мне подписаться. Я использую следующий код:
public static UUID SERVICE = UUID.fromString("00000010-0000-1000-8000-00805f9b34fb");
public static UUID CHARACTERISTIC = UUID.fromString("00000011-0000-1000-8000-00805f9b34fb");
public static UUID CHARACTERISTIC_2 = UUID.fromString("00000012-0000-1000-8000-00805f9b34fb");
public static UUID CLIENT_CONFIG = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
public static UUID CLIENT_CONFIG2 = UUID.fromString("00002903-0000-1000-8000-00805f9b34fb");
//Create a service
BluetoothGattService service = new BluetoothGattService(SERVICE, BluetoothGattService.SERVICE_TYPE_PRIMARY);
//CREATE THE FIRST CHARACTERISTIC
BluetoothGattCharacteristic Characteristic1 = new BluetoothGattCharacteristic(CHARACTERISTIC1,
BluetoothGattCharacteristic.PROPERTY_READ
| BluetoothGattCharacteristic.PROPERTY_NOTIFY
| BluetoothGattCharacteristic.PROPERTY_WRITE,
BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM
| BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM);
//Create a descriptor
BluetoothGattDescriptor rideDescriptor = new BluetoothGattDescriptor(CLIENT_CONFIG,
BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED_MITM
| BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED_MITM);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE THE SECOND CHARACTERISTIC
BluetoothGattCharacteristic Characteristic2 = new BluetoothGattCharacteristic(CHARACTERISTIC,
BluetoothGattCharacteristic.PROPERTY_NOTIFY
| BluetoothGattCharacteristic.PROPERTY_READ,
BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM
| BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM);
BluetoothGattDescriptor rideDescriptor2 = new BluetoothGattDescriptor(CLIENT_CONFIG2,
BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED_MITM
| BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED_MITM);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Add the characteristic and the descriptor to the service
Characteristic1.addDescriptor(rideDescriptor);
Characteristic2.addDescriptor(rideDescriptor2);
service.addCharacteristic(rideCharacteristic);
service.addCharacteristic(rideCharacteristic2); ```
I think it has something to do with the UUIDs but I'm not sure.
Any ideas?
Thanks in advance.