Skip to content

Commit

Permalink
Rename instanceId to index
Browse files Browse the repository at this point in the history
  • Loading branch information
nebkat committed Nov 7, 2024
1 parent eaf9826 commit de86390
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 270 deletions.

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions ios/Classes/FlutterBluePlusPlugin.m

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions lib/src/bluetooth_characteristic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ final Guid cccdUuid = Guid("00002902-0000-1000-8000-00805f9b34fb");
class BluetoothCharacteristic {
final DeviceIdentifier remoteId;
final Guid serviceUuid;
final int serviceInstanceId;
final int serviceIndex;
final Guid? secondaryServiceUuid;
final int? secondaryServiceInstanceId;
final int? secondaryServiceIndex;
final Guid characteristicUuid;
final int characteristicInstanceId;
final int characteristicIndex;

BluetoothCharacteristic({
required this.remoteId,
required this.serviceUuid,
required this.serviceInstanceId,
required this.serviceIndex,
this.secondaryServiceUuid,
this.secondaryServiceInstanceId,
this.secondaryServiceIndex,
required this.characteristicUuid,
required this.characteristicInstanceId,
required this.characteristicIndex,
});

BluetoothCharacteristic.fromProto(BmBluetoothCharacteristic p)
: remoteId = p.remoteId,
serviceUuid = p.serviceUuid,
serviceInstanceId = p.serviceInstanceId,
serviceIndex = p.serviceIndex,
secondaryServiceUuid = p.secondaryServiceUuid,
secondaryServiceInstanceId = p.secondaryServiceInstanceId,
secondaryServiceIndex = p.secondaryServiceIndex,
characteristicUuid = p.characteristicUuid,
characteristicInstanceId = p.characteristicInstanceId;
characteristicIndex = p.characteristicIndex;

/// convenience accessor
Guid get uuid => characteristicUuid;
Expand Down Expand Up @@ -120,11 +120,11 @@ class BluetoothCharacteristic {
var request = BmReadCharacteristicRequest(
remoteId: remoteId,
characteristicUuid: characteristicUuid,
characteristicInstanceId: characteristicInstanceId,
characteristicIndex: characteristicIndex,
serviceUuid: serviceUuid,
serviceInstanceId: serviceInstanceId,
serviceIndex: serviceIndex,
secondaryServiceUuid: secondaryServiceUuid,
secondaryServiceInstanceId: secondaryServiceInstanceId,
secondaryServiceIndex: secondaryServiceIndex,
);

var responseStream = FlutterBluePlus._methodStream.stream
Expand Down Expand Up @@ -194,11 +194,11 @@ class BluetoothCharacteristic {
var request = BmWriteCharacteristicRequest(
remoteId: remoteId,
characteristicUuid: characteristicUuid,
characteristicInstanceId: characteristicInstanceId,
characteristicIndex: characteristicIndex,
serviceUuid: serviceUuid,
serviceInstanceId: serviceInstanceId,
serviceIndex: serviceIndex,
secondaryServiceUuid: secondaryServiceUuid,
secondaryServiceInstanceId: secondaryServiceInstanceId,
secondaryServiceIndex: secondaryServiceIndex,
writeType: writeType,
allowLongWrite: allowLongWrite,
value: value,
Expand Down Expand Up @@ -261,11 +261,11 @@ class BluetoothCharacteristic {
var request = BmSetNotifyValueRequest(
remoteId: remoteId,
serviceUuid: serviceUuid,
serviceInstanceId: serviceInstanceId,
serviceIndex: serviceIndex,
secondaryServiceUuid: secondaryServiceUuid,
secondaryServiceInstanceId: secondaryServiceInstanceId,
secondaryServiceIndex: secondaryServiceIndex,
characteristicUuid: characteristicUuid,
characteristicInstanceId: characteristicInstanceId,
characteristicIndex: characteristicIndex,
forceIndications: forceIndications,
enable: notify,
);
Expand Down Expand Up @@ -310,11 +310,11 @@ class BluetoothCharacteristic {
BmBluetoothService? get _bmsvc {
if (FlutterBluePlus._knownServices[remoteId] != null) {
for (var s in FlutterBluePlus._knownServices[remoteId]!.services) {
if (s.serviceUuid == serviceUuid && s.serviceInstanceId == serviceInstanceId) {
if (s.serviceUuid == serviceUuid && s.serviceIndex == serviceIndex) {
if (secondaryServiceUuid != null) {
// search includedServices (i.e. secondary services)
for (var s2 in s.includedServices) {
if (s2.serviceUuid == secondaryServiceUuid && s2.serviceInstanceId == secondaryServiceInstanceId) {
if (s2.serviceUuid == secondaryServiceUuid && s2.serviceIndex == secondaryServiceIndex) {
return s2;
}
}
Expand All @@ -331,7 +331,7 @@ class BluetoothCharacteristic {
BmBluetoothCharacteristic? get _bmchr {
if (_bmsvc != null) {
for (var c in _bmsvc!.characteristics) {
if (c.characteristicUuid == uuid && c.characteristicInstanceId == characteristicInstanceId) {
if (c.characteristicUuid == uuid && c.characteristicIndex == characteristicIndex) {
return c;
}
}
Expand Down
24 changes: 12 additions & 12 deletions lib/src/bluetooth_descriptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ part of flutter_blue_plus;
class BluetoothDescriptor {
final DeviceIdentifier remoteId;
final Guid serviceUuid;
final int serviceInstanceId;
final int serviceIndex;
final Guid characteristicUuid;
final int characteristicInstanceId;
final int characteristicIndex;
final Guid descriptorUuid;

BluetoothDescriptor({
required this.remoteId,
required this.serviceUuid,
required this.serviceInstanceId,
required this.serviceIndex,
required this.characteristicUuid,
required this.characteristicInstanceId,
required this.characteristicIndex,
required this.descriptorUuid,
});

BluetoothDescriptor.fromProto(BmBluetoothDescriptor p)
: remoteId = p.remoteId,
serviceUuid = p.serviceUuid,
serviceInstanceId = p.serviceInstanceId,
serviceIndex = p.serviceIndex,
characteristicUuid = p.characteristicUuid,
characteristicInstanceId = p.characteristicInstanceId,
characteristicIndex = p.characteristicIndex,
descriptorUuid = p.descriptorUuid;

/// convenience accessor
Expand Down Expand Up @@ -92,11 +92,11 @@ class BluetoothDescriptor {
var request = BmReadDescriptorRequest(
remoteId: remoteId,
serviceUuid: serviceUuid,
serviceInstanceId: serviceInstanceId,
serviceIndex: serviceIndex,
secondaryServiceUuid: null,
secondaryServiceInstanceId: null,
secondaryServiceIndex: null,
characteristicUuid: characteristicUuid,
characteristicInstanceId: characteristicInstanceId,
characteristicIndex: characteristicIndex,
descriptorUuid: descriptorUuid,
);

Expand Down Expand Up @@ -150,11 +150,11 @@ class BluetoothDescriptor {
var request = BmWriteDescriptorRequest(
remoteId: remoteId,
serviceUuid: serviceUuid,
serviceInstanceId: serviceInstanceId,
serviceIndex: serviceIndex,
secondaryServiceUuid: null,
secondaryServiceInstanceId: null,
secondaryServiceIndex: null,
characteristicUuid: characteristicUuid,
characteristicInstanceId: characteristicInstanceId,
characteristicIndex: characteristicIndex,
descriptorUuid: descriptorUuid,
value: value,
);
Expand Down
20 changes: 10 additions & 10 deletions lib/src/bluetooth_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ class OnCharacteristicReceivedEvent {
BluetoothCharacteristic get characteristic => BluetoothCharacteristic(
remoteId: _response.remoteId,
characteristicUuid: _response.characteristicUuid,
characteristicInstanceId: _response.characteristicInstanceId,
characteristicIndex: _response.characteristicIndex,
serviceUuid: _response.serviceUuid,
serviceInstanceId: _response.serviceInstanceId,
serviceIndex: _response.serviceIndex,
secondaryServiceUuid: _response.secondaryServiceUuid,
secondaryServiceInstanceId: _response.secondaryServiceInstanceId);
secondaryServiceIndex: _response.secondaryServiceIndex);

/// the new data
List<int> get value => _response.value;
Expand All @@ -211,11 +211,11 @@ class OnCharacteristicWrittenEvent {
BluetoothCharacteristic get characteristic => BluetoothCharacteristic(
remoteId: _response.remoteId,
characteristicUuid: _response.characteristicUuid,
characteristicInstanceId: _response.characteristicInstanceId,
characteristicIndex: _response.characteristicIndex,
serviceUuid: _response.serviceUuid,
serviceInstanceId: _response.serviceInstanceId,
serviceIndex: _response.serviceIndex,
secondaryServiceUuid: _response.secondaryServiceUuid,
secondaryServiceInstanceId: _response.secondaryServiceInstanceId);
secondaryServiceIndex: _response.secondaryServiceIndex);

/// the new data
List<int> get value => _response.value;
Expand All @@ -237,9 +237,9 @@ class OnDescriptorReadEvent {
BluetoothDescriptor get descriptor => BluetoothDescriptor(
remoteId: _response.remoteId,
serviceUuid: _response.serviceUuid,
serviceInstanceId: _response.serviceInstanceId,
serviceIndex: _response.serviceIndex,
characteristicUuid: _response.characteristicUuid,
characteristicInstanceId: _response.characteristicInstanceId,
characteristicIndex: _response.characteristicIndex,
descriptorUuid: _response.descriptorUuid);

/// the new data
Expand All @@ -262,9 +262,9 @@ class OnDescriptorWrittenEvent {
BluetoothDescriptor get descriptor => BluetoothDescriptor(
remoteId: _response.remoteId,
serviceUuid: _response.serviceUuid,
serviceInstanceId: _response.serviceInstanceId,
serviceIndex: _response.serviceIndex,
characteristicUuid: _response.characteristicUuid,
characteristicInstanceId: _response.characteristicInstanceId,
characteristicIndex: _response.characteristicIndex,
descriptorUuid: _response.descriptorUuid);

/// the new data
Expand Down
Loading

0 comments on commit de86390

Please sign in to comment.