react-native-ble-manager 10.1.0 → 10.1.2

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.
package/README.md CHANGED
@@ -185,7 +185,7 @@ BleManager.stopScan().then(() => {
185
185
  });
186
186
  ```
187
187
 
188
- ### connect(peripheralId)
188
+ ### connect(peripheralId, options)
189
189
 
190
190
  Attempts to connect to a peripheral. In many case if you can't connect you have to scan for the peripheral before.
191
191
  Returns a `Promise` object.
@@ -195,6 +195,11 @@ Returns a `Promise` object.
195
195
  **Arguments**
196
196
 
197
197
  - `peripheralId` - `String` - the id/mac address of the peripheral to connect.
198
+ - `options` - `JSON` - The parameter is optional the configuration keys are:
199
+
200
+ - `phy` - `Number` - [Android only] corresponding to the preferred phy channel ([`Android doc`](<https://developer.android.com/reference/android/bluetooth/BluetoothDevice?hl=en#connectGatt(android.content.Context,%20boolean,%20android.bluetooth.BluetoothGattCallback,%20int,%20int)>))
201
+ - `autoconnect` - `Boolean` - [Android only] whether to directly connect to the remote device (false) or to automatically connect as soon as the remote device becomes available (true) ([`Android doc`](<https://developer.android.com/reference/android/bluetooth/BluetoothDevice?hl=en#connectGatt(android.content.Context,%20boolean,%20android.bluetooth.BluetoothGattCallback,%20int,%20int)>))
202
+
198
203
 
199
204
  **Examples**
200
205
 
@@ -758,6 +763,32 @@ BleManager.setName("INNOVEIT_CENTRAL")
758
763
  });
759
764
  ```
760
765
 
766
+ ### getMaximumWriteValueLengthForWithoutResponse(peripheralId) [iOS only]
767
+
768
+ Return the maximum value length for WriteWithoutResponse.
769
+ Returns a `Promise` object.
770
+
771
+ **Examples**
772
+
773
+ ```js
774
+ BleManager.getMaximumWriteValueLengthForWithoutResponse("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX").then((maxValue) => {
775
+ console.log("Maximum length for WriteWithoutResponse: " + maxValue);
776
+ });
777
+ ```
778
+
779
+ ### getMaximumWriteValueLengthForWitResponse(peripheralId) [iOS only]
780
+
781
+ Return the maximum value length for WriteWithResponse.
782
+ Returns a `Promise` object.
783
+
784
+ **Examples**
785
+
786
+ ```js
787
+ BleManager.getMaximumWriteValueLengthForWitResponse("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX").then((maxValue) => {
788
+ console.log("Maximum length for WriteWithResponse: " + maxValue);
789
+ });
790
+ ```
791
+
761
792
  ## Events
762
793
 
763
794
  ### BleManagerStopScan
@@ -360,7 +360,7 @@ class BleManager extends ReactContextBaseJavaModule {
360
360
  if (peripheral != null) {
361
361
  byte[] decoded = new byte[message.size()];
362
362
  for (int i = 0; i < message.size(); i++) {
363
- decoded[i] = Integer.valueOf(i).byteValue();
363
+ decoded[i] = Integer.valueOf(message.getInt(i)).byteValue();
364
364
  }
365
365
  Log.d(LOG_TAG, "Message(" + decoded.length + "): " + bytesToHex(decoded));
366
366
  peripheral.write(UUIDHelper.uuidFromString(serviceUUID), UUIDHelper.uuidFromString(characteristicUUID),
@@ -381,7 +381,7 @@ class BleManager extends ReactContextBaseJavaModule {
381
381
  if (peripheral != null) {
382
382
  byte[] decoded = new byte[message.size()];
383
383
  for (int i = 0; i < message.size(); i++) {
384
- decoded[i] = Integer.valueOf(i).byteValue();
384
+ decoded[i] = Integer.valueOf(message.getInt(i)).byteValue();
385
385
  }
386
386
  Log.d(LOG_TAG, "Message(" + decoded.length + "): " + bytesToHex(decoded));
387
387
  peripheral.write(UUIDHelper.uuidFromString(serviceUUID), UUIDHelper.uuidFromString(characteristicUUID),
@@ -127,7 +127,7 @@ public class BundleJSONConverter {
127
127
  JSONObject json = new JSONObject();
128
128
 
129
129
  for(String key : bundle.keySet()) {
130
- Object value = bundle.getString(key);
130
+ Object value = bundle.get(key);
131
131
  if (value == null) {
132
132
  // Null is not supported.
133
133
  continue;
package/ios/BleManager.m CHANGED
@@ -17,7 +17,7 @@ RCT_EXPORT_MODULE();
17
17
  @synthesize manager;
18
18
  @synthesize peripherals;
19
19
  @synthesize scanTimer;
20
- bool hasListeners;
20
+ static bool hasListeners = NO;
21
21
 
22
22
  - (instancetype)init
23
23
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-manager",
3
- "version": "10.1.0",
3
+ "version": "10.1.2",
4
4
  "description": "A BLE module for react native.",
5
5
  "repository": {
6
6
  "type": "git",