@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.
- package/LICENSE +202 -202
- package/README.OpenSource +10 -10
- package/README.md +9 -9
- package/app.plugin.js +1 -1
- package/harmony/rn_bleplx/build-profile.json5 +7 -7
- package/harmony/rn_bleplx/hvigorfile.ts +1 -1
- package/harmony/rn_bleplx/index.ets +26 -26
- package/harmony/rn_bleplx/obfuscation-rules.txt +17 -17
- package/harmony/rn_bleplx/oh-package.json5 +13 -13
- package/harmony/rn_bleplx/src/main/cpp/BlePlxPackage.h +36 -36
- package/harmony/rn_bleplx/src/main/cpp/CMakeLists.txt +9 -9
- package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/BaseReactNativeBlePlxPackage.h +65 -65
- package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.cpp +59 -59
- package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.h +16 -16
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ComponentDescriptors.h +22 -22
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.cpp +18 -18
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.h +19 -19
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.cpp +21 -21
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.h +20 -20
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.cpp +19 -19
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.h +25 -25
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.cpp +18 -18
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.h +22 -22
- package/harmony/rn_bleplx/src/main/ets/BleDevice.ts +98 -98
- package/harmony/rn_bleplx/src/main/ets/BleModule.ts +1219 -1219
- package/harmony/rn_bleplx/src/main/ets/BlePlxInterface.ts +26 -26
- package/harmony/rn_bleplx/src/main/ets/BlePlxModule.ts +246 -246
- package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ets +46 -46
- package/harmony/rn_bleplx/src/main/ets/Characteristic.ts +179 -179
- package/harmony/rn_bleplx/src/main/ets/CommonConstants.ts +29 -29
- package/harmony/rn_bleplx/src/main/ets/Descriptor.ts +143 -143
- package/harmony/rn_bleplx/src/main/ets/Service.ts +85 -85
- package/harmony/rn_bleplx/src/main/ets/common/BleError.ts +90 -90
- package/harmony/rn_bleplx/src/main/ets/common/BleErrorToJsObjectConverter.ts +62 -62
- package/harmony/rn_bleplx/src/main/ets/common/BleEvent.ts +32 -32
- package/harmony/rn_bleplx/src/main/ets/common/BleUtils.ts +86 -86
- package/harmony/rn_bleplx/src/main/ets/common/IdGenerator.ts +49 -49
- package/harmony/rn_bleplx/src/main/ets/common/IdGeneratorKey.ts +70 -70
- package/harmony/rn_bleplx/src/main/ets/common/InstanceIdGenerator.ts +36 -36
- package/harmony/rn_bleplx/src/main/ets/common/Logger.ts +64 -64
- package/harmony/rn_bleplx/src/main/ets/common/PermissionHandler.ts +98 -98
- package/harmony/rn_bleplx/src/main/ets/common/ServiceFactory.ts +37 -37
- package/harmony/rn_bleplx/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/rn_bleplx/src/main/ets/generated/index.ets +5 -5
- package/harmony/rn_bleplx/src/main/ets/generated/ts.ts +6 -6
- package/harmony/rn_bleplx/src/main/ets/generated/turboModules/BlePlx.ts +100 -100
- package/harmony/rn_bleplx/src/main/ets/generated/turboModules/ts.ts +5 -5
- package/harmony/rn_bleplx/src/main/module.json5 +6 -6
- package/harmony/rn_bleplx/ts.ets +25 -25
- package/harmony/rn_bleplx.har +0 -0
- package/package.json +185 -185
- package/src/BleError.js +555 -555
- package/src/BleManager.js +1287 -1287
- package/src/BleModule.js +847 -847
- package/src/Characteristic.js +166 -166
- package/src/Descriptor.js +82 -82
- package/src/Device.js +370 -370
- package/src/NativeBlePlx.ts +121 -121
- package/src/Service.js +188 -188
- package/src/TypeDefinition.js +360 -360
- package/src/Utils.js +26 -26
- package/src/index.d.ts +2113 -2113
- package/src/index.js +20 -20
- package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ts +0 -46
- package/harmony/rn_bleplx/ts.ts +0 -26
package/src/TypeDefinition.js
CHANGED
|
@@ -1,360 +1,360 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import type { Device } from './Device'
|
|
5
|
-
import { BleErrorCode } from './BleError'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Bluetooth device id.
|
|
9
|
-
*/
|
|
10
|
-
export type DeviceId = string
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Unique identifier for BLE objects.
|
|
14
|
-
*/
|
|
15
|
-
export type Identifier = number
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Bluetooth UUID
|
|
19
|
-
*/
|
|
20
|
-
export type UUID = string
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Base64 value
|
|
24
|
-
*/
|
|
25
|
-
export type Base64 = string
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Transaction identifier. All transaction identifiers in numeric form are reserved for internal use.
|
|
29
|
-
*/
|
|
30
|
-
export type TransactionId = string
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* [Android only] ConnectionOptions parameter to describe when to call BluetoothGatt.refresh()
|
|
34
|
-
*/
|
|
35
|
-
export type RefreshGattMoment = 'OnConnected'
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Subscription
|
|
39
|
-
* @interface
|
|
40
|
-
*/
|
|
41
|
-
export interface Subscription {
|
|
42
|
-
/**
|
|
43
|
-
* Removes subscription
|
|
44
|
-
* @memberof Subscription
|
|
45
|
-
* @ignore
|
|
46
|
-
*/
|
|
47
|
-
remove(): void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Type of error code mapping table
|
|
52
|
-
*/
|
|
53
|
-
export type BleErrorCodeMessageMapping = { [$Values < typeof BleErrorCode >]: string }
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Options which can be passed to when creating BLE Manager
|
|
57
|
-
*/
|
|
58
|
-
export interface BleManagerOptions {
|
|
59
|
-
/**
|
|
60
|
-
* BLE State restoration identifier used to restore state.
|
|
61
|
-
* @memberof BleManagerOptions
|
|
62
|
-
* @instance
|
|
63
|
-
*/
|
|
64
|
-
restoreStateIdentifier?: string;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Optional function which is used to properly restore state of your BLE Manager. Callback
|
|
68
|
-
* is emitted in the beginning of BleManager creation and optional {@link BleRestoreState}
|
|
69
|
-
* is passed. When value is `null` application is launching for the first time, otherwise
|
|
70
|
-
* it contains saved state which may be used by developer to continue working with
|
|
71
|
-
* connected peripherals.
|
|
72
|
-
* @memberof BleManagerOptions
|
|
73
|
-
* @instance
|
|
74
|
-
*/
|
|
75
|
-
restoreStateFunction?: (restoredState: ?BleRestoredState) => void;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Optional mapping of error codes to error messages. Uses {@link BleErrorCodeMessage}
|
|
79
|
-
* by default.
|
|
80
|
-
*
|
|
81
|
-
* To override logging UUIDs or MAC adresses in error messages copy the original object
|
|
82
|
-
* and overwrite values of interest to you.
|
|
83
|
-
*
|
|
84
|
-
* @memberof BleManagerOptions
|
|
85
|
-
* @instance
|
|
86
|
-
*/
|
|
87
|
-
errorCodesToMessagesMapping?: BleErrorCodeMessageMapping;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Object representing information about restored BLE state after application relaunch.
|
|
92
|
-
*/
|
|
93
|
-
export interface BleRestoredState {
|
|
94
|
-
/**
|
|
95
|
-
* List of connected devices after state restoration.
|
|
96
|
-
* @type {Array<Device>}
|
|
97
|
-
* @instance
|
|
98
|
-
* @memberof BleRestoredState
|
|
99
|
-
*/
|
|
100
|
-
connectedPeripherals: Array<Device>;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Scan mode for Bluetooth LE scan.
|
|
105
|
-
*/
|
|
106
|
-
export const ScanMode = {
|
|
107
|
-
/**
|
|
108
|
-
* A special Bluetooth LE scan mode. Applications using this scan mode will passively listen for
|
|
109
|
-
* other scan results without starting BLE scans themselves. [Android only]
|
|
110
|
-
*/
|
|
111
|
-
Opportunistic: -1,
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Perform Bluetooth LE scan in low power mode. This is the default scan mode as it consumes the
|
|
115
|
-
* least power. [Android and Harmony] [default value]
|
|
116
|
-
*/
|
|
117
|
-
LowPower: 0,
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Perform Bluetooth LE scan in balanced power mode. Scan results are returned at a rate that
|
|
121
|
-
* provides a good trade-off between scan frequency and power consumption. [Android and Harmony]
|
|
122
|
-
*/
|
|
123
|
-
Balanced: 1,
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Scan using highest duty cycle. It's recommended to only use this mode when the application is
|
|
127
|
-
* running in the foreground. [Android and Harmony]
|
|
128
|
-
*/
|
|
129
|
-
LowLatency: 2
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* The enum of BLE match mode.
|
|
134
|
-
*/
|
|
135
|
-
export const MatchMode = {
|
|
136
|
-
/**
|
|
137
|
-
* Aggressive mode
|
|
138
|
-
*/
|
|
139
|
-
Aggressive: 1,
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Sticky mode
|
|
143
|
-
*/
|
|
144
|
-
Sticky: 2
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Phy type used during scan.
|
|
149
|
-
*/
|
|
150
|
-
export const PhyType = {
|
|
151
|
-
/**
|
|
152
|
-
* Use 1M phy for scanning.
|
|
153
|
-
*/
|
|
154
|
-
LE_1M: 1,
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Use all supported Phys for scanning.
|
|
158
|
-
*/
|
|
159
|
-
LE_All_Supported: 255
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Scan callback type for Bluetooth LE scan.
|
|
164
|
-
* @name ScanCallbackType
|
|
165
|
-
*/
|
|
166
|
-
export const ScanCallbackType = {
|
|
167
|
-
/**
|
|
168
|
-
* Trigger a callback for every Bluetooth advertisement found that matches the filter criteria.
|
|
169
|
-
* If no filter is active, all advertisement packets are reported. [default value]
|
|
170
|
-
*/
|
|
171
|
-
AllMatches: 1,
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* A result callback is only triggered for the first advertisement packet received that matches
|
|
175
|
-
* the filter criteria.
|
|
176
|
-
*/
|
|
177
|
-
FirstMatch: 2,
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Receive a callback when advertisements are no longer received from a device that has been
|
|
181
|
-
* previously reported by a first match callback.
|
|
182
|
-
*/
|
|
183
|
-
MatchLost: 4
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Options which can be passed to scanning function
|
|
188
|
-
* @name ScanOptions
|
|
189
|
-
*/
|
|
190
|
-
export interface ScanOptions {
|
|
191
|
-
/**
|
|
192
|
-
* By allowing duplicates scanning records are received more frequently [iOS only]
|
|
193
|
-
* @memberof ScanOptions
|
|
194
|
-
* @instance
|
|
195
|
-
*/
|
|
196
|
-
allowDuplicates?: boolean;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Scan mode for Bluetooth LE scan [Android and Harmony]
|
|
200
|
-
* @memberof ScanOptions
|
|
201
|
-
* @instance
|
|
202
|
-
*/
|
|
203
|
-
scanMode?: $Values<typeof ScanMode>;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Scan callback type for Bluetooth LE scan [Android only]
|
|
207
|
-
* @memberof ScanOptions
|
|
208
|
-
* @instance
|
|
209
|
-
*/
|
|
210
|
-
callbackType?: $Values<typeof ScanCallbackType>;
|
|
211
|
-
/**
|
|
212
|
-
* Use legacyScan (default true) [Android only]
|
|
213
|
-
* https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setLegacy(boolean)
|
|
214
|
-
* @memberof ScanOptions
|
|
215
|
-
* @instance
|
|
216
|
-
*/
|
|
217
|
-
legacyScan?: boolean;
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Time of delay for reporting the scan result [Harmony only]
|
|
221
|
-
* @memberof ScanOptions
|
|
222
|
-
* @instance
|
|
223
|
-
*/
|
|
224
|
-
interval?: number;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Match mode for Bluetooth LE scan filters hardware match [Harmony only]
|
|
228
|
-
* @memberof ScanOptions
|
|
229
|
-
* @instance
|
|
230
|
-
*/
|
|
231
|
-
matchMode?: $Values<typeof MatchMode>;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Physical Layer used during scan [Harmony only]
|
|
235
|
-
* @memberof ScanOptions
|
|
236
|
-
* @instance
|
|
237
|
-
*/
|
|
238
|
-
phyType?: $Values<typeof PhyType>;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Connection specific options to be passed before connection happen. [Not used]
|
|
243
|
-
*/
|
|
244
|
-
export interface ConnectionOptions {
|
|
245
|
-
/**
|
|
246
|
-
* Whether to directly connect to the remote device (false) or to automatically connect as soon as the remote device
|
|
247
|
-
* becomes available (true). [Android only]
|
|
248
|
-
* @memberof ConnectionOptions
|
|
249
|
-
* @instance
|
|
250
|
-
*/
|
|
251
|
-
autoConnect?: boolean;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Whether MTU size will be negotiated to this value. It is not guaranteed to get it after connection is successful.
|
|
255
|
-
*
|
|
256
|
-
* @memberof ConnectionOptions
|
|
257
|
-
* @instance
|
|
258
|
-
*/
|
|
259
|
-
requestMTU?: number;
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Whether action will be taken to reset services cache. This option may be useful when a peripheral's firmware was
|
|
263
|
-
* updated and it's services/characteristics were added/removed/altered. [Android only]
|
|
264
|
-
* {@link https://stackoverflow.com/questions/22596951/how-to-programmatically-force-bluetooth-low-energy-service-discovery-on-android}
|
|
265
|
-
* @memberof ConnectionOptions
|
|
266
|
-
* @instance
|
|
267
|
-
*/
|
|
268
|
-
refreshGatt?: RefreshGattMoment;
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Number of milliseconds after connection is automatically timed out. In case of race condition were connection is
|
|
272
|
-
* established right after timeout event, device will be disconnected immediately. Time out may happen earlier then
|
|
273
|
-
* specified due to OS specific behavior.
|
|
274
|
-
*
|
|
275
|
-
* @memberof ConnectionOptions
|
|
276
|
-
* @instance
|
|
277
|
-
*/
|
|
278
|
-
timeout?: number;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Device Bluetooth Low Energy state. It's keys are used to check {@link #blemanagerstate} values
|
|
283
|
-
* received by {@link BleManager}
|
|
284
|
-
*/
|
|
285
|
-
export const State = {
|
|
286
|
-
/**
|
|
287
|
-
* The current state of the manager is unknown; an update is imminent.
|
|
288
|
-
*/
|
|
289
|
-
Unknown: 'Unknown',
|
|
290
|
-
/**
|
|
291
|
-
* The connection with the system service was momentarily lost; an update is imminent.
|
|
292
|
-
*/
|
|
293
|
-
Resetting: 'Resetting',
|
|
294
|
-
/**
|
|
295
|
-
* The platform does not support Bluetooth low energy.
|
|
296
|
-
*/
|
|
297
|
-
Unsupported: 'Unsupported',
|
|
298
|
-
/**
|
|
299
|
-
* The app is not authorized to use Bluetooth low energy.
|
|
300
|
-
*/
|
|
301
|
-
Unauthorized: 'Unauthorized',
|
|
302
|
-
/**
|
|
303
|
-
* Bluetooth is currently powered off.
|
|
304
|
-
*/
|
|
305
|
-
PoweredOff: 'PoweredOff',
|
|
306
|
-
/**
|
|
307
|
-
* Bluetooth is currently powered on and available to use.
|
|
308
|
-
*/
|
|
309
|
-
PoweredOn: 'PoweredOn'
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Native module logging log level. By default it is set to None.
|
|
314
|
-
* @name LogLevel
|
|
315
|
-
*/
|
|
316
|
-
export const LogLevel = {
|
|
317
|
-
/**
|
|
318
|
-
* Logging in native module is disabled
|
|
319
|
-
*/
|
|
320
|
-
None: 'None',
|
|
321
|
-
/**
|
|
322
|
-
* All logs in native module are shown
|
|
323
|
-
*/
|
|
324
|
-
Verbose: 'Verbose',
|
|
325
|
-
/**
|
|
326
|
-
* Only debug logs and of higher importance are shown in native module.
|
|
327
|
-
*/
|
|
328
|
-
Debug: 'Debug',
|
|
329
|
-
/**
|
|
330
|
-
* Only info logs and of higher importance are shown in native module.
|
|
331
|
-
*/
|
|
332
|
-
Info: 'Info',
|
|
333
|
-
/**
|
|
334
|
-
* Only warning logs and of higher importance are shown in native module.
|
|
335
|
-
*/
|
|
336
|
-
Warning: 'Warning',
|
|
337
|
-
/**
|
|
338
|
-
* Only error logs and of higher importance are shown in native module.
|
|
339
|
-
*/
|
|
340
|
-
Error: 'Error'
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Connection priority of BLE link determining the balance between power consumption and data throughput.
|
|
345
|
-
* @name ConnectionPriority
|
|
346
|
-
*/
|
|
347
|
-
export const ConnectionPriority = {
|
|
348
|
-
/**
|
|
349
|
-
* Default, recommended option balanced between power consumption and data throughput.
|
|
350
|
-
*/
|
|
351
|
-
Balanced: 0,
|
|
352
|
-
/**
|
|
353
|
-
* High priority, low latency connection, which increases transfer speed at the expense of power consumption.
|
|
354
|
-
*/
|
|
355
|
-
High: 1,
|
|
356
|
-
/**
|
|
357
|
-
* Low power, reduced data rate connection setup.
|
|
358
|
-
*/
|
|
359
|
-
LowPower: 2
|
|
360
|
-
}
|
|
1
|
+
// @flow
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import type { Device } from './Device'
|
|
5
|
+
import { BleErrorCode } from './BleError'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Bluetooth device id.
|
|
9
|
+
*/
|
|
10
|
+
export type DeviceId = string
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier for BLE objects.
|
|
14
|
+
*/
|
|
15
|
+
export type Identifier = number
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Bluetooth UUID
|
|
19
|
+
*/
|
|
20
|
+
export type UUID = string
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base64 value
|
|
24
|
+
*/
|
|
25
|
+
export type Base64 = string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Transaction identifier. All transaction identifiers in numeric form are reserved for internal use.
|
|
29
|
+
*/
|
|
30
|
+
export type TransactionId = string
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* [Android only] ConnectionOptions parameter to describe when to call BluetoothGatt.refresh()
|
|
34
|
+
*/
|
|
35
|
+
export type RefreshGattMoment = 'OnConnected'
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Subscription
|
|
39
|
+
* @interface
|
|
40
|
+
*/
|
|
41
|
+
export interface Subscription {
|
|
42
|
+
/**
|
|
43
|
+
* Removes subscription
|
|
44
|
+
* @memberof Subscription
|
|
45
|
+
* @ignore
|
|
46
|
+
*/
|
|
47
|
+
remove(): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Type of error code mapping table
|
|
52
|
+
*/
|
|
53
|
+
export type BleErrorCodeMessageMapping = { [$Values < typeof BleErrorCode >]: string }
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Options which can be passed to when creating BLE Manager
|
|
57
|
+
*/
|
|
58
|
+
export interface BleManagerOptions {
|
|
59
|
+
/**
|
|
60
|
+
* BLE State restoration identifier used to restore state.
|
|
61
|
+
* @memberof BleManagerOptions
|
|
62
|
+
* @instance
|
|
63
|
+
*/
|
|
64
|
+
restoreStateIdentifier?: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Optional function which is used to properly restore state of your BLE Manager. Callback
|
|
68
|
+
* is emitted in the beginning of BleManager creation and optional {@link BleRestoreState}
|
|
69
|
+
* is passed. When value is `null` application is launching for the first time, otherwise
|
|
70
|
+
* it contains saved state which may be used by developer to continue working with
|
|
71
|
+
* connected peripherals.
|
|
72
|
+
* @memberof BleManagerOptions
|
|
73
|
+
* @instance
|
|
74
|
+
*/
|
|
75
|
+
restoreStateFunction?: (restoredState: ?BleRestoredState) => void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Optional mapping of error codes to error messages. Uses {@link BleErrorCodeMessage}
|
|
79
|
+
* by default.
|
|
80
|
+
*
|
|
81
|
+
* To override logging UUIDs or MAC adresses in error messages copy the original object
|
|
82
|
+
* and overwrite values of interest to you.
|
|
83
|
+
*
|
|
84
|
+
* @memberof BleManagerOptions
|
|
85
|
+
* @instance
|
|
86
|
+
*/
|
|
87
|
+
errorCodesToMessagesMapping?: BleErrorCodeMessageMapping;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Object representing information about restored BLE state after application relaunch.
|
|
92
|
+
*/
|
|
93
|
+
export interface BleRestoredState {
|
|
94
|
+
/**
|
|
95
|
+
* List of connected devices after state restoration.
|
|
96
|
+
* @type {Array<Device>}
|
|
97
|
+
* @instance
|
|
98
|
+
* @memberof BleRestoredState
|
|
99
|
+
*/
|
|
100
|
+
connectedPeripherals: Array<Device>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Scan mode for Bluetooth LE scan.
|
|
105
|
+
*/
|
|
106
|
+
export const ScanMode = {
|
|
107
|
+
/**
|
|
108
|
+
* A special Bluetooth LE scan mode. Applications using this scan mode will passively listen for
|
|
109
|
+
* other scan results without starting BLE scans themselves. [Android only]
|
|
110
|
+
*/
|
|
111
|
+
Opportunistic: -1,
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Perform Bluetooth LE scan in low power mode. This is the default scan mode as it consumes the
|
|
115
|
+
* least power. [Android and Harmony] [default value]
|
|
116
|
+
*/
|
|
117
|
+
LowPower: 0,
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Perform Bluetooth LE scan in balanced power mode. Scan results are returned at a rate that
|
|
121
|
+
* provides a good trade-off between scan frequency and power consumption. [Android and Harmony]
|
|
122
|
+
*/
|
|
123
|
+
Balanced: 1,
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Scan using highest duty cycle. It's recommended to only use this mode when the application is
|
|
127
|
+
* running in the foreground. [Android and Harmony]
|
|
128
|
+
*/
|
|
129
|
+
LowLatency: 2
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The enum of BLE match mode.
|
|
134
|
+
*/
|
|
135
|
+
export const MatchMode = {
|
|
136
|
+
/**
|
|
137
|
+
* Aggressive mode
|
|
138
|
+
*/
|
|
139
|
+
Aggressive: 1,
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Sticky mode
|
|
143
|
+
*/
|
|
144
|
+
Sticky: 2
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Phy type used during scan.
|
|
149
|
+
*/
|
|
150
|
+
export const PhyType = {
|
|
151
|
+
/**
|
|
152
|
+
* Use 1M phy for scanning.
|
|
153
|
+
*/
|
|
154
|
+
LE_1M: 1,
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Use all supported Phys for scanning.
|
|
158
|
+
*/
|
|
159
|
+
LE_All_Supported: 255
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Scan callback type for Bluetooth LE scan.
|
|
164
|
+
* @name ScanCallbackType
|
|
165
|
+
*/
|
|
166
|
+
export const ScanCallbackType = {
|
|
167
|
+
/**
|
|
168
|
+
* Trigger a callback for every Bluetooth advertisement found that matches the filter criteria.
|
|
169
|
+
* If no filter is active, all advertisement packets are reported. [default value]
|
|
170
|
+
*/
|
|
171
|
+
AllMatches: 1,
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A result callback is only triggered for the first advertisement packet received that matches
|
|
175
|
+
* the filter criteria.
|
|
176
|
+
*/
|
|
177
|
+
FirstMatch: 2,
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Receive a callback when advertisements are no longer received from a device that has been
|
|
181
|
+
* previously reported by a first match callback.
|
|
182
|
+
*/
|
|
183
|
+
MatchLost: 4
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Options which can be passed to scanning function
|
|
188
|
+
* @name ScanOptions
|
|
189
|
+
*/
|
|
190
|
+
export interface ScanOptions {
|
|
191
|
+
/**
|
|
192
|
+
* By allowing duplicates scanning records are received more frequently [iOS only]
|
|
193
|
+
* @memberof ScanOptions
|
|
194
|
+
* @instance
|
|
195
|
+
*/
|
|
196
|
+
allowDuplicates?: boolean;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Scan mode for Bluetooth LE scan [Android and Harmony]
|
|
200
|
+
* @memberof ScanOptions
|
|
201
|
+
* @instance
|
|
202
|
+
*/
|
|
203
|
+
scanMode?: $Values<typeof ScanMode>;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Scan callback type for Bluetooth LE scan [Android only]
|
|
207
|
+
* @memberof ScanOptions
|
|
208
|
+
* @instance
|
|
209
|
+
*/
|
|
210
|
+
callbackType?: $Values<typeof ScanCallbackType>;
|
|
211
|
+
/**
|
|
212
|
+
* Use legacyScan (default true) [Android only]
|
|
213
|
+
* https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setLegacy(boolean)
|
|
214
|
+
* @memberof ScanOptions
|
|
215
|
+
* @instance
|
|
216
|
+
*/
|
|
217
|
+
legacyScan?: boolean;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Time of delay for reporting the scan result [Harmony only]
|
|
221
|
+
* @memberof ScanOptions
|
|
222
|
+
* @instance
|
|
223
|
+
*/
|
|
224
|
+
interval?: number;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Match mode for Bluetooth LE scan filters hardware match [Harmony only]
|
|
228
|
+
* @memberof ScanOptions
|
|
229
|
+
* @instance
|
|
230
|
+
*/
|
|
231
|
+
matchMode?: $Values<typeof MatchMode>;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Physical Layer used during scan [Harmony only]
|
|
235
|
+
* @memberof ScanOptions
|
|
236
|
+
* @instance
|
|
237
|
+
*/
|
|
238
|
+
phyType?: $Values<typeof PhyType>;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Connection specific options to be passed before connection happen. [Not used]
|
|
243
|
+
*/
|
|
244
|
+
export interface ConnectionOptions {
|
|
245
|
+
/**
|
|
246
|
+
* Whether to directly connect to the remote device (false) or to automatically connect as soon as the remote device
|
|
247
|
+
* becomes available (true). [Android only]
|
|
248
|
+
* @memberof ConnectionOptions
|
|
249
|
+
* @instance
|
|
250
|
+
*/
|
|
251
|
+
autoConnect?: boolean;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Whether MTU size will be negotiated to this value. It is not guaranteed to get it after connection is successful.
|
|
255
|
+
*
|
|
256
|
+
* @memberof ConnectionOptions
|
|
257
|
+
* @instance
|
|
258
|
+
*/
|
|
259
|
+
requestMTU?: number;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Whether action will be taken to reset services cache. This option may be useful when a peripheral's firmware was
|
|
263
|
+
* updated and it's services/characteristics were added/removed/altered. [Android only]
|
|
264
|
+
* {@link https://stackoverflow.com/questions/22596951/how-to-programmatically-force-bluetooth-low-energy-service-discovery-on-android}
|
|
265
|
+
* @memberof ConnectionOptions
|
|
266
|
+
* @instance
|
|
267
|
+
*/
|
|
268
|
+
refreshGatt?: RefreshGattMoment;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Number of milliseconds after connection is automatically timed out. In case of race condition were connection is
|
|
272
|
+
* established right after timeout event, device will be disconnected immediately. Time out may happen earlier then
|
|
273
|
+
* specified due to OS specific behavior.
|
|
274
|
+
*
|
|
275
|
+
* @memberof ConnectionOptions
|
|
276
|
+
* @instance
|
|
277
|
+
*/
|
|
278
|
+
timeout?: number;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Device Bluetooth Low Energy state. It's keys are used to check {@link #blemanagerstate} values
|
|
283
|
+
* received by {@link BleManager}
|
|
284
|
+
*/
|
|
285
|
+
export const State = {
|
|
286
|
+
/**
|
|
287
|
+
* The current state of the manager is unknown; an update is imminent.
|
|
288
|
+
*/
|
|
289
|
+
Unknown: 'Unknown',
|
|
290
|
+
/**
|
|
291
|
+
* The connection with the system service was momentarily lost; an update is imminent.
|
|
292
|
+
*/
|
|
293
|
+
Resetting: 'Resetting',
|
|
294
|
+
/**
|
|
295
|
+
* The platform does not support Bluetooth low energy.
|
|
296
|
+
*/
|
|
297
|
+
Unsupported: 'Unsupported',
|
|
298
|
+
/**
|
|
299
|
+
* The app is not authorized to use Bluetooth low energy.
|
|
300
|
+
*/
|
|
301
|
+
Unauthorized: 'Unauthorized',
|
|
302
|
+
/**
|
|
303
|
+
* Bluetooth is currently powered off.
|
|
304
|
+
*/
|
|
305
|
+
PoweredOff: 'PoweredOff',
|
|
306
|
+
/**
|
|
307
|
+
* Bluetooth is currently powered on and available to use.
|
|
308
|
+
*/
|
|
309
|
+
PoweredOn: 'PoweredOn'
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Native module logging log level. By default it is set to None.
|
|
314
|
+
* @name LogLevel
|
|
315
|
+
*/
|
|
316
|
+
export const LogLevel = {
|
|
317
|
+
/**
|
|
318
|
+
* Logging in native module is disabled
|
|
319
|
+
*/
|
|
320
|
+
None: 'None',
|
|
321
|
+
/**
|
|
322
|
+
* All logs in native module are shown
|
|
323
|
+
*/
|
|
324
|
+
Verbose: 'Verbose',
|
|
325
|
+
/**
|
|
326
|
+
* Only debug logs and of higher importance are shown in native module.
|
|
327
|
+
*/
|
|
328
|
+
Debug: 'Debug',
|
|
329
|
+
/**
|
|
330
|
+
* Only info logs and of higher importance are shown in native module.
|
|
331
|
+
*/
|
|
332
|
+
Info: 'Info',
|
|
333
|
+
/**
|
|
334
|
+
* Only warning logs and of higher importance are shown in native module.
|
|
335
|
+
*/
|
|
336
|
+
Warning: 'Warning',
|
|
337
|
+
/**
|
|
338
|
+
* Only error logs and of higher importance are shown in native module.
|
|
339
|
+
*/
|
|
340
|
+
Error: 'Error'
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Connection priority of BLE link determining the balance between power consumption and data throughput.
|
|
345
|
+
* @name ConnectionPriority
|
|
346
|
+
*/
|
|
347
|
+
export const ConnectionPriority = {
|
|
348
|
+
/**
|
|
349
|
+
* Default, recommended option balanced between power consumption and data throughput.
|
|
350
|
+
*/
|
|
351
|
+
Balanced: 0,
|
|
352
|
+
/**
|
|
353
|
+
* High priority, low latency connection, which increases transfer speed at the expense of power consumption.
|
|
354
|
+
*/
|
|
355
|
+
High: 1,
|
|
356
|
+
/**
|
|
357
|
+
* Low power, reduced data rate connection setup.
|
|
358
|
+
*/
|
|
359
|
+
LowPower: 2
|
|
360
|
+
}
|