react-native-ble-nitro 1.0.0-beta.18 → 1.0.0-beta.19

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.
@@ -21,58 +21,40 @@ public class BleNitroBleManager: HybridBleManagerSpec {
21
21
  // MARK: - HybridBleManagerSpec Implementation (Stubs)
22
22
 
23
23
  public func destroy() throws -> Promise<Void> {
24
- return Promise { resolve, reject in
25
- resolve(())
26
- }
24
+ return Promise.resolved(withResult: ())
27
25
  }
28
26
 
29
27
  public func initialize(options: BleManagerNitroOptions) throws -> Promise<Void> {
30
- return Promise { resolve, reject in
31
- print("BleNitro: iOS implementation not yet complete")
32
- resolve(())
33
- }
28
+ print("BleNitro: iOS implementation not yet complete")
29
+ return Promise.resolved(withResult: ())
34
30
  }
35
31
 
36
32
  public func getRestoredState() throws -> Promise<BleRestoredState?> {
37
- return Promise { resolve, reject in
38
- resolve(nil)
39
- }
33
+ return Promise.resolved(withResult: nil as BleRestoredState?)
40
34
  }
41
35
 
42
36
  public func setLogLevel(logLevel: BleLogLevel) throws -> Promise<BleLogLevel> {
43
- return Promise { resolve, reject in
44
- resolve(logLevel)
45
- }
37
+ return Promise.resolved(withResult: logLevel)
46
38
  }
47
39
 
48
40
  public func logLevel() throws -> Promise<BleLogLevel> {
49
- return Promise { resolve, reject in
50
- resolve(.none)
51
- }
41
+ return Promise.resolved(withResult: BleLogLevel.none)
52
42
  }
53
43
 
54
44
  public func cancelTransaction(transactionId: String) throws -> Promise<Void> {
55
- return Promise { resolve, reject in
56
- resolve(())
57
- }
45
+ return Promise.resolved(withResult: ())
58
46
  }
59
47
 
60
48
  public func enable(transactionId: String?) throws -> Promise<Void> {
61
- return Promise { resolve, reject in
62
- reject(BleError.notImplemented("enable not implemented on iOS yet"))
63
- }
49
+ return Promise.rejected(withError: BleError.notImplemented("enable not implemented on iOS yet"))
64
50
  }
65
51
 
66
52
  public func disable(transactionId: String?) throws -> Promise<Void> {
67
- return Promise { resolve, reject in
68
- reject(BleError.notImplemented("disable not implemented on iOS yet"))
69
- }
53
+ return Promise.rejected(withError: BleError.notImplemented("disable not implemented on iOS yet"))
70
54
  }
71
55
 
72
56
  public func state() throws -> Promise<State> {
73
- return Promise { resolve, reject in
74
- resolve(.unknown)
75
- }
57
+ return Promise.resolved(withResult: State.unknown)
76
58
  }
77
59
 
78
60
  public func onStateChange(listener: @escaping (State) -> Void, emitCurrentState: Bool?) throws -> Subscription {
@@ -80,57 +62,39 @@ public class BleNitroBleManager: HybridBleManagerSpec {
80
62
  }
81
63
 
82
64
  public func startDeviceScan(uuids: [String]?, options: ScanOptions?, listener: @escaping (NativeBleError?, NativeDevice?) -> Void) throws -> Promise<Void> {
83
- return Promise { resolve, reject in
84
- reject(BleError.notImplemented("startDeviceScan not implemented on iOS yet"))
85
- }
65
+ return Promise.rejected(withError: BleError.notImplemented("startDeviceScan not implemented on iOS yet"))
86
66
  }
87
67
 
88
68
  public func stopDeviceScan() throws -> Promise<Void> {
89
- return Promise { resolve, reject in
90
- resolve(())
91
- }
69
+ return Promise.resolved(withResult: ())
92
70
  }
93
71
 
94
72
  public func requestConnectionPriorityForDevice(deviceIdentifier: String, connectionPriority: ConnectionPriority, transactionId: String?) throws -> Promise<NativeDevice> {
95
- return Promise { resolve, reject in
96
- reject(BleError.notImplemented("requestConnectionPriorityForDevice not implemented on iOS yet"))
97
- }
73
+ return Promise.rejected(withError: BleError.notImplemented("requestConnectionPriorityForDevice not implemented on iOS yet"))
98
74
  }
99
75
 
100
76
  public func readRSSIForDevice(deviceIdentifier: String, transactionId: String?) throws -> Promise<NativeDevice> {
101
- return Promise { resolve, reject in
102
- reject(BleError.notImplemented("readRSSIForDevice not implemented on iOS yet"))
103
- }
77
+ return Promise.rejected(withError: BleError.notImplemented("readRSSIForDevice not implemented on iOS yet"))
104
78
  }
105
79
 
106
80
  public func requestMTUForDevice(deviceIdentifier: String, mtu: Double, transactionId: String?) throws -> Promise<NativeDevice> {
107
- return Promise { resolve, reject in
108
- reject(BleError.notImplemented("requestMTUForDevice not implemented on iOS yet"))
109
- }
81
+ return Promise.rejected(withError: BleError.notImplemented("requestMTUForDevice not implemented on iOS yet"))
110
82
  }
111
83
 
112
84
  public func devices(deviceIdentifiers: [String]) throws -> Promise<[NativeDevice]> {
113
- return Promise { resolve, reject in
114
- resolve([])
115
- }
85
+ return Promise.resolved(withResult: [])
116
86
  }
117
87
 
118
88
  public func connectedDevices(serviceUUIDs: [String]) throws -> Promise<[NativeDevice]> {
119
- return Promise { resolve, reject in
120
- resolve([])
121
- }
89
+ return Promise.resolved(withResult: [])
122
90
  }
123
91
 
124
92
  public func connectToDevice(deviceIdentifier: String, options: ConnectionOptions?) throws -> Promise<NativeDevice> {
125
- return Promise { resolve, reject in
126
- reject(BleError.notImplemented("connectToDevice not implemented on iOS yet"))
127
- }
93
+ return Promise.rejected(withError: BleError.notImplemented("connectToDevice not implemented on iOS yet"))
128
94
  }
129
95
 
130
96
  public func cancelDeviceConnection(deviceIdentifier: String) throws -> Promise<NativeDevice> {
131
- return Promise { resolve, reject in
132
- reject(BleError.notImplemented("cancelDeviceConnection not implemented on iOS yet"))
133
- }
97
+ return Promise.rejected(withError: BleError.notImplemented("cancelDeviceConnection not implemented on iOS yet"))
134
98
  }
135
99
 
136
100
  public func onDeviceDisconnected(deviceIdentifier: String, listener: @escaping (NativeBleError?, NativeDevice?) -> Void) throws -> Subscription {
@@ -138,45 +102,31 @@ public class BleNitroBleManager: HybridBleManagerSpec {
138
102
  }
139
103
 
140
104
  public func isDeviceConnected(deviceIdentifier: String) throws -> Promise<Bool> {
141
- return Promise { resolve, reject in
142
- resolve(false)
143
- }
105
+ return Promise.resolved(withResult: false)
144
106
  }
145
107
 
146
108
  public func discoverAllServicesAndCharacteristicsForDevice(deviceIdentifier: String, transactionId: String?) throws -> Promise<NativeDevice> {
147
- return Promise { resolve, reject in
148
- reject(BleError.notImplemented("discoverAllServicesAndCharacteristicsForDevice not implemented on iOS yet"))
149
- }
109
+ return Promise.rejected(withError: BleError.notImplemented("discoverAllServicesAndCharacteristicsForDevice not implemented on iOS yet"))
150
110
  }
151
111
 
152
112
  public func servicesForDevice(deviceIdentifier: String) throws -> Promise<[NativeService]> {
153
- return Promise { resolve, reject in
154
- resolve([])
155
- }
113
+ return Promise.resolved(withResult: [])
156
114
  }
157
115
 
158
116
  public func characteristicsForDevice(deviceIdentifier: String, serviceUUID: String) throws -> Promise<[NativeCharacteristic]> {
159
- return Promise { resolve, reject in
160
- resolve([])
161
- }
117
+ return Promise.resolved(withResult: [])
162
118
  }
163
119
 
164
120
  public func readCharacteristicForDevice(deviceIdentifier: String, serviceUUID: String, characteristicUUID: String, transactionId: String?) throws -> Promise<NativeCharacteristic> {
165
- return Promise { resolve, reject in
166
- reject(BleError.notImplemented("readCharacteristicForDevice not implemented on iOS yet"))
167
- }
121
+ return Promise.rejected(withError: BleError.notImplemented("readCharacteristicForDevice not implemented on iOS yet"))
168
122
  }
169
123
 
170
124
  public func writeCharacteristicWithResponseForDevice(deviceIdentifier: String, serviceUUID: String, characteristicUUID: String, base64Value: String, transactionId: String?) throws -> Promise<NativeCharacteristic> {
171
- return Promise { resolve, reject in
172
- reject(BleError.notImplemented("writeCharacteristicWithResponseForDevice not implemented on iOS yet"))
173
- }
125
+ return Promise.rejected(withError: BleError.notImplemented("writeCharacteristicWithResponseForDevice not implemented on iOS yet"))
174
126
  }
175
127
 
176
128
  public func writeCharacteristicWithoutResponseForDevice(deviceIdentifier: String, serviceUUID: String, characteristicUUID: String, base64Value: String, transactionId: String?) throws -> Promise<NativeCharacteristic> {
177
- return Promise { resolve, reject in
178
- reject(BleError.notImplemented("writeCharacteristicWithoutResponseForDevice not implemented on iOS yet"))
179
- }
129
+ return Promise.rejected(withError: BleError.notImplemented("writeCharacteristicWithoutResponseForDevice not implemented on iOS yet"))
180
130
  }
181
131
 
182
132
  public func monitorCharacteristicForDevice(deviceIdentifier: String, serviceUUID: String, characteristicUUID: String, listener: @escaping (NativeBleError?, NativeCharacteristic?) -> Void, transactionId: String?, subscriptionType: CharacteristicSubscriptionType?) throws -> Subscription {
@@ -184,21 +134,15 @@ public class BleNitroBleManager: HybridBleManagerSpec {
184
134
  }
185
135
 
186
136
  public func descriptorsForDevice(deviceIdentifier: String, serviceUUID: String, characteristicUUID: String) throws -> Promise<[NativeDescriptor]> {
187
- return Promise { resolve, reject in
188
- resolve([])
189
- }
137
+ return Promise.resolved(withResult: [])
190
138
  }
191
139
 
192
140
  public func readDescriptorForDevice(deviceIdentifier: String, serviceUUID: String, characteristicUUID: String, descriptorUUID: String, transactionId: String?) throws -> Promise<NativeDescriptor> {
193
- return Promise { resolve, reject in
194
- reject(BleError.notImplemented("readDescriptorForDevice not implemented on iOS yet"))
195
- }
141
+ return Promise.rejected(withError: BleError.notImplemented("readDescriptorForDevice not implemented on iOS yet"))
196
142
  }
197
143
 
198
144
  public func writeDescriptorForDevice(deviceIdentifier: String, serviceUUID: String, characteristicUUID: String, descriptorUUID: String, valueBase64: String, transactionId: String?) throws -> Promise<NativeDescriptor> {
199
- return Promise { resolve, reject in
200
- reject(BleError.notImplemented("writeDescriptorForDevice not implemented on iOS yet"))
201
- }
145
+ return Promise.rejected(withError: BleError.notImplemented("writeDescriptorForDevice not implemented on iOS yet"))
202
146
  }
203
147
  }
204
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-nitro",
3
- "version": "1.0.0-beta.18",
3
+ "version": "1.0.0-beta.19",
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",