@react-native-ohos/react-native-ble-plx 3.2.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 (65) 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/build-profile.json5 +8 -0
  6. package/harmony/rn_bleplx/hvigorfile.ts +2 -0
  7. package/harmony/rn_bleplx/index.ets +27 -0
  8. package/harmony/rn_bleplx/obfuscation-rules.txt +18 -0
  9. package/harmony/rn_bleplx/oh-package.json5 +13 -0
  10. package/harmony/rn_bleplx/src/main/cpp/BlePlxPackage.h +36 -0
  11. package/harmony/rn_bleplx/src/main/cpp/CMakeLists.txt +9 -0
  12. package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/BaseReactNativeBlePlxPackage.h +65 -0
  13. package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.cpp +59 -0
  14. package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.h +16 -0
  15. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ComponentDescriptors.h +22 -0
  16. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.cpp +18 -0
  17. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.h +19 -0
  18. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.cpp +21 -0
  19. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.h +20 -0
  20. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.cpp +19 -0
  21. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.h +25 -0
  22. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.cpp +18 -0
  23. package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.h +23 -0
  24. package/harmony/rn_bleplx/src/main/ets/BleDevice.ts +99 -0
  25. package/harmony/rn_bleplx/src/main/ets/BleModule.ts +1219 -0
  26. package/harmony/rn_bleplx/src/main/ets/BlePlxInterface.ts +27 -0
  27. package/harmony/rn_bleplx/src/main/ets/BlePlxModule.ts +246 -0
  28. package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ets +47 -0
  29. package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ts +46 -0
  30. package/harmony/rn_bleplx/src/main/ets/Characteristic.ts +179 -0
  31. package/harmony/rn_bleplx/src/main/ets/CommonConstants.ts +30 -0
  32. package/harmony/rn_bleplx/src/main/ets/Descriptor.ts +143 -0
  33. package/harmony/rn_bleplx/src/main/ets/Service.ts +85 -0
  34. package/harmony/rn_bleplx/src/main/ets/common/BleError.ts +90 -0
  35. package/harmony/rn_bleplx/src/main/ets/common/BleErrorToJsObjectConverter.ts +63 -0
  36. package/harmony/rn_bleplx/src/main/ets/common/BleEvent.ts +33 -0
  37. package/harmony/rn_bleplx/src/main/ets/common/BleUtils.ts +86 -0
  38. package/harmony/rn_bleplx/src/main/ets/common/IdGenerator.ts +49 -0
  39. package/harmony/rn_bleplx/src/main/ets/common/IdGeneratorKey.ts +70 -0
  40. package/harmony/rn_bleplx/src/main/ets/common/InstanceIdGenerator.ts +37 -0
  41. package/harmony/rn_bleplx/src/main/ets/common/Logger.ts +64 -0
  42. package/harmony/rn_bleplx/src/main/ets/common/PermissionHandler.ts +98 -0
  43. package/harmony/rn_bleplx/src/main/ets/common/ServiceFactory.ts +37 -0
  44. package/harmony/rn_bleplx/src/main/ets/generated/components/ts.ts +5 -0
  45. package/harmony/rn_bleplx/src/main/ets/generated/index.ets +5 -0
  46. package/harmony/rn_bleplx/src/main/ets/generated/ts.ts +6 -0
  47. package/harmony/rn_bleplx/src/main/ets/generated/turboModules/BlePlx.ts +100 -0
  48. package/harmony/rn_bleplx/src/main/ets/generated/turboModules/ts.ts +5 -0
  49. package/harmony/rn_bleplx/src/main/module.json5 +7 -0
  50. package/harmony/rn_bleplx/ts.ets +26 -0
  51. package/harmony/rn_bleplx/ts.ts +26 -0
  52. package/harmony/rn_bleplx.har +0 -0
  53. package/package.json +185 -0
  54. package/src/BleError.js +555 -0
  55. package/src/BleManager.js +1287 -0
  56. package/src/BleModule.js +847 -0
  57. package/src/Characteristic.js +166 -0
  58. package/src/Descriptor.js +82 -0
  59. package/src/Device.js +370 -0
  60. package/src/NativeBlePlx.ts +121 -0
  61. package/src/Service.js +188 -0
  62. package/src/TypeDefinition.js +360 -0
  63. package/src/Utils.js +26 -0
  64. package/src/index.d.ts +2113 -0
  65. package/src/index.js +20 -0
