mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-24 16:31:13 +01:00
Add generic service for immediate alert and prepare the code to support characteristics from different services
This commit is contained in:
parent
e3533a2b18
commit
720eaa111d
@ -39,6 +39,8 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
|||||||
public static final UUID UUID_DESCRIPTOR_CHARACTERISTIC_USER_CONFIGURATION = UUID.fromString(String.format(BASE_UUID, "2901"));
|
public static final UUID UUID_DESCRIPTOR_CHARACTERISTIC_USER_CONFIGURATION = UUID.fromString(String.format(BASE_UUID, "2901"));
|
||||||
public static final UUID UUID_DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION = UUID.fromString(String.format(BASE_UUID, "2902"));
|
public static final UUID UUID_DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION = UUID.fromString(String.format(BASE_UUID, "2902"));
|
||||||
|
|
||||||
|
//part of the generic BLE specs see https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.immediate_alert.xml
|
||||||
|
public static final UUID UUID_SERVICE_IMMEDIATE_ALERT = UUID.fromString((String.format(BASE_UUID, "1802")));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean connect() {
|
public boolean connect() {
|
||||||
@ -140,13 +142,13 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void gattServicesDiscovered(List<BluetoothGattService> discoveredGattServices) {
|
private void gattServicesDiscovered(List<BluetoothGattService> discoveredGattServices) {
|
||||||
mAvailableCharacteristics = null;
|
|
||||||
|
|
||||||
if (discoveredGattServices == null) {
|
if (discoveredGattServices == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<UUID> supportedServices = getSupportedServices();
|
Set<UUID> supportedServices = getSupportedServices();
|
||||||
|
mAvailableCharacteristics = new HashMap();
|
||||||
for (BluetoothGattService service : discoveredGattServices) {
|
for (BluetoothGattService service : discoveredGattServices) {
|
||||||
if (supportedServices.contains(service.getUuid())) {
|
if (supportedServices.contains(service.getUuid())) {
|
||||||
List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
|
List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
|
||||||
@ -154,10 +156,11 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
|||||||
LOG.warn("Supported LE service " + service.getUuid() + "did not return any characteristics");
|
LOG.warn("Supported LE service " + service.getUuid() + "did not return any characteristics");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mAvailableCharacteristics = new HashMap<>(characteristics.size());
|
HashMap<UUID, BluetoothGattCharacteristic> intmAvailableCharacteristics = new HashMap<>(characteristics.size());
|
||||||
for (BluetoothGattCharacteristic characteristic : characteristics) {
|
for (BluetoothGattCharacteristic characteristic : characteristics) {
|
||||||
mAvailableCharacteristics.put(characteristic.getUuid(), characteristic);
|
intmAvailableCharacteristics.put(characteristic.getUuid(), characteristic);
|
||||||
}
|
}
|
||||||
|
mAvailableCharacteristics.putAll(intmAvailableCharacteristics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user