@react-native-ohos/react-native-ble-plx 3.2.1-rc.1 → 3.2.1

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.
Files changed (65) hide show
  1. package/LICENSE +202 -202
  2. package/README.OpenSource +10 -10
  3. package/README.md +9 -9
  4. package/app.plugin.js +1 -1
  5. package/harmony/rn_bleplx/build-profile.json5 +7 -7
  6. package/harmony/rn_bleplx/hvigorfile.ts +1 -1
  7. package/harmony/rn_bleplx/index.ets +26 -26
  8. package/harmony/rn_bleplx/obfuscation-rules.txt +17 -17
  9. package/harmony/rn_bleplx/oh-package.json5 +13 -13
  10. package/harmony/rn_bleplx/src/main/cpp/BlePlxPackage.h +36 -36
  11. package/harmony/rn_bleplx/src/main/cpp/CMakeLists.txt +9 -9
  12. package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/BaseReactNativeBlePlxPackage.h +65 -65
  13. package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.cpp +59 -59
  14. package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.h +16 -16
  15. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ComponentDescriptors.h +22 -22
  16. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.cpp +18 -18
  17. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.h +19 -19
  18. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.cpp +21 -21
  19. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.h +20 -20
  20. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.cpp +19 -19
  21. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.h +25 -25
  22. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.cpp +18 -18
  23. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.h +22 -22
  24. package/harmony/rn_bleplx/src/main/ets/BleDevice.ts +98 -98
  25. package/harmony/rn_bleplx/src/main/ets/BleModule.ts +1219 -1219
  26. package/harmony/rn_bleplx/src/main/ets/BlePlxInterface.ts +26 -26
  27. package/harmony/rn_bleplx/src/main/ets/BlePlxModule.ts +246 -246
  28. package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ets +46 -46
  29. package/harmony/rn_bleplx/src/main/ets/Characteristic.ts +179 -179
  30. package/harmony/rn_bleplx/src/main/ets/CommonConstants.ts +29 -29
  31. package/harmony/rn_bleplx/src/main/ets/Descriptor.ts +143 -143
  32. package/harmony/rn_bleplx/src/main/ets/Service.ts +85 -85
  33. package/harmony/rn_bleplx/src/main/ets/common/BleError.ts +90 -90
  34. package/harmony/rn_bleplx/src/main/ets/common/BleErrorToJsObjectConverter.ts +62 -62
  35. package/harmony/rn_bleplx/src/main/ets/common/BleEvent.ts +32 -32
  36. package/harmony/rn_bleplx/src/main/ets/common/BleUtils.ts +86 -86
  37. package/harmony/rn_bleplx/src/main/ets/common/IdGenerator.ts +49 -49
  38. package/harmony/rn_bleplx/src/main/ets/common/IdGeneratorKey.ts +70 -70
  39. package/harmony/rn_bleplx/src/main/ets/common/InstanceIdGenerator.ts +36 -36
  40. package/harmony/rn_bleplx/src/main/ets/common/Logger.ts +64 -64
  41. package/harmony/rn_bleplx/src/main/ets/common/PermissionHandler.ts +98 -98
  42. package/harmony/rn_bleplx/src/main/ets/common/ServiceFactory.ts +37 -37
  43. package/harmony/rn_bleplx/src/main/ets/generated/components/ts.ts +5 -5
  44. package/harmony/rn_bleplx/src/main/ets/generated/index.ets +5 -5
  45. package/harmony/rn_bleplx/src/main/ets/generated/ts.ts +6 -6
  46. package/harmony/rn_bleplx/src/main/ets/generated/turboModules/BlePlx.ts +100 -100
  47. package/harmony/rn_bleplx/src/main/ets/generated/turboModules/ts.ts +5 -5
  48. package/harmony/rn_bleplx/src/main/module.json5 +6 -6
  49. package/harmony/rn_bleplx/ts.ets +25 -25
  50. package/harmony/rn_bleplx.har +0 -0
  51. package/package.json +185 -185
  52. package/src/BleError.js +555 -555
  53. package/src/BleManager.js +1287 -1287
  54. package/src/BleModule.js +847 -847
  55. package/src/Characteristic.js +166 -166
  56. package/src/Descriptor.js +82 -82
  57. package/src/Device.js +370 -370
  58. package/src/NativeBlePlx.ts +121 -121
  59. package/src/Service.js +188 -188
  60. package/src/TypeDefinition.js +360 -360
  61. package/src/Utils.js +26 -26
  62. package/src/index.d.ts +2113 -2113
  63. package/src/index.js +20 -20
  64. package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ts +0 -46
  65. package/harmony/rn_bleplx/ts.ts +0 -26