@@ -0,0 +1,166 @@
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 { DeviceId, Identifier, UUID, TransactionId, Base64, Subscription } from './TypeDefinition'
9
+
10
+ /**
11
+ * Characteristic object.
12
+ */
13
+ export class Characteristic implements NativeCharacteristic {
14
+ /**
15
+ * Internal BLE Manager handle
16
+ * @private
17
+ */
18
+ _manager: BleManager
19
+ /**
20
+ * Characteristic unique identifier
21
+ */
22
+ id: Identifier
23
+ /**
24
+ * Characteristic UUID
25
+ */
26
+ uuid: UUID
27
+ /**
28
+ * Service's ID to which characteristic belongs
29
+ */
30
+ serviceID: Identifier
31
+ /**
32
+ * Service's UUID to which characteristic belongs
33
+ */
34
+ serviceUUID: UUID
35
+ /**
36
+ * Device's ID to which characteristic belongs
37
+ */
38
+ deviceID: DeviceId
39
+ /**
40
+ * True if characteristic can be read
41
+ */
42
+ isReadable: boolean
43
+ /**
44
+ * True if characteristic can be written with response
45
+ */
46
+ isWritableWithResponse: boolean
47
+ /**
48
+ * True if characteristic can be written without response
49
+ */
50
+ isWritableWithoutResponse: boolean
51
+ /**
52
+ * True if characteristic can monitor value changes.
53
+ */
54
+ isNotifiable: boolean
55
+ /**
56
+ * True if characteristic is monitoring value changes without ACK.
57
+ */
58
+ isNotifying: boolean
59
+ /**
60
+ * True if characteristic is monitoring value changes with ACK.
61
+ */
62
+ isIndicatable: boolean
63
+ /**
64
+ * Characteristic value if present
65
+ */
66
+ value: ?Base64
67
+
68
+ /**
69
+ * Private constructor used to create instance of {@link Characteristic}.
70
+ * @param {NativeCharacteristic} nativeCharacteristic NativeCharacteristic
71
+ * @param {BleManager} manager BleManager
72
+ * @private
73
+ */
74
+ constructor(nativeCharacteristic: NativeCharacteristic, manager: BleManager) {
75
+ Object.assign(this, nativeCharacteristic, { _manager: manager })
76
+ }
77
+
78
+ /**
79
+ * {@link #blemanagerdescriptorsfordevice|bleManager.descriptorsForDevice()} with partially filled arguments.
80
+ *
81
+ * @returns {Promise<Array<Descriptor>>} Promise which emits array of {@link Descriptor} objects which are
82
+ * discovered for this {@link Characteristic}.
83
+ */
84
+ descriptors(): Promise<Array<Descriptor>> {
85
+ return this._manager._descriptorsForCharacteristic(this.id)
86
+ }
87
+
88
+ /**
89
+ * {@link #blemanagerreadcharacteristicfordevice|bleManager.readCharacteristicForDevice()} with partially filled arguments.
90
+ *
91
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
92
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
93
+ * @returns {Promise<Characteristic>} Promise which emits this {@link Characteristic}. Latest value will be stored
94
+ * inside returned object.
95
+ */
96
+ read(transactionId: ?TransactionId): Promise<Characteristic> {
97
+ return this._manager._readCharacteristic(this.id, transactionId)
98
+ }
99
+
100
+ /**
101
+ * {@link #blemanagerwritecharacteristicwithresponsefordevice|bleManager.writeCharacteristicWithResponseForDevice()} with partially filled arguments.
102
+ *
103
+ * @param {Base64} valueBase64 Value in Base64 format.
104
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
105
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
106
+ * @returns {Promise<Characteristic>} Promise which emits this {@link Characteristic}. Latest value may
107
+ * not be stored inside returned object.
108
+ */
109
+ writeWithResponse(valueBase64: Base64, transactionId: ?TransactionId): Promise<Characteristic> {
110
+ return this._manager._writeCharacteristicWithResponse(this.id, valueBase64, transactionId)
111
+ }
112
+
113
+ /**
114
+ * {@link #blemanagerwritecharacteristicwithoutresponsefordevice|bleManager.writeCharacteristicWithoutResponseForDevice()} with partially filled arguments.
115
+ *
116
+ * @param {Base64} valueBase64 Value in Base64 format.
117
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
118
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
119
+ * @returns {Promise<Characteristic>} Promise which emits this {@link Characteristic}. Latest value may
120
+ * not be stored inside returned object.
121
+ */
122
+ writeWithoutResponse(valueBase64: Base64, transactionId: ?TransactionId): Promise<Characteristic> {
123
+ return this._manager._writeCharacteristicWithoutResponse(this.id, valueBase64, transactionId)
124
+ }
125
+
126
+ /**
127
+ * {@link #blemanagermonitorcharacteristicfordevice|bleManager.monitorCharacteristicForDevice()} with partially filled arguments.
128
+ *
129
+ * @param {function(error: ?BleError, characteristic: ?Characteristic)} listener callback which emits
130
+ * this {@link Characteristic} with modified value for each notification.
131
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
132
+ * {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
133
+ * @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
134
+ */
135
+ monitor(
136
+ listener: (error: ?BleError, characteristic: ?Characteristic) => void,
137
+ transactionId: ?TransactionId
138
+ ): Subscription {
139
+ return this._manager._monitorCharacteristic(this.id, listener, transactionId)
140
+ }
141
+
142
+ /**
143
+ * {@link #blemanagerreaddescriptorfordevice|bleManager.readDescriptorForDevice()} with partially filled arguments.
144
+ *
145
+ * @param {UUID} descriptorUUID {@link Descriptor} UUID.
146
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
147
+ * {@link #blemanagercanceltransaction|cancelTransaction()} function.
148
+ * @returns {Promise<Descriptor>} Promise which emits first {@link Descriptor} object matching specified
149
+ * UUID paths. Latest value of {@link Descriptor} will be stored inside returned object.
150
+ */
151
+ async readDescriptor(descriptorUUID: UUID, transactionId: ?TransactionId): Promise<Descriptor> {
152
+ return this._manager._readDescriptorForCharacteristic(this.id, descriptorUUID, transactionId)
153
+ }
154
+
155
+ /**
156
+ * {@link #blemanagerwritedescriptorfordevice|bleManager.writeDescriptorForDevice()} with partially filled arguments.
157
+ *
158
+ * @param {UUID} descriptorUUID Descriptor UUID
159
+ * @param {Base64} valueBase64 Value to be set coded in Base64
160
+ * @param {?TransactionId} transactionId Transaction handle used to cancel operation
161
+ * @returns {Promise<Descriptor>} Descriptor which saved passed value.
162
+ */
163
+ async writeDescriptor(descriptorUUID: UUID, valueBase64: Base64, transactionId: ?TransactionId): Promise<Descriptor> {
164
+ return this._manager._writeDescriptorForCharacteristic(this.id, descriptorUUID, valueBase64, transactionId)
165
+ }
166
+ }
@@ -0,0 +1,82 @@
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, { _manager: manager })
58
+ }
59
+
60
+ /**
61
+ * {@link #blemanagerreaddescriptorfordevice|bleManager.readDescriptorForDevice()} with partially filled arguments.
62
+ *
63
+ * @param {?TransactionId} transactionId optional `transactionId` which can be used in
64
+ * {@link #blemanagercanceltransaction|cancelTransaction()} function.
65
+ * @returns {Promise<Descriptor>} Promise which emits first {@link Descriptor} object matching specified
66
+ * UUID paths. Latest value of {@link Descriptor} will be stored inside returned object.
67
+ */
68
+ async read(transactionId: ?TransactionId): Promise<Descriptor> {
69
+ return this._manager._readDescriptor(this.id, transactionId)
70
+ }
71
+
72
+ /**
73
+ * {@link #blemanagerwritedescriptorfordevice|bleManager.writeDescriptorForDevice()} with partially filled arguments.
74
+ *
75
+ * @param {Base64} valueBase64 Value to be set coded in Base64
76
+ * @param {?TransactionId} transactionId Transaction handle used to cancel operation
77
+ * @returns {Promise<Descriptor>} Descriptor which saved passed value.
78
+ */
79
+ async write(valueBase64: Base64, transactionId: ?TransactionId): Promise<Descriptor> {
80
+ return this._manager._writeDescriptor(this.id, valueBase64, transactionId)
81
+ }
82
+ }
package/src/Device.js ADDED
@@ -0,0 +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
+ }