react-native-ble-nitro 1.9.1 → 1.9.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
|
@@ -257,8 +257,8 @@ const emptyResult = await ble.writeCharacteristic(
|
|
|
257
257
|
#### 📡 Characteristic Notifications
|
|
258
258
|
|
|
259
259
|
> [!CAUTION]
|
|
260
|
-
> From version 1.8.0 on the returned subscription object has the type `AsyncSubscription` instead of `Subscription` to indicate that the `remove` method is now async and returns a Promise for better multi-platform compatibility.
|
|
261
|
-
> From version 1.9.0 on the `subscribeToCharacteristic` method is async, so use await when calling it. This was introduced to fix the handling of gatt queuing on Android.
|
|
260
|
+
> **From version 1.8.0** on the returned subscription object has the type `AsyncSubscription` instead of `Subscription` to indicate that the `remove` method is now async and returns a Promise for better multi-platform compatibility.
|
|
261
|
+
> **From version 1.9.0** on the `subscribeToCharacteristic` method is async, so use await when calling it. This was introduced to fix the handling of gatt queuing on Android.
|
|
262
262
|
|
|
263
263
|
> [!IMPORTANT]
|
|
264
264
|
> It is only possible to have one active notification subscription per specific characteristic. If you call `subscribeToCharacteristic` again for the same characteristic, the previous subscription won't receive any more updates and should be removed previously.
|
|
@@ -303,7 +303,7 @@ const deviceId = await ble.connect(
|
|
|
303
303
|
);
|
|
304
304
|
await ble.discoverServices(deviceId);
|
|
305
305
|
|
|
306
|
-
const subscription = ble.subscribeToCharacteristic(
|
|
306
|
+
const subscription = await ble.subscribeToCharacteristic(
|
|
307
307
|
deviceId,
|
|
308
308
|
HEART_RATE_SERVICE,
|
|
309
309
|
HEART_RATE_MEASUREMENT,
|
|
@@ -656,7 +656,10 @@ class BleNitroBleManager : HybridNativeBleNitroSpec() {
|
|
|
656
656
|
}
|
|
657
657
|
|
|
658
658
|
override fun isConnected(deviceId: String): Boolean {
|
|
659
|
-
|
|
659
|
+
val gatt = connectedDevices[deviceId] ?: return false
|
|
660
|
+
val bluetoothManager = appContext?.getSystemService(Context.BLUETOOTH_SERVICE) as? BluetoothManager ?: return false
|
|
661
|
+
val connectionState = bluetoothManager.getConnectionState(gatt.device, BluetoothProfile.GATT)
|
|
662
|
+
return connectionState == BluetoothProfile.STATE_CONNECTED
|
|
660
663
|
}
|
|
661
664
|
|
|
662
665
|
override fun requestMTU(deviceId: String, mtu: Double): Double {
|