react-native-ble-manager 8.7.0 → 9.0.0
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/README.md +96 -47
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.name +1 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +18 -0
- package/android/.idea/jarRepositories.xml +40 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +17 -17
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +3 -1
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -0
- package/android/local.properties +8 -0
- package/android/src/main/java/it/innove/BleManager.java +33 -17
- package/android/src/main/java/it/innove/LegacyScanManager.java +33 -28
- package/android/src/main/java/it/innove/LollipopPeripheral.java +66 -65
- package/android/src/main/java/it/innove/LollipopScanManager.java +52 -25
- package/android/src/main/java/it/innove/Peripheral.java +889 -837
- package/android/src/main/java/it/innove/ScanManager.java +24 -23
- package/dist/cjs/index.d.ts +147 -0
- package/dist/cjs/index.js +487 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.d.ts +311 -0
- package/dist/cjs/types.js +110 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/index.d.ts +147 -0
- package/dist/esm/index.js +471 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +311 -0
- package/dist/esm/types.js +107 -0
- package/dist/esm/types.js.map +1 -0
- package/ios/BleManager.m +87 -110
- package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/package.json +31 -4
- package/src/index.ts +569 -0
- package/src/types.ts +336 -0
- package/.github/FUNDING.yml +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/BleManager.js +0 -427
- package/index.d.ts +0 -168
package/BleManager.js
DELETED
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var React = require("react-native");
|
|
3
|
-
var bleManager = React.NativeModules.BleManager;
|
|
4
|
-
|
|
5
|
-
class BleManager {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.isPeripheralConnected = this.isPeripheralConnected.bind(this);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
read(peripheralId, serviceUUID, characteristicUUID) {
|
|
11
|
-
return new Promise((fulfill, reject) => {
|
|
12
|
-
bleManager.read(
|
|
13
|
-
peripheralId,
|
|
14
|
-
serviceUUID,
|
|
15
|
-
characteristicUUID,
|
|
16
|
-
(error, data) => {
|
|
17
|
-
if (error) {
|
|
18
|
-
reject(error);
|
|
19
|
-
} else {
|
|
20
|
-
fulfill(data);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
readRSSI(peripheralId) {
|
|
28
|
-
return new Promise((fulfill, reject) => {
|
|
29
|
-
bleManager.readRSSI(peripheralId, (error, rssi) => {
|
|
30
|
-
if (error) {
|
|
31
|
-
reject(error);
|
|
32
|
-
} else {
|
|
33
|
-
fulfill(rssi);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
refreshCache(peripheralId) {
|
|
40
|
-
return new Promise((fulfill, reject) => {
|
|
41
|
-
bleManager.refreshCache(peripheralId, (error, result) => {
|
|
42
|
-
if (error) {
|
|
43
|
-
reject(error);
|
|
44
|
-
} else {
|
|
45
|
-
fulfill(result);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
retrieveServices(peripheralId, services) {
|
|
52
|
-
return new Promise((fulfill, reject) => {
|
|
53
|
-
bleManager.retrieveServices(
|
|
54
|
-
peripheralId,
|
|
55
|
-
services,
|
|
56
|
-
(error, peripheral) => {
|
|
57
|
-
if (error) {
|
|
58
|
-
reject(error);
|
|
59
|
-
} else {
|
|
60
|
-
fulfill(peripheral);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
write(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize) {
|
|
68
|
-
if (maxByteSize == null) {
|
|
69
|
-
maxByteSize = 20;
|
|
70
|
-
}
|
|
71
|
-
return new Promise((fulfill, reject) => {
|
|
72
|
-
bleManager.write(
|
|
73
|
-
peripheralId,
|
|
74
|
-
serviceUUID,
|
|
75
|
-
characteristicUUID,
|
|
76
|
-
data,
|
|
77
|
-
maxByteSize,
|
|
78
|
-
error => {
|
|
79
|
-
if (error) {
|
|
80
|
-
reject(error);
|
|
81
|
-
} else {
|
|
82
|
-
fulfill();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
writeWithoutResponse(
|
|
90
|
-
peripheralId,
|
|
91
|
-
serviceUUID,
|
|
92
|
-
characteristicUUID,
|
|
93
|
-
data,
|
|
94
|
-
maxByteSize,
|
|
95
|
-
queueSleepTime
|
|
96
|
-
) {
|
|
97
|
-
if (maxByteSize == null) {
|
|
98
|
-
maxByteSize = 20;
|
|
99
|
-
}
|
|
100
|
-
if (queueSleepTime == null) {
|
|
101
|
-
queueSleepTime = 10;
|
|
102
|
-
}
|
|
103
|
-
return new Promise((fulfill, reject) => {
|
|
104
|
-
bleManager.writeWithoutResponse(
|
|
105
|
-
peripheralId,
|
|
106
|
-
serviceUUID,
|
|
107
|
-
characteristicUUID,
|
|
108
|
-
data,
|
|
109
|
-
maxByteSize,
|
|
110
|
-
queueSleepTime,
|
|
111
|
-
error => {
|
|
112
|
-
if (error) {
|
|
113
|
-
reject(error);
|
|
114
|
-
} else {
|
|
115
|
-
fulfill();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
connect(peripheralId) {
|
|
123
|
-
return new Promise((fulfill, reject) => {
|
|
124
|
-
bleManager.connect(peripheralId, error => {
|
|
125
|
-
if (error) {
|
|
126
|
-
reject(error);
|
|
127
|
-
} else {
|
|
128
|
-
fulfill();
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
createBond(peripheralId,peripheralPin=null) {
|
|
135
|
-
return new Promise((fulfill, reject) => {
|
|
136
|
-
bleManager.createBond(peripheralId,peripheralPin, error => {
|
|
137
|
-
if (error) {
|
|
138
|
-
reject(error);
|
|
139
|
-
} else {
|
|
140
|
-
fulfill();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
removeBond(peripheralId) {
|
|
147
|
-
return new Promise((fulfill, reject) => {
|
|
148
|
-
bleManager.removeBond(peripheralId, error => {
|
|
149
|
-
if (error) {
|
|
150
|
-
reject(error);
|
|
151
|
-
} else {
|
|
152
|
-
fulfill();
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
disconnect(peripheralId, force = true) {
|
|
159
|
-
return new Promise((fulfill, reject) => {
|
|
160
|
-
bleManager.disconnect(peripheralId, force, error => {
|
|
161
|
-
if (error) {
|
|
162
|
-
reject(error);
|
|
163
|
-
} else {
|
|
164
|
-
fulfill();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
startNotification(peripheralId, serviceUUID, characteristicUUID) {
|
|
171
|
-
return new Promise((fulfill, reject) => {
|
|
172
|
-
bleManager.startNotification(
|
|
173
|
-
peripheralId,
|
|
174
|
-
serviceUUID,
|
|
175
|
-
characteristicUUID,
|
|
176
|
-
error => {
|
|
177
|
-
if (error) {
|
|
178
|
-
reject(error);
|
|
179
|
-
} else {
|
|
180
|
-
fulfill();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
startNotificationUseBuffer(
|
|
188
|
-
peripheralId,
|
|
189
|
-
serviceUUID,
|
|
190
|
-
characteristicUUID,
|
|
191
|
-
buffer
|
|
192
|
-
) {
|
|
193
|
-
return new Promise((fulfill, reject) => {
|
|
194
|
-
bleManager.startNotificationUseBuffer(
|
|
195
|
-
peripheralId,
|
|
196
|
-
serviceUUID,
|
|
197
|
-
characteristicUUID,
|
|
198
|
-
buffer,
|
|
199
|
-
error => {
|
|
200
|
-
if (error) {
|
|
201
|
-
reject(error);
|
|
202
|
-
} else {
|
|
203
|
-
fulfill();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
stopNotification(peripheralId, serviceUUID, characteristicUUID) {
|
|
211
|
-
return new Promise((fulfill, reject) => {
|
|
212
|
-
bleManager.stopNotification(
|
|
213
|
-
peripheralId,
|
|
214
|
-
serviceUUID,
|
|
215
|
-
characteristicUUID,
|
|
216
|
-
error => {
|
|
217
|
-
if (error) {
|
|
218
|
-
reject(error);
|
|
219
|
-
} else {
|
|
220
|
-
fulfill();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
checkState() {
|
|
228
|
-
bleManager.checkState();
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
start(options) {
|
|
232
|
-
return new Promise((fulfill, reject) => {
|
|
233
|
-
if (options == null) {
|
|
234
|
-
options = {};
|
|
235
|
-
}
|
|
236
|
-
bleManager.start(options, error => {
|
|
237
|
-
if (error) {
|
|
238
|
-
reject(error);
|
|
239
|
-
} else {
|
|
240
|
-
fulfill();
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
scan(serviceUUIDs, seconds, allowDuplicates, scanningOptions = {}) {
|
|
247
|
-
return new Promise((fulfill, reject) => {
|
|
248
|
-
if (allowDuplicates == null) {
|
|
249
|
-
allowDuplicates = false;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// (ANDROID) Match as many advertisement per filter as hw could allow
|
|
253
|
-
// depends on current capability and availability of the resources in hw.
|
|
254
|
-
if (scanningOptions.numberOfMatches == null) {
|
|
255
|
-
scanningOptions.numberOfMatches = 3;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// (ANDROID) Defaults to MATCH_MODE_AGGRESSIVE
|
|
259
|
-
if (scanningOptions.matchMode == null) {
|
|
260
|
-
scanningOptions.matchMode = 1;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// (ANDROID) Defaults to SCAN_MODE_LOW_POWER
|
|
264
|
-
if (scanningOptions.scanMode == null) {
|
|
265
|
-
scanningOptions.scanMode = 0;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// (ANDROID) Defaults to CALLBACK_TYPE_ALL_MATCHES
|
|
269
|
-
// WARN: sometimes, setting a scanSetting instead of leaving it untouched might result in unexpected behaviors.
|
|
270
|
-
// https://github.com/dariuszseweryn/RxAndroidBle/issues/462
|
|
271
|
-
if (scanningOptions.callbackType == null) {
|
|
272
|
-
scanningOptions.callbackType = 1;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// (ANDROID) Defaults to 0ms (report results immediately).
|
|
276
|
-
if (scanningOptions.reportDelay == null) {
|
|
277
|
-
scanningOptions.reportDelay = 0;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
bleManager.scan(
|
|
281
|
-
serviceUUIDs,
|
|
282
|
-
seconds,
|
|
283
|
-
allowDuplicates,
|
|
284
|
-
scanningOptions,
|
|
285
|
-
error => {
|
|
286
|
-
if (error) {
|
|
287
|
-
reject(error);
|
|
288
|
-
} else {
|
|
289
|
-
fulfill();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
);
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
stopScan() {
|
|
297
|
-
return new Promise((fulfill, reject) => {
|
|
298
|
-
bleManager.stopScan(error => {
|
|
299
|
-
if (error != null) {
|
|
300
|
-
reject(error);
|
|
301
|
-
} else {
|
|
302
|
-
fulfill();
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
enableBluetooth() {
|
|
309
|
-
return new Promise((fulfill, reject) => {
|
|
310
|
-
bleManager.enableBluetooth(error => {
|
|
311
|
-
if (error != null) {
|
|
312
|
-
reject(error);
|
|
313
|
-
} else {
|
|
314
|
-
fulfill();
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
getConnectedPeripherals(serviceUUIDs) {
|
|
321
|
-
return new Promise((fulfill, reject) => {
|
|
322
|
-
bleManager.getConnectedPeripherals(serviceUUIDs, (error, result) => {
|
|
323
|
-
if (error) {
|
|
324
|
-
reject(error);
|
|
325
|
-
} else {
|
|
326
|
-
if (result != null) {
|
|
327
|
-
fulfill(result);
|
|
328
|
-
} else {
|
|
329
|
-
fulfill([]);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
getBondedPeripherals() {
|
|
337
|
-
return new Promise((fulfill, reject) => {
|
|
338
|
-
bleManager.getBondedPeripherals((error, result) => {
|
|
339
|
-
if (error) {
|
|
340
|
-
reject(error);
|
|
341
|
-
} else {
|
|
342
|
-
if (result != null) {
|
|
343
|
-
fulfill(result);
|
|
344
|
-
} else {
|
|
345
|
-
fulfill([]);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
getDiscoveredPeripherals() {
|
|
353
|
-
return new Promise((fulfill, reject) => {
|
|
354
|
-
bleManager.getDiscoveredPeripherals((error, result) => {
|
|
355
|
-
if (error) {
|
|
356
|
-
reject(error);
|
|
357
|
-
} else {
|
|
358
|
-
if (result != null) {
|
|
359
|
-
fulfill(result);
|
|
360
|
-
} else {
|
|
361
|
-
fulfill([]);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
removePeripheral(peripheralId) {
|
|
369
|
-
return new Promise((fulfill, reject) => {
|
|
370
|
-
bleManager.removePeripheral(peripheralId, error => {
|
|
371
|
-
if (error) {
|
|
372
|
-
reject(error);
|
|
373
|
-
} else {
|
|
374
|
-
fulfill();
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
isPeripheralConnected(peripheralId, serviceUUIDs) {
|
|
381
|
-
return this.getConnectedPeripherals(serviceUUIDs).then(result => {
|
|
382
|
-
if (
|
|
383
|
-
result.find(p => {
|
|
384
|
-
return p.id === peripheralId;
|
|
385
|
-
})
|
|
386
|
-
) {
|
|
387
|
-
return true;
|
|
388
|
-
} else {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
requestConnectionPriority(peripheralId, connectionPriority) {
|
|
395
|
-
return new Promise((fulfill, reject) => {
|
|
396
|
-
bleManager.requestConnectionPriority(
|
|
397
|
-
peripheralId,
|
|
398
|
-
connectionPriority,
|
|
399
|
-
(error, status) => {
|
|
400
|
-
if (error) {
|
|
401
|
-
reject(error);
|
|
402
|
-
} else {
|
|
403
|
-
fulfill(status);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
);
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
requestMTU(peripheralId, mtu) {
|
|
411
|
-
return new Promise((fulfill, reject) => {
|
|
412
|
-
bleManager.requestMTU(peripheralId, mtu, (error, mtu) => {
|
|
413
|
-
if (error) {
|
|
414
|
-
reject(error);
|
|
415
|
-
} else {
|
|
416
|
-
fulfill(mtu);
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
setName(name) {
|
|
423
|
-
bleManager.setName(name);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
module.exports = new BleManager();
|
package/index.d.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
declare module "react-native-ble-manager" {
|
|
2
|
-
export interface Peripheral {
|
|
3
|
-
id: string;
|
|
4
|
-
rssi: number;
|
|
5
|
-
name?: string;
|
|
6
|
-
advertising: AdvertisingData;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface AdvertisingData {
|
|
10
|
-
isConnectable?: boolean;
|
|
11
|
-
localName?: string;
|
|
12
|
-
manufacturerData?: any;
|
|
13
|
-
serviceUUIDs?: string[];
|
|
14
|
-
txPowerLevel?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface StartOptions {
|
|
18
|
-
showAlert?: boolean;
|
|
19
|
-
restoreIdentifierKey?: string;
|
|
20
|
-
queueIdentifierKey?: string;
|
|
21
|
-
forceLegacy?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function start(options?: StartOptions): Promise<void>;
|
|
25
|
-
|
|
26
|
-
export interface ScanOptions {
|
|
27
|
-
numberOfMatches?: number;
|
|
28
|
-
matchMode?: number;
|
|
29
|
-
callbackType?: number;
|
|
30
|
-
scanMode?: number;
|
|
31
|
-
reportDelay?: number;
|
|
32
|
-
phy?: number;
|
|
33
|
-
legacy?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function scan(
|
|
37
|
-
serviceUUIDs: string[],
|
|
38
|
-
seconds: number,
|
|
39
|
-
allowDuplicates?: boolean,
|
|
40
|
-
options?: ScanOptions
|
|
41
|
-
): Promise<void>;
|
|
42
|
-
export function stopScan(): Promise<void>;
|
|
43
|
-
export function connect(peripheralID: string): Promise<void>;
|
|
44
|
-
export function disconnect(
|
|
45
|
-
peripheralID: string,
|
|
46
|
-
force?: boolean
|
|
47
|
-
): Promise<void>;
|
|
48
|
-
export function checkState(): void;
|
|
49
|
-
export function startNotification(
|
|
50
|
-
peripheralID: string,
|
|
51
|
-
serviceUUID: string,
|
|
52
|
-
characteristicUUID: string
|
|
53
|
-
): Promise<void>;
|
|
54
|
-
|
|
55
|
-
/// Android only
|
|
56
|
-
export function startNotificationUseBuffer(
|
|
57
|
-
peripheralID: string,
|
|
58
|
-
serviceUUID: string,
|
|
59
|
-
characteristicUUID: string,
|
|
60
|
-
buffer: number
|
|
61
|
-
): Promise<void>;
|
|
62
|
-
|
|
63
|
-
export function stopNotification(
|
|
64
|
-
peripheralID: string,
|
|
65
|
-
serviceUUID: string,
|
|
66
|
-
characteristicUUID: string
|
|
67
|
-
): Promise<void>;
|
|
68
|
-
|
|
69
|
-
export function read(
|
|
70
|
-
peripheralID: string,
|
|
71
|
-
serviceUUID: string,
|
|
72
|
-
characteristicUUID: string
|
|
73
|
-
): Promise<any>;
|
|
74
|
-
export function write(
|
|
75
|
-
peripheralID: string,
|
|
76
|
-
serviceUUID: string,
|
|
77
|
-
characteristicUUID: string,
|
|
78
|
-
data: any,
|
|
79
|
-
maxByteSize?: number
|
|
80
|
-
): Promise<void>;
|
|
81
|
-
export function writeWithoutResponse(
|
|
82
|
-
peripheralID: string,
|
|
83
|
-
serviceUUID: string,
|
|
84
|
-
characteristicUUID: string,
|
|
85
|
-
data: any,
|
|
86
|
-
maxByteSize?: number,
|
|
87
|
-
queueSleepTime?: number
|
|
88
|
-
): Promise<void>;
|
|
89
|
-
|
|
90
|
-
export function readRSSI(peripheralID: string): Promise<void>;
|
|
91
|
-
|
|
92
|
-
export function getConnectedPeripherals(
|
|
93
|
-
serviceUUIDs: string[]
|
|
94
|
-
): Promise<Peripheral[]>;
|
|
95
|
-
export function getDiscoveredPeripherals(): Promise<Peripheral[]>;
|
|
96
|
-
export function isPeripheralConnected(
|
|
97
|
-
peripheralID: string,
|
|
98
|
-
serviceUUIDs: string[]
|
|
99
|
-
): Promise<boolean>;
|
|
100
|
-
|
|
101
|
-
// [Android only API 21+]
|
|
102
|
-
export enum ConnectionPriority {
|
|
103
|
-
balanced = 0,
|
|
104
|
-
high = 1,
|
|
105
|
-
low = 2,
|
|
106
|
-
}
|
|
107
|
-
export function requestConnectionPriority(
|
|
108
|
-
peripheralID: string,
|
|
109
|
-
connectionPriority: ConnectionPriority
|
|
110
|
-
): Promise<void>;
|
|
111
|
-
/// Android only
|
|
112
|
-
export function enableBluetooth(): Promise<void>;
|
|
113
|
-
// [Android only]
|
|
114
|
-
export function refreshCache(peripheralID: string): Promise<void>;
|
|
115
|
-
// [Android only API 21+]
|
|
116
|
-
export function requestMTU(peripheralID: string, mtu: number): Promise<number>;
|
|
117
|
-
|
|
118
|
-
export function createBond(
|
|
119
|
-
peripheralID: string,
|
|
120
|
-
peripheralPin?: string
|
|
121
|
-
): Promise<void>;
|
|
122
|
-
export function removeBond(peripheralID: string): Promise<void>;
|
|
123
|
-
export function getBondedPeripherals(): Promise<Peripheral[]>;
|
|
124
|
-
export function removePeripheral(peripheralID: string): Promise<void>;
|
|
125
|
-
|
|
126
|
-
// [Android only]
|
|
127
|
-
export function setName(name: string): void;
|
|
128
|
-
|
|
129
|
-
export interface Service {
|
|
130
|
-
uuid: string;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface Descriptor {
|
|
134
|
-
value: string;
|
|
135
|
-
uuid: string;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface Characteristic {
|
|
139
|
-
// See https://developer.apple.com/documentation/corebluetooth/cbcharacteristicproperties
|
|
140
|
-
properties: {
|
|
141
|
-
Broadcast?: "Broadcast";
|
|
142
|
-
Read?: "Read";
|
|
143
|
-
WriteWithoutResponse?: "WriteWithoutResponse";
|
|
144
|
-
Write?: "Write";
|
|
145
|
-
Notify?: "Notify";
|
|
146
|
-
Indicate?: "Indicate";
|
|
147
|
-
AuthenticatedSignedWrites?: "AuthenticatedSignedWrites";
|
|
148
|
-
ExtendedProperties?: "ExtendedProperties";
|
|
149
|
-
NotifyEncryptionRequired?: "NotifyEncryptionRequired";
|
|
150
|
-
IndicateEncryptionRequired?: "IndicateEncryptionRequired";
|
|
151
|
-
}
|
|
152
|
-
characteristic: string;
|
|
153
|
-
service: string;
|
|
154
|
-
descriptors?: Descriptor[];
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export interface PeripheralInfo extends Peripheral {
|
|
159
|
-
serviceUUIDs?: string[];
|
|
160
|
-
characteristics?: Characteristic[];
|
|
161
|
-
services?: Service[];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function retrieveServices(
|
|
165
|
-
peripheralID: string,
|
|
166
|
-
serviceUUIDs?: string[]
|
|
167
|
-
): Promise<PeripheralInfo>;
|
|
168
|
-
}
|