Skip to content

Commit ffe3d55

Browse files
committed
add digitail ble service
1 parent 2e21521 commit ffe3d55

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/Backend/Bluetooth/bluetooth_manager_plus.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class _OnDiscoveredServices extends _$OnDiscoveredServices {
143143
//Subscribes to all characteristics
144144
for (BluetoothService service in event.services) {
145145
BluetoothUartService? bluetoothUartService = uartServices.firstWhereOrNull(
146-
(element) => element.bleDeviceService.toLowerCase() == service.serviceUuid.str.toLowerCase(),
146+
(element) => element.bleDeviceService.toLowerCase() == service.serviceUuid.str128.toLowerCase(),
147147
);
148148
if (bluetoothUartService != null) {
149149
BaseStatefulDevice? statefulDevice = ref.read(knownDevicesProvider)[event.device.remoteId.str];
@@ -319,7 +319,7 @@ class _OnCharacteristicReceived extends _$OnCharacteristicReceived {
319319
}
320320

321321
Future<void> listener(OnCharacteristicReceivedEvent event) async {
322-
_bluetoothPlusLogger.info('onCharacteristicReceived ${event.device.advName} ${event.characteristic.uuid.str} ${event.value}');
322+
_bluetoothPlusLogger.info('onCharacteristicReceived ${event.device.advName} ${event.characteristic.uuid.str128} ${event.value}');
323323

324324
BluetoothDevice bluetoothDevice = event.device;
325325
BluetoothCharacteristic bluetoothCharacteristic = event.characteristic;
@@ -332,7 +332,7 @@ class _OnCharacteristicReceived extends _$OnCharacteristicReceived {
332332
}
333333
if (bluetoothCharacteristic.characteristicUuid.str.toLowerCase() == "2a19") {
334334
statefulDevice.batteryLevel.value = values.first.toDouble();
335-
} else if (bluetoothCharacteristic.characteristicUuid.str.toLowerCase() == "5073792e-4fc0-45a0-b0a5-78b6c1756c91") {
335+
} else if (bluetoothCharacteristic.characteristicUuid.str128.toLowerCase() == "5073792e-4fc0-45a0-b0a5-78b6c1756c91") {
336336
try {
337337
String value = const Utf8Decoder().convert(values);
338338
statefulDevice.messageHistory.add(MessageHistoryEntry(type: MessageHistoryType.receive, message: value));
@@ -342,7 +342,7 @@ class _OnCharacteristicReceived extends _$OnCharacteristicReceived {
342342
statefulDevice.messageHistory.add(MessageHistoryEntry(type: MessageHistoryType.receive, message: "Unknown: ${values.toString()}"));
343343
return;
344344
}
345-
} else if (statefulDevice.bluetoothUartService.value != null && bluetoothCharacteristic.characteristicUuid.str.toLowerCase() == statefulDevice.bluetoothUartService.value!.bleRxCharacteristic.toLowerCase()) {
345+
} else if (statefulDevice.bluetoothUartService.value != null && bluetoothCharacteristic.characteristicUuid.str128.toLowerCase() == statefulDevice.bluetoothUartService.value!.bleRxCharacteristic.toLowerCase()) {
346346
String value = "";
347347
try {
348348
value = const Utf8Decoder().convert(values);
@@ -560,9 +560,9 @@ Future<void> sendMessage(BaseStatefulDevice device, List<int> message, {bool wit
560560
BluetoothDevice? bluetoothDevice = flutterBluePlus.connectedDevices.firstWhereOrNull((element) => element.remoteId.str == device.baseStoredDevice.btMACAddress);
561561
if (bluetoothDevice != null && device.bluetoothUartService.value != null) {
562562
BluetoothCharacteristic? bluetoothCharacteristic = bluetoothDevice.servicesList
563-
.firstWhereOrNull((element) => element.uuid.str.toLowerCase() == device.bluetoothUartService.value!.bleDeviceService.toLowerCase())
563+
.firstWhereOrNull((element) => element.uuid.str128.toLowerCase() == device.bluetoothUartService.value!.bleDeviceService.toLowerCase())
564564
?.characteristics
565-
.firstWhereOrNull((element) => element.characteristicUuid.str.toLowerCase() == device.bluetoothUartService.value!.bleTxCharacteristic.toLowerCase());
565+
.firstWhereOrNull((element) => element.characteristicUuid.str128.toLowerCase() == device.bluetoothUartService.value!.bleTxCharacteristic.toLowerCase());
566566
if (bluetoothCharacteristic == null) {
567567
_bluetoothPlusLogger.warning("Unable to find bluetooth characteristic to send command to");
568568
return;

lib/Backend/Definitions/Device/device_definition.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ final List<BluetoothUartService> uartServices = const [
144144
bleTxCharacteristic: "5bfd6484-ddee-4723-bfe6-b653372bbfd6",
145145
label: "Legacy Gear",
146146
),
147+
BluetoothUartService(
148+
bleDeviceService: "0000ffe0-0000-1000-8000-00805f9b34fb",
149+
bleRxCharacteristic: "",
150+
bleTxCharacteristic: "0000ffe1-0000-1000-8000-00805f9b34fb",
151+
label: "DigiTail",
152+
),
147153
BluetoothUartService(
148154
bleDeviceService: "927dee04-ddd4-4582-8e42-69dc9fbfae66",
149155
bleRxCharacteristic: "0b646a19-371e-4327-b169-9632d56c0e84",

0 commit comments

Comments
 (0)