react-native-ble-nitro 1.0.0-beta.14 → 1.0.0-beta.15

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,11 +12,11 @@ import NitroModules
12
12
  * Core BLE Manager implementation using CoreBluetooth
13
13
  * Implements the HybridBleManagerSpec protocol generated by Nitro
14
14
  */
15
- public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate {
15
+ public class BleNitroBleManager: NSObject, HybridBleManagerSpec, CBCentralManagerDelegate {
16
16
 
17
17
  // MARK: - Properties
18
18
  private var centralManager: CBCentralManager!
19
- private var logLevel: LogLevel = .None
19
+ private var logLevel: BleLogLevel = .none
20
20
  private var isScanning = false
21
21
  private var scanListener: ((_ error: NativeBleError?, _ scannedDevice: NativeDevice?) -> Void)?
22
22
  private var stateChangeListener: ((_ newState: State) -> Void)?
@@ -48,7 +48,7 @@ public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate
48
48
  self.centralManager = CBCentralManager(delegate: self, queue: nil, options: options.isEmpty ? nil : options)
49
49
  }
50
50
 
51
- public override var memorySize: Int {
51
+ public var memorySize: Int {
52
52
  return MemorySize.MemorySize_estimate(self)
53
53
  }
54
54
 
@@ -90,14 +90,14 @@ public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate
90
90
  })
91
91
  }
92
92
 
93
- public func setLogLevel(logLevel: LogLevel) throws -> Promise<LogLevel> {
93
+ public func setLogLevel(logLevel: BleLogLevel) throws -> Promise<BleLogLevel> {
94
94
  return Promise.resolve(withBlock: {
95
95
  self.logLevel = logLevel
96
96
  return logLevel
97
97
  })
98
98
  }
99
99
 
100
- public func logLevel() throws -> Promise<LogLevel> {
100
+ public func logLevel() throws -> Promise<BleLogLevel> {
101
101
  return Promise.resolve(self.logLevel)
102
102
  }
103
103
 
@@ -140,9 +140,9 @@ public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate
140
140
  listener(self.mapCBManagerState(self.centralManager.state))
141
141
  }
142
142
 
143
- return SubscriptionImpl {
143
+ return Subscription(remove: {
144
144
  self.stateChangeListener = nil
145
- }
145
+ })
146
146
  }
147
147
 
148
148
  public func startDeviceScan(uuids: [String]?, options: ScanOptions?, listener: @escaping (_ error: NativeBleError?, _ scannedDevice: NativeDevice?) -> Void) throws -> Promise<Void> {
@@ -281,9 +281,9 @@ public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate
281
281
  public func onDeviceDisconnected(deviceIdentifier: String, listener: @escaping (_ error: NativeBleError?, _ device: NativeDevice?) -> Void) throws -> Subscription {
282
282
  self.deviceDisconnectListeners[deviceIdentifier] = listener
283
283
 
284
- return SubscriptionImpl {
284
+ return Subscription(remove: {
285
285
  self.deviceDisconnectListeners.removeValue(forKey: deviceIdentifier)
286
- }
286
+ })
287
287
  }
288
288
 
289
289
  public func isDeviceConnected(deviceIdentifier: String) throws -> Promise<Bool> {
@@ -562,7 +562,7 @@ extension BleNitroBleManager: CBPeripheralDelegate {
562
562
  /**
563
563
  * Simple subscription implementation for cleanup
564
564
  */
565
- private class SubscriptionImpl: Subscription {
565
+ private class SubscriptionImpl {
566
566
  private let cleanup: () -> Void
567
567
 
568
568
  init(_ cleanup: @escaping () -> Void) {
@@ -572,4 +572,8 @@ private class SubscriptionImpl: Subscription {
572
572
  public func remove() {
573
573
  cleanup()
574
574
  }
575
+
576
+ public func toSubscription() -> Subscription {
577
+ return Subscription(remove: self.cleanup)
578
+ }
575
579
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-nitro",
3
- "version": "1.0.0-beta.14",
3
+ "version": "1.0.0-beta.15",
4
4
  "description": "High-performance React Native BLE library built on Nitro Modules - drop-in replacement for react-native-ble-plx",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",