react-native-ble-manager 10.1.3 → 10.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,18 +12,21 @@ public class NotifyBufferContainer {
12
12
  this.items.clear();
13
13
  }
14
14
  public byte[] put(byte[] value){
15
- int restLength = value.length - this.items.remaining();
16
15
  byte[] toInsert = null;
17
16
  byte[] rest = null;
18
- if (restLength < 0) {
17
+
18
+ if (value.length > this.items.remaining()) {
19
+ int restLength = value.length - this.items.remaining();
19
20
  rest = new byte[restLength];
20
- toInsert = new byte[value.length - restLength];
21
+ toInsert = new byte[this.items.remaining()];
21
22
  System.arraycopy(value, 0, toInsert, 0, toInsert.length);
22
- System.arraycopy(value, toInsert.length, rest, restLength, rest.length);
23
+ System.arraycopy(value, toInsert.length, rest, 0, rest.length);
23
24
  } else {
24
25
  toInsert = value;
25
26
  }
27
+
26
28
  this.items.put(toInsert);
29
+
27
30
  return rest;
28
31
  }
29
32
  public boolean isBufferFull(){
@@ -435,11 +435,7 @@ public class Peripheral extends BluetoothGattCallback {
435
435
  byte[] rest = null;
436
436
  if (buffer != null) {
437
437
  rest = buffer.put(dataValue);
438
- Log.d(BleManager.LOG_TAG, "onCharacteristicChanged-buffering: " +
439
- buffer.size() + " from peripheral: " + device.getAddress());
440
-
441
438
  if (buffer.isBufferFull()) {
442
- Log.d(BleManager.LOG_TAG, "onCharacteristicChanged sending buffered data " + buffer.size());
443
439
 
444
440
  // fetch and reset
445
441
  dataValue = buffer.items.array();
@@ -448,8 +444,7 @@ public class Peripheral extends BluetoothGattCallback {
448
444
  return;
449
445
  }
450
446
  }
451
- Log.d(BleManager.LOG_TAG, "onCharacteristicChanged: " + BleManager.bytesToHex(dataValue)
452
- + " from peripheral: " + device.getAddress());
447
+
453
448
  WritableMap map = Arguments.createMap();
454
449
  map.putString("peripheral", device.getAddress());
455
450
  map.putString("characteristic", charString);
@@ -37,7 +37,7 @@ export interface AdvertisingData {
37
37
  isConnectable?: boolean;
38
38
  localName?: string;
39
39
  manufacturerData?: CustomAdvertisingData;
40
- serviceData?: CustomAdvertisingData;
40
+ serviceData?: Record<string, CustomAdvertisingData>;
41
41
  serviceUUIDs?: string[];
42
42
  txPowerLevel?: number;
43
43
  }
@@ -37,7 +37,7 @@ export interface AdvertisingData {
37
37
  isConnectable?: boolean;
38
38
  localName?: string;
39
39
  manufacturerData?: CustomAdvertisingData;
40
- serviceData?: CustomAdvertisingData;
40
+ serviceData?: Record<string, CustomAdvertisingData>;
41
41
  serviceUUIDs?: string[];
42
42
  txPowerLevel?: number;
43
43
  }
package/ios/BleManager.m CHANGED
@@ -112,11 +112,19 @@ static bool hasListeners = NO;
112
112
  [self invokeAndClearDictionary:readDescriptorCallbacks withKey:key usingParameters:@[error, [NSNull null]]];
113
113
  return;
114
114
  }
115
- NSLog(@"Read value [descriptor: %@, characteristic: %@]: (%lu) %@",
115
+
116
+ if ([descriptor.value isKindOfClass:[NSData class]]) {
117
+ NSLog(@"Read value [descriptor: %@, characteristic: %@]: (%lu) %@",
118
+ descriptor.UUID,
119
+ descriptor.characteristic.UUID,
120
+ [(NSData *)descriptor.value length],
121
+ descriptor.value);
122
+ } else {
123
+ NSLog(@"Read value [descriptor: %@, characteristic: %@]: %@",
116
124
  descriptor.UUID,
117
125
  descriptor.characteristic.UUID,
118
- [descriptor.value length],
119
126
  descriptor.value);
127
+ }
120
128
 
121
129
  NSMutableArray* peripheralReadDescriptorCallbacks = [readDescriptorCallbacks objectForKey:key];
122
130
  if (peripheralReadDescriptorCallbacks != NULL) {
@@ -1140,6 +1148,7 @@ RCT_EXPORT_METHOD(requestMTU:(NSString *)deviceUUID mtu:(NSInteger)mtu callback:
1140
1148
  NSMutableArray *data = [NSMutableArray new];
1141
1149
  for (CBPeripheral *peripheral in peripherals) {
1142
1150
  [data addObject:[peripheral asDictionary]];
1151
+ peripheral.delegate = self;
1143
1152
  }
1144
1153
 
1145
1154
  [self sendEventWithName:@"BleManagerCentralManagerWillRestoreState" body:@{@"peripherals": data}];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-manager",
3
- "version": "10.1.3",
3
+ "version": "10.1.5",
4
4
  "description": "A BLE module for react native.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/types.ts CHANGED
@@ -39,7 +39,7 @@ export interface AdvertisingData {
39
39
  isConnectable?: boolean;
40
40
  localName?: string;
41
41
  manufacturerData?: CustomAdvertisingData;
42
- serviceData?: CustomAdvertisingData;
42
+ serviceData?: Record<string, CustomAdvertisingData>;
43
43
  serviceUUIDs?: string[];
44
44
  txPowerLevel?: number;
45
45
  }
@@ -76,7 +76,7 @@ export interface StartOptions {
76
76
  forceLegacy?: boolean;
77
77
  }
78
78
 
79
- export interface ConnectOptions {
79
+ export interface ConnectOptions {
80
80
  /**
81
81
  * [android only]
82
82
  */