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