@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
@@ -1,166 +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
- }
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
+ }
package/src/Descriptor.js CHANGED
@@ -1,82 +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
- }
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
+ }