package/src/Device.js CHANGED
@@ -1,370 +1,370 @@
1
- // @flow
2
- 'use strict'
3
-
4
- import type { BleManager } from './BleManager'
5
- import type { BleError } from './BleError'
6
- import type { Characteristic } from './Characteristic'
7
- import type { Service } from './Service'
8
- import type { Descriptor } from './Descriptor'
9
- import { ConnectionPriority } from './TypeDefinition'
10
- import type { NativeDevice } from './BleModule'
11
- import type { DeviceId, Base64, UUID, Subscription, TransactionId, ConnectionOptions } from './TypeDefinition'
12
-
13
- /**
14
- * Device instance which can be retrieved only by calling
15
- * {@link #blemanagerstartdevicescan|bleManager.startDeviceScan()}.
16
- */
17
- export class Device implements NativeDevice {
18
- /**
19
- * Internal BLE Manager handle
20
- * @private
21
- */
22
- _manager: BleManager
23
-
24
- /**
25
- * Device identifier: MAC address on Android and UUID on iOS.
26
- */
27
- id: DeviceId
28
-
29
- /**
30
- * Device name if present
31
- */
32
- name: ?string
33
-
34
- /**
35
- * Current Received Signal Strength Indication of device
36
- */
37
- rssi: ?number
38
-
39
- /**
40
- * Current Maximum Transmission Unit for this device. When device is not connected
41
- * default value of 23 is used.
42
- */
43
- mtu: number
44
-
45
- // Advertisement
46
-
47
- /**
48
- * Device's custom manufacturer data. Its format is defined by manufacturer.
49
- */
50
- manufacturerData: ?Base64
51
-
52
- /**
53
- * Raw device scan data. When you have specific advertiser data,
54
- * you can implement your own processing.
55
- */
56
- rawScanRecord: Base64
57
-
58
- /**
59
- * Map of service UUIDs (as keys) with associated data (as values).
60
- */
61
- serviceData: ?{ [uuid: UUID]: Base64 }
62
-
63
- /**
64
- * List of available services visible during scanning.
65
- */
66
- serviceUUIDs: ?Array<UUID>
67
-
68
- /**
69
- * User friendly name of device.
70
- */
71
- localName: ?string
72
-
73
- /**
74
- * Transmission power level of device.
75
- */
76
- txPowerLevel: ?number
77
-
78
- /**
79
- * List of solicited service UUIDs.
80
- */
81
- solicitedServiceUUIDs: ?Array<UUID>
82
-
83
- /**
84
- * Is device connectable. [iOS only]
85
- */
86
- isConnectable: ?boolean
87
-
88
- /**
89
- * List of overflow service UUIDs. [iOS only]
90
- */
91
- overflowServiceUUIDs: ?Array<UUID>
92
-
93
- /**
94
- * Private constructor used to create {@link Device} object.
95
- *
96
- * @param {NativeDevice} nativeDevice Native device properties
97
- * @param {BleManager} manager {@link BleManager} handle
98
- * @private
99
- */
100
- constructor(nativeDevice: NativeDevice, manager: BleManager) {
101
- Object.assign(this, nativeDevice, { _manager: manager })
102
- }
103
-
104
- /**
105
- * {@link #blemanagerrequestconnectionpriorityfordevice|bleManager.requestConnectionPriorityForDevice()} with partially filled arguments.
106
- *
107
- * @param {ConnectionPriority} connectionPriority: Connection priority.
108
- * @param {?TransactionId} transactionId Transaction handle used to cancel operation.
109
- * @returns {Promise<Device>} Connected device.
110
- */
111
- requestConnectionPriority(
112
- connectionPriority: $Values<typeof ConnectionPriority>,
113
- transactionId: ?TransactionId
114
- ): Promise<Device> {
115
- return this._manager.requestConnectionPriorityForDevice(this.id, connectionPriority, transactionId)
116
- }
117
-
118
- /**
119
- * {@link #blemanagerreadrssifordevice|bleManager.readRSSIForDevice()} with partially filled arguments.
120
- *
121
- * @param {?TransactionId} transactionId Transaction handle used to cancel operation.
122
- * @returns {Promise<Device>} This device with updated RSSI value.
123
- */
124
- readRSSI(transactionId: ?TransactionId): Promise<Device> {
125
- return this._manager.readRSSIForDevice(this.id, transactionId)
126
- }
127
-
128
- /**
129
- * {@link #blemanagerrequestmtufordevice|bleManager.requestMTUForDevice()} with partially filled arguments.
130
- *
131
- * @param {?TransactionId} transactionId Transaction handle used to cancel operation.
132
- * @returns {Promise<Device>} Device with updated MTU size. Default value is 23.
133
- */
134
- requestMTU(mtu: number, transactionId: ?TransactionId): Promise<Device> {
135
- return this._manager.requestMTUForDevice(this.id, mtu, transactionId)
136
- }
137
-
138
- /**
139
- * {@link #blemanagerconnecttodevice|bleManager.connectToDevice()} with partially filled arguments.
140
- *
141
- * @param {?ConnectionOptions} options Platform specific options for connection establishment. Not used currently.
142
- * @returns {Promise<Device>} Connected {@link Device} object if successful.
143
- */
144
- connect(options: ?ConnectionOptions): Promise<Device> {
145
- return this._manager.connectToDevice(this.id, options)
146
- }
147
-
148
- /**
149
- * {@link #blemanagercanceldeviceconnection|bleManager.cancelDeviceConnection()} with partially filled arguments.
150
- *
151
- * @returns {Promise<Device>} Returns closed {@link Device} when operation is successful.
152
- */
153
- cancelConnection(): Promise<Device> {
154
- return this._manager.cancelDeviceConnection(this.id)
155
- }
156
-
157
- /**
158
- * {@link #blemanagerisdeviceconnected|bleManager.isDeviceConnected()} with partially filled arguments.
159
- *
160
- * @returns {Promise<boolean>} Promise which emits `true` if device is connected, and `false` otherwise.
161
- */
162
- isConnected(): Promise<boolean> {
163
- return this._manager.isDeviceConnected(this.id)
164
- }
165
-
166
- /**
167
- * {@link #blemanagerondevicedisconnected|bleManager.onDeviceDisconnected()} with partially filled arguments.
168
- *
169
- * @param {function(error: ?BleError, device: Device)} listener callback returning error as a reason of disconnection
170
- * if available and {@link Device} object. If an error is null, that means the connection was terminated by
171
- * {@link #blemanagercanceldeviceconnection|bleManager.cancelDeviceConnection()} call.
172
- * @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
173
- */
174
- onDisconnected(listener: (error: ?BleError, device: Device) => void): Subscription {
175
- return this._manager.onDeviceDisconnected(this.id, listener)
176
- }
177
-
178
- /**
179
- * {@link #blemanagerdiscoverallservicesandcharacteristicsfordevice|bleManager.discoverAllServicesAndCharacteristicsForDevice()} with partially filled arguments.
180
- *
181
- * @param {?TransactionId} transactionId Transaction handle used to cancel operation
182
- * @returns {Promise<Device>} Promise which emits {@link Device} object if all available services and
183
- * characteristics have been discovered.
184
- */
185
- discoverAllServicesAndCharacteristics(transactionId: ?TransactionId): Promise<Device> {
186
- return this._manager.discoverAllServicesAndCharacteristicsForDevice(this.id, transactionId)
187
- }
188
-
189
- /**
190
- * {@link #blemanagerservicesfordevice|bleManager.servicesForDevice()} with partially filled arguments.
191
- *
192
- * @returns {Promise<Service[]>} Promise which emits array of {@link Service} objects which are discovered by this
193
- * device.
194
- */
195
- services(): Promise<Service[]> {
196
- return this._manager.servicesForDevice(this.id)
197
- }
198
-
199
- /**
200
- * {@link #blemanagercharacteristicsfordevice|bleManager.characteristicsForDevice()} with partially filled arguments.
201
- *
202
- * @param {UUID} serviceUUID {@link Service} UUID.
203
- * @returns {Promise<Characteristic[]>} Promise which emits array of {@link Characteristic} objects which are
204
- * discovered for a {@link Device} in specified {@link Service}.
205
- */
206
- characteristicsForService(serviceUUID: string): Promise<Characteristic[]> {
207
- return this._manager.characteristicsForDevice(this.id, serviceUUID)
208
- }
209
-
210
- /**
211
- * {@link #blemanagerdescriptorsfordevice|bleManager.descriptorsForDevice()} with partially filled arguments.
212
- *
213
- * @param {UUID} serviceUUID {@link Service} UUID.
214
- * @param {UUID} characteristicUUID {@link Characteristic} UUID.
215
- * @returns {Promise<Array<Descriptor>>} Promise which emits array of {@link Descriptor} objects which are
216
- * discovered for this {@link Characteristic}.
217
- */
218
- descriptorsForService(serviceUUID: UUID, characteristicUUID: UUID): Promise<Array<Descriptor>> {
219
- return this._manager.descriptorsForDevice(this.id, serviceUUID, characteristicUUID)
220
- }
221
-
222
- /**
223
- * {@link #blemanagerreadcharacteristicfordevice|bleManager.readCharacteristicForDevice()} with partially filled arguments.
224
- *
225
- * @param {UUID} serviceUUID {@link Service} UUID.
226
- * @param {UUID} characteristicUUID {@link Characteristic} UUID.
227
- * @param {?TransactionId} transactionId optional `transactionId` which can be used in
228
- * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
229
- * @returns {Promise<Characteristic>} Promise which emits first {@link Characteristic} object matching specified
230
- * UUID paths. Latest value of {@link Characteristic} will be stored inside returned object.
231
- */
232
- readCharacteristicForService(
233
- serviceUUID: UUID,
234
- characteristicUUID: UUID,
235
- transactionId: ?TransactionId
236
- ): Promise<Characteristic> {
237
- return this._manager.readCharacteristicForDevice(this.id, serviceUUID, characteristicUUID, transactionId)
238
- }
239
-
240
- /**
241
- * {@link #blemanagerwritecharacteristicwithresponsefordevice|bleManager.writeCharacteristicWithResponseForDevice()} with partially filled arguments.
242
- *
243
- * @param {UUID} serviceUUID {@link Service} UUID.
244
- * @param {UUID} characteristicUUID {@link Characteristic} UUID.
245
- * @param {Base64} valueBase64 Value in Base64 format.
246
- * @param {?TransactionId} transactionId optional `transactionId` which can be used in
247
- * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
248
- * @returns {Promise<Characteristic>} Promise which emits first {@link Characteristic} object matching specified
249
- * UUID paths. Latest value of characteristic may not be stored inside returned object.
250
- */
251
- writeCharacteristicWithResponseForService(
252
- serviceUUID: UUID,
253
- characteristicUUID: UUID,
254
- valueBase64: Base64,
255
- transactionId: ?TransactionId
256
- ): Promise<Characteristic> {
257
- return this._manager.writeCharacteristicWithResponseForDevice(
258
- this.id,
259
- serviceUUID,
260
- characteristicUUID,
261
- valueBase64,
262
- transactionId
263
- )
264
- }
265
-
266
- /**
267
- * {@link #blemanagerwritecharacteristicwithoutresponsefordevice|bleManager.writeCharacteristicWithoutResponseForDevice()} with partially filled arguments.
268
- *
269
- * @param {UUID} serviceUUID {@link Service} UUID.
270
- * @param {UUID} characteristicUUID {@link Characteristic} UUID.
271
- * @param {Base64} valueBase64 Value in Base64 format.
272
- * @param {?TransactionId} transactionId optional `transactionId` which can be used in
273
- * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
274
- * @returns {Promise<Characteristic>} Promise which emits first {@link Characteristic} object matching specified
275
- * UUID paths. Latest value of characteristic may not be stored inside returned object.
276
- */
277
- writeCharacteristicWithoutResponseForService(
278
- serviceUUID: UUID,
279
- characteristicUUID: UUID,
280
- valueBase64: Base64,
281
- transactionId: ?TransactionId
282
- ): Promise<Characteristic> {
283
- return this._manager.writeCharacteristicWithoutResponseForDevice(
284
- this.id,
285
- serviceUUID,
286
- characteristicUUID,
287
- valueBase64,
288
- transactionId
289
- )
290
- }
291
-
292
- /**
293
- * {@link #blemanagermonitorcharacteristicfordevice|bleManager.monitorCharacteristicForDevice()} with partially filled arguments.
294
- *
295
- * @param {UUID} serviceUUID {@link Service} UUID.
296
- * @param {UUID} characteristicUUID {@link Characteristic} UUID.
297
- * @param {function(error: ?BleError, characteristic: ?Characteristic)} listener - callback which emits
298
- * {@link Characteristic} objects with modified value for each notification.
299
- * @param {?TransactionId} transactionId optional `transactionId` which can be used in
300
- * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
301
- * @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
302
- */
303
- monitorCharacteristicForService(
304
- serviceUUID: UUID,
305
- characteristicUUID: UUID,
306
- listener: (error: ?BleError, characteristic: ?Characteristic) => void,
307
- transactionId: ?TransactionId
308
- ): Subscription {
309
- return this._manager.monitorCharacteristicForDevice(
310
- this.id,
311
- serviceUUID,
312
- characteristicUUID,
313
- listener,
314
- transactionId
315
- )
316
- }
317
-
318
- /**
319
- * {@link #blemanagerreaddescriptorfordevice|bleManager.readDescriptorForDevice()} with partially filled arguments.
320
- *
321
- * @param {UUID} serviceUUID {@link Service} UUID.
322
- * @param {UUID} characteristicUUID {@link Characteristic} UUID.
323
- * @param {UUID} descriptorUUID {@link Descriptor} UUID.
324
- * @param {?TransactionId} transactionId optional `transactionId` which can be used in
325
- * {@link #blemanagercanceltransaction|cancelTransaction()} function.
326
- * @returns {Promise<Descriptor>} Promise which emits first {@link Descriptor} object matching specified
327
- * UUID paths. Latest value of {@link Descriptor} will be stored inside returned object.
328
- */
329
- async readDescriptorForService(
330
- serviceUUID: UUID,
331
- characteristicUUID: UUID,
332
- descriptorUUID: UUID,
333
- transactionId: ?TransactionId
334
- ): Promise<Descriptor> {
335
- return this._manager.readDescriptorForDevice(
336
- this.id,
337
- serviceUUID,
338
- characteristicUUID,
339
- descriptorUUID,
340
- transactionId
341
- )
342
- }
343
-
344
- /**
345
- * {@link #blemanagerwritedescriptorfordevice|bleManager.writeDescriptorForDevice()} with partially filled arguments.
346
- *
347
- * @param {UUID} serviceUUID {@link Service} UUID.
348
- * @param {UUID} characteristicUUID Characteristic UUID
349
- * @param {UUID} descriptorUUID Descriptor UUID
350
- * @param {Base64} valueBase64 Value to be set coded in Base64
351
- * @param {?TransactionId} transactionId Transaction handle used to cancel operation
352
- * @returns {Promise<Descriptor>} Descriptor which saved passed value.
353
- */
354
- async writeDescriptorForService(
355
- serviceUUID: UUID,
356
- characteristicUUID: UUID,
357
- descriptorUUID: UUID,
358
- valueBase64: Base64,
359
- transactionId: ?TransactionId
360
- ): Promise<Descriptor> {
361
- return this._manager.writeDescriptorForDevice(
362
- this.id,
363
- serviceUUID,
364
- characteristicUUID,
365
- descriptorUUID,
366
- valueBase64,
367
- transactionId
368
- )
369
- }
370
- }
1
+ // @flow
2
+ 'use strict'
3
+
4
+ import type { BleManager } from './BleManager'
5
+ import type { BleError } from './BleError'
6
+ import type { Characteristic } from './Characteristic'
7
+ import type { Service } from './Service'
8
+ import type { Descriptor } from './Descriptor'
9
+ import { ConnectionPriority } from './TypeDefinition'
10
+ import type { NativeDevice } from './BleModule'
11
+ import type { DeviceId, Base64, UUID, Subscription, TransactionId, ConnectionOptions } from './TypeDefinition'
12
+
13
+ /**
14
+ * Device instance which can be retrieved only by calling
15
+ * {@link #blemanagerstartdevicescan|bleManager.startDeviceScan()}.
16
+ */
17
+ export class Device implements NativeDevice {
18
+ /**
19
+ * Internal BLE Manager handle
20
+ * @private
21
+ */
22
+ _manager: BleManager
23
+
24
+ /**
25
+ * Device identifier: MAC address on Android and UUID on iOS.
26
+ */
27
+ id: DeviceId
28
+
29
+ /**
30
+ * Device name if present
31
+ */
32
+ name: ?string
33
+
34
+ /**
35
+ * Current Received Signal Strength Indication of device
36
+ */
37
+ rssi: ?number
38
+
39
+ /**
40
+ * Current Maximum Transmission Unit for this device. When device is not connected
41
+ * default value of 23 is used.
42
+ */
43
+ mtu: number
44
+
45
+ // Advertisement
46
+
47
+ /**
48
+ * Device's custom manufacturer data. Its format is defined by manufacturer.
49
+ */
50
+ manufacturerData: ?Base64
51
+
52
+ /**
53
+ * Raw device scan data. When you have specific advertiser data,
54
+ * you can implement your own processing.
55
+ */
56
+ rawScanRecord: Base64
57
+
58
+ /**
59
+ * Map of service UUIDs (as keys) with associated data (as values).
60
+ */
61
+ serviceData: ?{ [uuid: UUID]: Base64 }
62
+
63
+ /**
64
+ * List of available services visible during scanning.
65
+ */
66
+ serviceUUIDs: ?Array<UUID>
67
+
68
+ /**
69
+ * User friendly name of device.
70
+ */
71
+ localName: ?string
72
+
73
+ /**
74
+ * Transmission power level of device.
75
+ */
76
+ txPowerLevel: ?number
77
+
78
+ /**
79
+ * List of solicited service UUIDs.
80
+ */
81
+ solicitedServiceUUIDs: ?Array<UUID>
82
+
83
+ /**
84
+ * Is device connectable. [iOS only]
85
+ */
86
+ isConnectable: ?boolean
87
+
88
+ /**
89
+ * List of overflow service UUIDs. [iOS only]
90
+ */
91
+ overflowServiceUUIDs: ?Array<UUID>
92
+
93
+ /**
94
+ * Private constructor used to create {@link Device} object.
95
+ *
96
+ * @param {NativeDevice} nativeDevice Native device properties
97
+ * @param {BleManager} manager {@link BleManager} handle
98
+ * @private
99
+ */
100
+ constructor(nativeDevice: NativeDevice, manager: BleManager) {
101
+ Object.assign(this, nativeDevice, { _manager: manager })
102
+ }
103
+
104
+ /**
105
+ * {@link #blemanagerrequestconnectionpriorityfordevice|bleManager.requestConnectionPriorityForDevice()} with partially filled arguments.
106
+ *
107
+ * @param {ConnectionPriority} connectionPriority: Connection priority.
108
+ * @param {?TransactionId} transactionId Transaction handle used to cancel operation.
109
+ * @returns {Promise<Device>} Connected device.
110
+ */
111
+ requestConnectionPriority(
112
+ connectionPriority: $Values<typeof ConnectionPriority>,
113
+ transactionId: ?TransactionId
114
+ ): Promise<Device> {
115
+ return this._manager.requestConnectionPriorityForDevice(this.id, connectionPriority, transactionId)
116
+ }
117
+
118
+ /**
119
+ * {@link #blemanagerreadrssifordevice|bleManager.readRSSIForDevice()} with partially filled arguments.
120
+ *
121
+ * @param {?TransactionId} transactionId Transaction handle used to cancel operation.
122
+ * @returns {Promise<Device>} This device with updated RSSI value.
123
+ */
124
+ readRSSI(transactionId: ?TransactionId): Promise<Device> {
125
+ return this._manager.readRSSIForDevice(this.id, transactionId)
126
+ }
127
+
128
+ /**
129
+ * {@link #blemanagerrequestmtufordevice|bleManager.requestMTUForDevice()} with partially filled arguments.
130
+ *
131
+ * @param {?TransactionId} transactionId Transaction handle used to cancel operation.
132
+ * @returns {Promise<Device>} Device with updated MTU size. Default value is 23.
133
+ */
134
+ requestMTU(mtu: number, transactionId: ?TransactionId): Promise<Device> {
135
+ return this._manager.requestMTUForDevice(this.id, mtu, transactionId)
136
+ }
137
+
138
+ /**
139
+ * {@link #blemanagerconnecttodevice|bleManager.connectToDevice()} with partially filled arguments.
140
+ *
141
+ * @param {?ConnectionOptions} options Platform specific options for connection establishment. Not used currently.
142
+ * @returns {Promise<Device>} Connected {@link Device} object if successful.
143
+ */
144
+ connect(options: ?ConnectionOptions): Promise<Device> {
145
+ return this._manager.connectToDevice(this.id, options)
146
+ }
147
+
148
+ /**
149
+ * {@link #blemanagercanceldeviceconnection|bleManager.cancelDeviceConnection()} with partially filled arguments.
150
+ *
151
+ * @returns {Promise<Device>} Returns closed {@link Device} when operation is successful.
152
+ */
153
+ cancelConnection(): Promise<Device> {
154
+ return this._manager.cancelDeviceConnection(this.id)
155
+ }
156
+
157
+ /**
158
+ * {@link #blemanagerisdeviceconnected|bleManager.isDeviceConnected()} with partially filled arguments.
159
+ *
160
+ * @returns {Promise<boolean>} Promise which emits `true` if device is connected, and `false` otherwise.
161
+ */
162
+ isConnected(): Promise<boolean> {
163
+ return this._manager.isDeviceConnected(this.id)
164
+ }
165
+
166
+ /**
167
+ * {@link #blemanagerondevicedisconnected|bleManager.onDeviceDisconnected()} with partially filled arguments.
168
+ *
169
+ * @param {function(error: ?BleError, device: Device)} listener callback returning error as a reason of disconnection
170
+ * if available and {@link Device} object. If an error is null, that means the connection was terminated by
171
+ * {@link #blemanagercanceldeviceconnection|bleManager.cancelDeviceConnection()} call.
172
+ * @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
173
+ */
174
+ onDisconnected(listener: (error: ?BleError, device: Device) => void): Subscription {
175
+ return this._manager.onDeviceDisconnected(this.id, listener)
176
+ }
177
+
178
+ /**
179
+ * {@link #blemanagerdiscoverallservicesandcharacteristicsfordevice|bleManager.discoverAllServicesAndCharacteristicsForDevice()} with partially filled arguments.
180
+ *
181
+ * @param {?TransactionId} transactionId Transaction handle used to cancel operation
182
+ * @returns {Promise<Device>} Promise which emits {@link Device} object if all available services and
183
+ * characteristics have been discovered.
184
+ */
185
+ discoverAllServicesAndCharacteristics(transactionId: ?TransactionId): Promise<Device> {
186
+ return this._manager.discoverAllServicesAndCharacteristicsForDevice(this.id, transactionId)
187
+ }
188
+
189
+ /**
190
+ * {@link #blemanagerservicesfordevice|bleManager.servicesForDevice()} with partially filled arguments.
191
+ *
192
+ * @returns {Promise<Service[]>} Promise which emits array of {@link Service} objects which are discovered by this
193
+ * device.
194
+ */
195
+ services(): Promise<Service[]> {
196
+ return this._manager.servicesForDevice(this.id)
197
+ }
198
+
199
+ /**
200
+ * {@link #blemanagercharacteristicsfordevice|bleManager.characteristicsForDevice()} with partially filled arguments.
201
+ *
202
+ * @param {UUID} serviceUUID {@link Service} UUID.
203
+ * @returns {Promise<Characteristic[]>} Promise which emits array of {@link Characteristic} objects which are
204
+ * discovered for a {@link Device} in specified {@link Service}.
205
+ */
206
+ characteristicsForService(serviceUUID: string): Promise<Characteristic[]> {
207
+ return this._manager.characteristicsForDevice(this.id, serviceUUID)
208
+ }
209
+
210
+ /**
211
+ * {@link #blemanagerdescriptorsfordevice|bleManager.descriptorsForDevice()} with partially filled arguments.
212
+ *
213
+ * @param {UUID} serviceUUID {@link Service} UUID.
214
+ * @param {UUID} characteristicUUID {@link Characteristic} UUID.
215
+ * @returns {Promise<Array<Descriptor>>} Promise which emits array of {@link Descriptor} objects which are
216
+ * discovered for this {@link Characteristic}.
217
+ */
218
+ descriptorsForService(serviceUUID: UUID, characteristicUUID: UUID): Promise<Array<Descriptor>> {
219
+ return this._manager.descriptorsForDevice(this.id, serviceUUID, characteristicUUID)
220
+ }
221
+
222
+ /**
223
+ * {@link #blemanagerreadcharacteristicfordevice|bleManager.readCharacteristicForDevice()} with partially filled arguments.
224
+ *
225
+ * @param {UUID} serviceUUID {@link Service} UUID.
226
+ * @param {UUID} characteristicUUID {@link Characteristic} UUID.
227
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
228
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
229
+ * @returns {Promise<Characteristic>} Promise which emits first {@link Characteristic} object matching specified
230
+ * UUID paths. Latest value of {@link Characteristic} will be stored inside returned object.
231
+ */
232
+ readCharacteristicForService(
233
+ serviceUUID: UUID,
234
+ characteristicUUID: UUID,
235
+ transactionId: ?TransactionId
236
+ ): Promise<Characteristic> {
237
+ return this._manager.readCharacteristicForDevice(this.id, serviceUUID, characteristicUUID, transactionId)
238
+ }
239
+
240
+ /**
241
+ * {@link #blemanagerwritecharacteristicwithresponsefordevice|bleManager.writeCharacteristicWithResponseForDevice()} with partially filled arguments.
242
+ *
243
+ * @param {UUID} serviceUUID {@link Service} UUID.
244
+ * @param {UUID} characteristicUUID {@link Characteristic} UUID.
245
+ * @param {Base64} valueBase64 Value in Base64 format.
246
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
247
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
248
+ * @returns {Promise<Characteristic>} Promise which emits first {@link Characteristic} object matching specified
249
+ * UUID paths. Latest value of characteristic may not be stored inside returned object.
250
+ */
251
+ writeCharacteristicWithResponseForService(
252
+ serviceUUID: UUID,
253
+ characteristicUUID: UUID,
254
+ valueBase64: Base64,
255
+ transactionId: ?TransactionId
256
+ ): Promise<Characteristic> {
257
+ return this._manager.writeCharacteristicWithResponseForDevice(
258
+ this.id,
259
+ serviceUUID,
260
+ characteristicUUID,
261
+ valueBase64,
262
+ transactionId
263
+ )
264
+ }
265
+
266
+ /**
267
+ * {@link #blemanagerwritecharacteristicwithoutresponsefordevice|bleManager.writeCharacteristicWithoutResponseForDevice()} with partially filled arguments.
268
+ *
269
+ * @param {UUID} serviceUUID {@link Service} UUID.
270
+ * @param {UUID} characteristicUUID {@link Characteristic} UUID.
271
+ * @param {Base64} valueBase64 Value in Base64 format.
272
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
273
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
274
+ * @returns {Promise<Characteristic>} Promise which emits first {@link Characteristic} object matching specified
275
+ * UUID paths. Latest value of characteristic may not be stored inside returned object.
276
+ */
277
+ writeCharacteristicWithoutResponseForService(
278
+ serviceUUID: UUID,
279
+ characteristicUUID: UUID,
280
+ valueBase64: Base64,
281
+ transactionId: ?TransactionId
282
+ ): Promise<Characteristic> {
283
+ return this._manager.writeCharacteristicWithoutResponseForDevice(
284
+ this.id,
285
+ serviceUUID,
286
+ characteristicUUID,
287
+ valueBase64,
288
+ transactionId
289
+ )
290
+ }
291
+
292
+ /**
293
+ * {@link #blemanagermonitorcharacteristicfordevice|bleManager.monitorCharacteristicForDevice()} with partially filled arguments.
294
+ *
295
+ * @param {UUID} serviceUUID {@link Service} UUID.
296
+ * @param {UUID} characteristicUUID {@link Characteristic} UUID.
297
+ * @param {function(error: ?BleError, characteristic: ?Characteristic)} listener - callback which emits
298
+ * {@link Characteristic} objects with modified value for each notification.
299
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
300
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
301
+ * @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
302
+ */
303
+ monitorCharacteristicForService(
304
+ serviceUUID: UUID,
305
+ characteristicUUID: UUID,
306
+ listener: (error: ?BleError, characteristic: ?Characteristic) => void,
307
+ transactionId: ?TransactionId
308
+ ): Subscription {
309
+ return this._manager.monitorCharacteristicForDevice(
310
+ this.id,
311
+ serviceUUID,
312
+ characteristicUUID,
313
+ listener,
314
+ transactionId
315
+ )
316
+ }
317
+
318
+ /**
319
+ * {@link #blemanagerreaddescriptorfordevice|bleManager.readDescriptorForDevice()} with partially filled arguments.
320
+ *
321
+ * @param {UUID} serviceUUID {@link Service} UUID.
322
+ * @param {UUID} characteristicUUID {@link Characteristic} UUID.
323
+ * @param {UUID} descriptorUUID {@link Descriptor} UUID.
324
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
325
+ * {@link #blemanagercanceltransaction|cancelTransaction()} function.
326
+ * @returns {Promise<Descriptor>} Promise which emits first {@link Descriptor} object matching specified
327
+ * UUID paths. Latest value of {@link Descriptor} will be stored inside returned object.
328
+ */
329
+ async readDescriptorForService(
330
+ serviceUUID: UUID,
331
+ characteristicUUID: UUID,
332
+ descriptorUUID: UUID,
333
+ transactionId: ?TransactionId
334
+ ): Promise<Descriptor> {
335
+ return this._manager.readDescriptorForDevice(
336
+ this.id,
337
+ serviceUUID,
338
+ characteristicUUID,
339
+ descriptorUUID,
340
+ transactionId
341
+ )
342
+ }
343
+
344
+ /**
345
+ * {@link #blemanagerwritedescriptorfordevice|bleManager.writeDescriptorForDevice()} with partially filled arguments.
346
+ *
347
+ * @param {UUID} serviceUUID {@link Service} UUID.
348
+ * @param {UUID} characteristicUUID Characteristic UUID
349
+ * @param {UUID} descriptorUUID Descriptor UUID
350
+ * @param {Base64} valueBase64 Value to be set coded in Base64
351
+ * @param {?TransactionId} transactionId Transaction handle used to cancel operation
352
+ * @returns {Promise<Descriptor>} Descriptor which saved passed value.
353
+ */
354
+ async writeDescriptorForService(
355
+ serviceUUID: UUID,
356
+ characteristicUUID: UUID,
357
+ descriptorUUID: UUID,
358
+ valueBase64: Base64,
359
+ transactionId: ?TransactionId
360
+ ): Promise<Descriptor> {
361
+ return this._manager.writeDescriptorForDevice(
362
+ this.id,
363
+ serviceUUID,
364
+ characteristicUUID,
365
+ descriptorUUID,
366
+ valueBase64,
367
+ transactionId
368
+ )
369
+ }
370
+ }