mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-03 22:45:52 +01:00
reworked init process
This commit is contained in:
parent
aaa9e7bef2
commit
3f79592588
@ -121,6 +121,8 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
public QHybridSupport() {
|
public QHybridSupport() {
|
||||||
super(logger);
|
super(logger);
|
||||||
addSupportedService(UUID.fromString("3dda0001-957f-7d4a-34a6-74696673696d"));
|
addSupportedService(UUID.fromString("3dda0001-957f-7d4a-34a6-74696673696d"));
|
||||||
|
addSupportedService(UUID.fromString("0000180a-0000-1000-8000-00805f9b34fb"));
|
||||||
|
addSupportedService(UUID.fromString("00001800-0000-1000-8000-00805f9b34fb"));
|
||||||
IntentFilter commandFilter = new IntentFilter(QHYBRID_COMMAND_CONTROL);
|
IntentFilter commandFilter = new IntentFilter(QHYBRID_COMMAND_CONTROL);
|
||||||
commandFilter.addAction(QHYBRID_COMMAND_UNCONTROL);
|
commandFilter.addAction(QHYBRID_COMMAND_UNCONTROL);
|
||||||
commandFilter.addAction(QHYBRID_COMMAND_SET);
|
commandFilter.addAction(QHYBRID_COMMAND_SET);
|
||||||
@ -200,6 +202,12 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
||||||
|
|
||||||
|
for (int i = 2; i <= 7; i++)
|
||||||
|
builder.notify(getCharacteristic(UUID.fromString("3dda000" + i + "-957f-7d4a-34a6-74696673696d")), true);
|
||||||
|
|
||||||
|
builder.read(getCharacteristic(UUID.fromString("00002a00-0000-1000-8000-00805f9b34fb")));
|
||||||
|
builder.read(getCharacteristic(UUID.fromString("00002a24-0000-1000-8000-00805f9b34fb")));
|
||||||
|
builder.read(getCharacteristic(UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb")));
|
||||||
|
|
||||||
helper = new PackageConfigHelper(getContext());
|
helper = new PackageConfigHelper(getContext());
|
||||||
|
|
||||||
@ -219,23 +227,6 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServicesDiscovered(BluetoothGatt gatt) {
|
|
||||||
super.onServicesDiscovered(gatt);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 2; i <= 7; i++)
|
|
||||||
gatt.setCharacteristicNotification(getCharacteristic(UUID.fromString("3dda000" + i + "-957f-7d4a-34a6-74696673696d")), true);
|
|
||||||
|
|
||||||
BluetoothGattService deviceInfo = gatt.getService(UUID.fromString("0000180a-0000-1000-8000-00805f9b34fb"));
|
|
||||||
BluetoothGattCharacteristic modelNumber = deviceInfo.getCharacteristic(UUID.fromString("00002a24-0000-1000-8000-00805f9b34fb"));
|
|
||||||
|
|
||||||
gatt.readCharacteristic(modelNumber);
|
|
||||||
|
|
||||||
logger.debug("onServicesDiscovered");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotification(NotificationSpec notificationSpec) {
|
public void onNotification(NotificationSpec notificationSpec) {
|
||||||
Log.d("Service", "notif from " + notificationSpec.sourceAppId + " " + notificationSpec.sender + " " + notificationSpec.phoneNumber);
|
Log.d("Service", "notif from " + notificationSpec.sourceAppId + " " + notificationSpec.sender + " " + notificationSpec.phoneNumber);
|
||||||
@ -362,24 +353,14 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||||
switch (characteristic.getUuid().toString()){
|
switch (characteristic.getUuid().toString()){
|
||||||
case "00002a24-0000-1000-8000-00805f9b34fb":{
|
|
||||||
modelNumber = characteristic.getStringValue(0);
|
|
||||||
gbDevice.setModel(modelNumber);
|
|
||||||
|
|
||||||
BluetoothGattService genericAccess = gatt.getService(UUID.fromString("00001800-0000-1000-8000-00805f9b34fb"));
|
|
||||||
BluetoothGattCharacteristic deviceName = genericAccess.getCharacteristic(UUID.fromString("00002a00-0000-1000-8000-00805f9b34fb"));
|
|
||||||
|
|
||||||
gatt.readCharacteristic(deviceName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "00002a00-0000-1000-8000-00805f9b34fb":{
|
case "00002a00-0000-1000-8000-00805f9b34fb":{
|
||||||
String deviceName = characteristic.getStringValue(0);
|
String deviceName = characteristic.getStringValue(0);
|
||||||
gbDevice.setName(deviceName);
|
gbDevice.setName(deviceName);
|
||||||
|
break;
|
||||||
BluetoothGattService genericAccess = gatt.getService(UUID.fromString("0000180a-0000-1000-8000-00805f9b34fb"));
|
}
|
||||||
BluetoothGattCharacteristic firmwareVersion = genericAccess.getCharacteristic(UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb"));
|
case "00002a24-0000-1000-8000-00805f9b34fb":{
|
||||||
|
modelNumber = characteristic.getStringValue(0);
|
||||||
gatt.readCharacteristic(firmwareVersion);
|
gbDevice.setModel(modelNumber);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "00002a26-0000-1000-8000-00805f9b34fb":{
|
case "00002a26-0000-1000-8000-00805f9b34fb":{
|
||||||
|
Loading…
Reference in New Issue
Block a user