react-native-ble-manager 8.8.0 → 9.1.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.
Files changed (60) hide show
  1. package/README.md +131 -44
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  8. package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
  11. package/android/.gradle/7.4/gc.properties +0 -0
  12. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  13. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  14. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  15. package/android/.gradle/file-system.probe +0 -0
  16. package/android/.gradle/vcs-1/gc.properties +0 -0
  17. package/android/.idea/.name +1 -0
  18. package/android/.idea/compiler.xml +6 -0
  19. package/android/.idea/gradle.xml +18 -0
  20. package/android/.idea/jarRepositories.xml +40 -0
  21. package/android/.idea/misc.xml +10 -0
  22. package/android/.idea/vcs.xml +6 -0
  23. package/android/build.gradle +17 -17
  24. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  25. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  26. package/android/gradle.properties +3 -1
  27. package/android/gradlew +234 -0
  28. package/android/gradlew.bat +89 -0
  29. package/android/local.properties +8 -0
  30. package/android/src/main/java/it/innove/BleManager.java +38 -17
  31. package/android/src/main/java/it/innove/LegacyScanManager.java +33 -28
  32. package/android/src/main/java/it/innove/LollipopPeripheral.java +66 -65
  33. package/android/src/main/java/it/innove/LollipopScanManager.java +52 -25
  34. package/android/src/main/java/it/innove/Peripheral.java +973 -838
  35. package/android/src/main/java/it/innove/ScanManager.java +24 -23
  36. package/dist/cjs/index.d.ts +156 -0
  37. package/dist/cjs/index.js +507 -0
  38. package/dist/cjs/index.js.map +1 -0
  39. package/dist/cjs/types.d.ts +311 -0
  40. package/dist/cjs/types.js +110 -0
  41. package/dist/cjs/types.js.map +1 -0
  42. package/dist/esm/index.d.ts +156 -0
  43. package/dist/esm/index.js +491 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/types.d.ts +311 -0
  46. package/dist/esm/types.js +107 -0
  47. package/dist/esm/types.js.map +1 -0
  48. package/ios/BleManager.h +1 -0
  49. package/ios/BleManager.m +213 -115
  50. package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  51. package/ios/BleManager.xcodeproj/project.xcworkspace/xcuserdata/marco.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  52. package/ios/BleManager.xcodeproj/xcuserdata/marco.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  53. package/ios/CBPeripheral+Extensions.m +1 -1
  54. package/package.json +31 -4
  55. package/src/index.ts +595 -0
  56. package/src/types.ts +336 -0
  57. package/.github/FUNDING.yml +0 -3
  58. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  59. package/BleManager.js +0 -427
  60. package/index.d.ts +0 -294
@@ -0,0 +1,311 @@
1
+ /**
2
+ * android states: https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_STATE
3
+ * ios states: https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerstate
4
+ * */
5
+ export declare enum BleState {
6
+ /**
7
+ * [iOS only]
8
+ */
9
+ Unknown = "unknown",
10
+ /**
11
+ * [iOS only]
12
+ */
13
+ Resetting = "resetting",
14
+ Unsupported = "unsupported",
15
+ /**
16
+ * [iOS only]
17
+ */
18
+ Unauthorized = "unauthorized",
19
+ On = "on",
20
+ Off = "off",
21
+ /**
22
+ * [android only]
23
+ */
24
+ TurningOn = "turning_on",
25
+ /**
26
+ * [android only]
27
+ */
28
+ TurningOff = "turning_off"
29
+ }
30
+ export interface Peripheral {
31
+ id: string;
32
+ rssi: number;
33
+ name?: string;
34
+ advertising: AdvertisingData;
35
+ }
36
+ export interface AdvertisingData {
37
+ isConnectable?: boolean;
38
+ localName?: string;
39
+ manufacturerData?: CustomAdvertisingData;
40
+ serviceData?: CustomAdvertisingData;
41
+ serviceUUIDs?: string[];
42
+ txPowerLevel?: number;
43
+ }
44
+ export interface CustomAdvertisingData {
45
+ CDVType: 'ArrayBuffer';
46
+ /**
47
+ * data as an array of numbers (which can be converted back to a Uint8Array (ByteArray),
48
+ * using something like [Buffer.from()](https://github.com/feross/buffer))
49
+ */
50
+ bytes: number[];
51
+ /**
52
+ * base64-encoded string of the data
53
+ */
54
+ data: string;
55
+ }
56
+ export interface StartOptions {
57
+ /**
58
+ * [iOS only]
59
+ */
60
+ showAlert?: boolean;
61
+ /**
62
+ * [iOS only]
63
+ */
64
+ restoreIdentifierKey?: string;
65
+ /**
66
+ * [iOS only]
67
+ */
68
+ queueIdentifierKey?: string;
69
+ /**
70
+ * [android only]
71
+ */
72
+ forceLegacy?: boolean;
73
+ }
74
+ /**
75
+ * [android only]
76
+ * https://developer.android.com/reference/android/bluetooth/le/ScanSettings
77
+ */
78
+ export interface ScanOptions {
79
+ /**
80
+ * This will only works if a ScanFilter is active. Otherwise, may not retrieve any result.
81
+ * See https://developer.android.com/reference/android/bluetooth/le/ScanSettings#MATCH_NUM_FEW_ADVERTISEMENT.
82
+ * */
83
+ numberOfMatches?: BleScanMatchCount;
84
+ matchMode?: BleScanMatchMode;
85
+ /**
86
+ * This will only works if a ScanFilter is active. Otherwise, may not retrieve any result.
87
+ * See https://developer.android.com/reference/android/bluetooth/le/ScanSettings#CALLBACK_TYPE_FIRST_MATCH.
88
+ * Also read [this issue](https://github.com/dariuszseweryn/RxAndroidBle/issues/561#issuecomment-532295346) for a deeper understanding
89
+ * of the very brittle stability of ScanSettings on android.
90
+ * */
91
+ callbackType?: BleScanCallbackType;
92
+ scanMode?: BleScanMode;
93
+ /**
94
+ * This is supposed to push results after a certain delay.
95
+ * In practice it is tricky, use with caution.
96
+ * Do not set something below 5000ms as it will wait that long anyway before pushing the first results,
97
+ * or on some phones it will ignore that setting and behave just like it was set to 0.
98
+ * Set your minimum scan duration accordingly, otherwise you will not retrieve the batched results.
99
+ * https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setReportDelay(long)
100
+ */
101
+ reportDelay?: number;
102
+ /**
103
+ * Does not work in conjunction with legacy scans. Setting an unsupported PHY will result in a failure to scan,
104
+ * use with caution.
105
+ * https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setPhy(int)
106
+ */
107
+ phy?: BleScanPhyMode;
108
+ /**
109
+ * true by default for compatibility with older apps.
110
+ * In that mode, scan will only retrieve advertisements data as specified by BLE 4.2 and below.
111
+ * Change this if you want to benefit from the extended BLE 5 advertisement spec.
112
+ * https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setLegacy(boolean)
113
+ */
114
+ legacy?: boolean;
115
+ /**
116
+ * an android ScanFilter, used if present to restrict scan results to devices with a specific advertising name.
117
+ * This is a whole word match, not a partial search.
118
+ * Use with caution, it's behavior is tricky and seems to be the following:
119
+ * if `callbackType` is set to `AllMatches`, only the completeLocalName will be used for filtering.
120
+ * if `callbackType` is set to `FirstMatch`, the shortenedLocalName will be used for filtering.
121
+ * https://developer.android.com/reference/android/bluetooth/le/ScanFilter.Builder#setDeviceName(java.lang.String)
122
+ */
123
+ exactAdvertisingName?: string;
124
+ }
125
+ /**
126
+ * [android only]
127
+ */
128
+ export declare enum BleScanMode {
129
+ Opportunistic = -1,
130
+ LowPower = 0,
131
+ Balanced = 1,
132
+ LowLatency = 2
133
+ }
134
+ /**
135
+ * [android only]
136
+ */
137
+ export declare enum BleScanMatchMode {
138
+ Aggressive = 1,
139
+ Sticky = 2
140
+ }
141
+ /**
142
+ * [android only]
143
+ */
144
+ export declare enum BleScanCallbackType {
145
+ AllMatches = 1,
146
+ FirstMatch = 2,
147
+ MatchLost = 4
148
+ }
149
+ /**
150
+ * [android only]
151
+ */
152
+ export declare enum BleScanMatchCount {
153
+ OneAdvertisement = 1,
154
+ FewAdvertisements = 2,
155
+ MaxAdvertisements = 3
156
+ }
157
+ /**
158
+ * [android only]
159
+ */
160
+ export declare enum BleScanPhyMode {
161
+ LE_1M = 1,
162
+ LE_2M = 2,
163
+ LE_CODED = 3,
164
+ ALL_SUPPORTED = 255
165
+ }
166
+ /**
167
+ * [android only API 21+]
168
+ */
169
+ export declare enum ConnectionPriority {
170
+ balanced = 0,
171
+ high = 1,
172
+ low = 2
173
+ }
174
+ export interface Service {
175
+ uuid: string;
176
+ }
177
+ export interface Descriptor {
178
+ value: string;
179
+ uuid: string;
180
+ }
181
+ export interface Characteristic {
182
+ /**
183
+ * See https://developer.apple.com/documentation/corebluetooth/cbcharacteristicproperties
184
+ */
185
+ properties: {
186
+ Broadcast?: "Broadcast";
187
+ Read?: "Read";
188
+ WriteWithoutResponse?: "WriteWithoutResponse";
189
+ Write?: "Write";
190
+ Notify?: "Notify";
191
+ Indicate?: "Indicate";
192
+ AuthenticatedSignedWrites?: "AuthenticatedSignedWrites";
193
+ ExtendedProperties?: "ExtendedProperties";
194
+ NotifyEncryptionRequired?: "NotifyEncryptionRequired";
195
+ IndicateEncryptionRequired?: "IndicateEncryptionRequired";
196
+ };
197
+ characteristic: string;
198
+ service: string;
199
+ descriptors?: Descriptor[];
200
+ }
201
+ export interface PeripheralInfo extends Peripheral {
202
+ serviceUUIDs?: string[];
203
+ characteristics?: Characteristic[];
204
+ services?: Service[];
205
+ }
206
+ export declare enum BleEventType {
207
+ BleManagerDidUpdateState = "BleManagerDidUpdateState",
208
+ BleManagerStopScan = "BleManagerStopScan",
209
+ BleManagerDiscoverPeripheral = "BleManagerDiscoverPeripheral",
210
+ BleManagerDidUpdateValueForCharacteristic = "BleManagerDidUpdateValueForCharacteristic",
211
+ BleManagerConnectPeripheral = "BleManagerConnectPeripheral",
212
+ BleManagerDisconnectPeripheral = "BleManagerDisconnectPeripheral",
213
+ /**
214
+ * [Android only]
215
+ */
216
+ BleManagerPeripheralDidBond = "BleManagerPeripheralDidBond",
217
+ /**
218
+ * [iOS only]
219
+ */
220
+ BleManagerCentralManagerWillRestoreState = "BleManagerCentralManagerWillRestoreState",
221
+ /**
222
+ * [iOS only]
223
+ */
224
+ BleManagerDidUpdateNotificationStateFor = "BleManagerDidUpdateNotificationStateFor"
225
+ }
226
+ export interface BleStopScanEvent {
227
+ /**
228
+ * [iOS only]
229
+ */
230
+ status?: number;
231
+ }
232
+ export interface BleManagerDidUpdateStateEvent {
233
+ state: BleState;
234
+ }
235
+ export interface BleConnectPeripheralEvent {
236
+ /**
237
+ * peripheral id
238
+ */
239
+ readonly peripheral: string;
240
+ /**
241
+ * [android only]
242
+ */
243
+ readonly status?: number;
244
+ }
245
+ export type BleDiscoverPeripheralEvent = Peripheral;
246
+ /**
247
+ * [Android only]
248
+ */
249
+ export type BleBondedPeripheralEvent = Peripheral;
250
+ export interface BleDisconnectPeripheralEvent {
251
+ /**
252
+ * peripheral id
253
+ */
254
+ readonly peripheral: string;
255
+ /**
256
+ * [android only] disconnect reason.
257
+ */
258
+ readonly status?: number;
259
+ /**
260
+ * [iOS only] disconnect error domain.
261
+ */
262
+ readonly domain?: string;
263
+ /**
264
+ * [iOS only] disconnect error code.
265
+ */
266
+ readonly code?: number;
267
+ }
268
+ export interface BleManagerDidUpdateValueForCharacteristicEvent {
269
+ /**
270
+ * characteristic UUID
271
+ */
272
+ readonly characteristic: string;
273
+ /**
274
+ * peripheral id
275
+ */
276
+ readonly peripheral: string;
277
+ /**
278
+ * service UUID
279
+ */
280
+ readonly service: string;
281
+ /**
282
+ * data as an array of numbers (which can be converted back to a Uint8Array (ByteArray),
283
+ * using something like [Buffer.from()](https://github.com/feross/buffer))
284
+ */
285
+ readonly value: number[];
286
+ }
287
+ /**
288
+ * [iOS only]
289
+ */
290
+ export interface BleManagerDidUpdateNotificationStateForEvent {
291
+ /**
292
+ * peripheral id
293
+ */
294
+ readonly peripheral: string;
295
+ /**
296
+ * characteristic UUID
297
+ */
298
+ readonly characteristic: string;
299
+ /**
300
+ * is the characteristic notifying or not
301
+ */
302
+ readonly isNotifying: boolean;
303
+ /**
304
+ * error domain
305
+ */
306
+ readonly domain: string;
307
+ /**
308
+ * error code
309
+ */
310
+ readonly code: number;
311
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BleEventType = exports.ConnectionPriority = exports.BleScanPhyMode = exports.BleScanMatchCount = exports.BleScanCallbackType = exports.BleScanMatchMode = exports.BleScanMode = exports.BleState = void 0;
4
+ /**
5
+ * android states: https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#EXTRA_STATE
6
+ * ios states: https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerstate
7
+ * */
8
+ var BleState;
9
+ (function (BleState) {
10
+ /**
11
+ * [iOS only]
12
+ */
13
+ BleState["Unknown"] = "unknown";
14
+ /**
15
+ * [iOS only]
16
+ */
17
+ BleState["Resetting"] = "resetting";
18
+ BleState["Unsupported"] = "unsupported";
19
+ /**
20
+ * [iOS only]
21
+ */
22
+ BleState["Unauthorized"] = "unauthorized";
23
+ BleState["On"] = "on";
24
+ BleState["Off"] = "off";
25
+ /**
26
+ * [android only]
27
+ */
28
+ BleState["TurningOn"] = "turning_on";
29
+ /**
30
+ * [android only]
31
+ */
32
+ BleState["TurningOff"] = "turning_off";
33
+ })(BleState = exports.BleState || (exports.BleState = {}));
34
+ /**
35
+ * [android only]
36
+ */
37
+ var BleScanMode;
38
+ (function (BleScanMode) {
39
+ BleScanMode[BleScanMode["Opportunistic"] = -1] = "Opportunistic";
40
+ BleScanMode[BleScanMode["LowPower"] = 0] = "LowPower";
41
+ BleScanMode[BleScanMode["Balanced"] = 1] = "Balanced";
42
+ BleScanMode[BleScanMode["LowLatency"] = 2] = "LowLatency";
43
+ })(BleScanMode = exports.BleScanMode || (exports.BleScanMode = {}));
44
+ /**
45
+ * [android only]
46
+ */
47
+ var BleScanMatchMode;
48
+ (function (BleScanMatchMode) {
49
+ BleScanMatchMode[BleScanMatchMode["Aggressive"] = 1] = "Aggressive";
50
+ BleScanMatchMode[BleScanMatchMode["Sticky"] = 2] = "Sticky";
51
+ })(BleScanMatchMode = exports.BleScanMatchMode || (exports.BleScanMatchMode = {}));
52
+ /**
53
+ * [android only]
54
+ */
55
+ var BleScanCallbackType;
56
+ (function (BleScanCallbackType) {
57
+ BleScanCallbackType[BleScanCallbackType["AllMatches"] = 1] = "AllMatches";
58
+ BleScanCallbackType[BleScanCallbackType["FirstMatch"] = 2] = "FirstMatch";
59
+ BleScanCallbackType[BleScanCallbackType["MatchLost"] = 4] = "MatchLost";
60
+ })(BleScanCallbackType = exports.BleScanCallbackType || (exports.BleScanCallbackType = {}));
61
+ /**
62
+ * [android only]
63
+ */
64
+ var BleScanMatchCount;
65
+ (function (BleScanMatchCount) {
66
+ BleScanMatchCount[BleScanMatchCount["OneAdvertisement"] = 1] = "OneAdvertisement";
67
+ BleScanMatchCount[BleScanMatchCount["FewAdvertisements"] = 2] = "FewAdvertisements";
68
+ BleScanMatchCount[BleScanMatchCount["MaxAdvertisements"] = 3] = "MaxAdvertisements";
69
+ })(BleScanMatchCount = exports.BleScanMatchCount || (exports.BleScanMatchCount = {}));
70
+ /**
71
+ * [android only]
72
+ */
73
+ var BleScanPhyMode;
74
+ (function (BleScanPhyMode) {
75
+ BleScanPhyMode[BleScanPhyMode["LE_1M"] = 1] = "LE_1M";
76
+ BleScanPhyMode[BleScanPhyMode["LE_2M"] = 2] = "LE_2M";
77
+ BleScanPhyMode[BleScanPhyMode["LE_CODED"] = 3] = "LE_CODED";
78
+ BleScanPhyMode[BleScanPhyMode["ALL_SUPPORTED"] = 255] = "ALL_SUPPORTED";
79
+ })(BleScanPhyMode = exports.BleScanPhyMode || (exports.BleScanPhyMode = {}));
80
+ /**
81
+ * [android only API 21+]
82
+ */
83
+ var ConnectionPriority;
84
+ (function (ConnectionPriority) {
85
+ ConnectionPriority[ConnectionPriority["balanced"] = 0] = "balanced";
86
+ ConnectionPriority[ConnectionPriority["high"] = 1] = "high";
87
+ ConnectionPriority[ConnectionPriority["low"] = 2] = "low";
88
+ })(ConnectionPriority = exports.ConnectionPriority || (exports.ConnectionPriority = {}));
89
+ var BleEventType;
90
+ (function (BleEventType) {
91
+ BleEventType["BleManagerDidUpdateState"] = "BleManagerDidUpdateState";
92
+ BleEventType["BleManagerStopScan"] = "BleManagerStopScan";
93
+ BleEventType["BleManagerDiscoverPeripheral"] = "BleManagerDiscoverPeripheral";
94
+ BleEventType["BleManagerDidUpdateValueForCharacteristic"] = "BleManagerDidUpdateValueForCharacteristic";
95
+ BleEventType["BleManagerConnectPeripheral"] = "BleManagerConnectPeripheral";
96
+ BleEventType["BleManagerDisconnectPeripheral"] = "BleManagerDisconnectPeripheral";
97
+ /**
98
+ * [Android only]
99
+ */
100
+ BleEventType["BleManagerPeripheralDidBond"] = "BleManagerPeripheralDidBond";
101
+ /**
102
+ * [iOS only]
103
+ */
104
+ BleEventType["BleManagerCentralManagerWillRestoreState"] = "BleManagerCentralManagerWillRestoreState";
105
+ /**
106
+ * [iOS only]
107
+ */
108
+ BleEventType["BleManagerDidUpdateNotificationStateFor"] = "BleManagerDidUpdateNotificationStateFor";
109
+ })(BleEventType = exports.BleEventType || (exports.BleEventType = {}));
110
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAAA;;;KAGK;AACL,IAAY,QAwBX;AAxBD,WAAY,QAAQ;IAClB;;OAEG;IACH,+BAAmB,CAAA;IACnB;;OAEG;IACH,mCAAuB,CAAA;IACvB,uCAA2B,CAAA;IAC3B;;OAEG;IACH,yCAA6B,CAAA;IAC7B,qBAAS,CAAA;IACT,uBAAW,CAAA;IACX;;OAEG;IACH,oCAAwB,CAAA;IACxB;;OAEG;IACH,sCAA0B,CAAA;AAC5B,CAAC,EAxBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAwBnB;AAsGD;;GAEG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,gEAAkB,CAAA;IAClB,qDAAY,CAAA;IACZ,qDAAY,CAAA;IACZ,yDAAc,CAAA;AAChB,CAAC,EALW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAKtB;AAED;;GAEG;AACH,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,mEAAc,CAAA;IACd,2DAAU,CAAA;AACZ,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAED;;GAEG;AACH,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,yEAAc,CAAA;IACd,yEAAc,CAAA;IACd,uEAAa,CAAA;AACf,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B;AAED;;GAEG;AACH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,iFAAoB,CAAA;IACpB,mFAAqB,CAAA;IACrB,mFAAqB,CAAA;AACvB,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAED;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,qDAAS,CAAA;IACT,qDAAS,CAAA;IACT,2DAAY,CAAA;IACZ,uEAAmB,CAAA;AACrB,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB;AAED;;GAEG;AACH,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mEAAY,CAAA;IACZ,2DAAQ,CAAA;IACR,yDAAO,CAAA;AACT,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B;AAuCD,IAAY,YAmBX;AAnBD,WAAY,YAAY;IACtB,qEAAqD,CAAA;IACrD,yDAAyC,CAAA;IACzC,6EAA6D,CAAA;IAC7D,uGAAuF,CAAA;IACvF,2EAA2D,CAAA;IAC3D,iFAAiE,CAAA;IACjE;;OAEG;IACH,2EAA2D,CAAA;IAC3D;;OAEG;IACH,qGAAqF,CAAA;IACrF;;OAEG;IACH,mGAAmF,CAAA;AACrF,CAAC,EAnBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAmBvB"}
@@ -0,0 +1,156 @@
1
+ import { BleState, ConnectionPriority, Peripheral, PeripheralInfo, ScanOptions, StartOptions } from './types';
2
+ export * from './types';
3
+ declare class BleManager {
4
+ constructor();
5
+ /**
6
+ *
7
+ * @param peripheralId
8
+ * @param serviceUUID
9
+ * @param characteristicUUID
10
+ * @returns data as an array of numbers (which can be converted back to a Uint8Array (ByteArray) using something like [Buffer.from()](https://github.com/feross/buffer))
11
+ */
12
+ read(peripheralId: string, serviceUUID: string, characteristicUUID: string): Promise<number[]>;
13
+ /**
14
+ *
15
+ * @param peripheralId
16
+ * @param serviceUUID
17
+ * @param characteristicUUID
18
+ * @param descriptorUUID
19
+ * @returns data as an array of numbers (which can be converted back to a Uint8Array (ByteArray) using something like [Buffer.from()](https://github.com/feross/buffer))
20
+ */
21
+ readDescriptor(peripheralId: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string): Promise<number[]>;
22
+ /**
23
+ *
24
+ * @param peripheralId
25
+ * @returns a promise resolving with the updated RSSI (`number`) if it succeeds.
26
+ */
27
+ readRSSI(peripheralId: string): Promise<number>;
28
+ /**
29
+ * [Android only]
30
+ * @param peripheralId
31
+ * @returns a promise that resolves to a boolean indicating if gatt was successfully refreshed or not.
32
+ */
33
+ refreshCache(peripheralId: string): Promise<boolean>;
34
+ /**
35
+ *
36
+ * @param peripheralId
37
+ * @param serviceUUIDs [iOS only] optional filter of services to retrieve.
38
+ * @returns
39
+ */
40
+ retrieveServices(peripheralId: string, serviceUUIDs?: string[]): Promise<PeripheralInfo>;
41
+ /**
42
+ *
43
+ * @param peripheralId
44
+ * @param serviceUUID
45
+ * @param characteristicUUID
46
+ * @param data data to write as an array of numbers (which can be converted from a Uint8Array (ByteArray) using something like [Buffer.toJSON().data](https://github.com/feross/buffer))
47
+ * @param maxByteSize optional, defaults to 20
48
+ * @returns
49
+ */
50
+ write(peripheralId: string, serviceUUID: string, characteristicUUID: string, data: number[], maxByteSize?: number): Promise<void>;
51
+ /**
52
+ *
53
+ * @param peripheralId
54
+ * @param serviceUUID
55
+ * @param characteristicUUID
56
+ * @param data data to write as an array of numbers (which can be converted from a Uint8Array (ByteArray) using something like [Buffer.toJSON().data](https://github.com/feross/buffer))
57
+ * @param maxByteSize optional, defaults to 20
58
+ * @param queueSleepTime optional, defaults to 10. Only useful if data length is greater than maxByteSize.
59
+ * @returns
60
+ */
61
+ writeWithoutResponse(peripheralId: string, serviceUUID: string, characteristicUUID: string, data: number[], maxByteSize?: number, queueSleepTime?: number): Promise<void>;
62
+ connect(peripheralId: string): Promise<void>;
63
+ /**
64
+ * [Android only]
65
+ * @param peripheralId
66
+ * @param peripheralPin optional. will be used to auto-bond if possible.
67
+ * @returns
68
+ */
69
+ createBond(peripheralId: string, peripheralPin?: string | null): Promise<void>;
70
+ /**
71
+ * [Android only]
72
+ * @param peripheralId
73
+ * @returns
74
+ */
75
+ removeBond(peripheralId: string): Promise<void>;
76
+ /**
77
+ *
78
+ * @param peripheralId
79
+ * @param force [Android only] defaults to true.
80
+ * @returns
81
+ */
82
+ disconnect(peripheralId: string, force?: boolean): Promise<void>;
83
+ startNotification(peripheralId: string, serviceUUID: string, characteristicUUID: string): Promise<void>;
84
+ /**
85
+ * [Android only]
86
+ * @param peripheralId
87
+ * @param serviceUUID
88
+ * @param characteristicUUID
89
+ * @param buffer
90
+ * @returns
91
+ */
92
+ startNotificationUseBuffer(peripheralId: string, serviceUUID: string, characteristicUUID: string, buffer: number): Promise<void>;
93
+ stopNotification(peripheralId: string, serviceUUID: string, characteristicUUID: string): Promise<void>;
94
+ checkState(): Promise<BleState>;
95
+ start(options?: StartOptions): Promise<void>;
96
+ /**
97
+ *
98
+ * @param serviceUUIDs
99
+ * @param seconds amount of seconds to scan. if set to 0 or less, will scan until you call stopScan() or the OS stops the scan (background etc).
100
+ * @param allowDuplicates [iOS only]
101
+ * @param scanningOptions [Android only] optional map of properties to fine-tune scan behavior on android, see README.
102
+ * @returns
103
+ */
104
+ scan(serviceUUIDs: string[], seconds: number, allowDuplicates?: boolean, scanningOptions?: ScanOptions): Promise<void>;
105
+ stopScan(): Promise<void>;
106
+ /**
107
+ * [Android only] triggers an ENABLE_REQUEST intent to the end-user to enable bluetooth.
108
+ * @returns
109
+ */
110
+ enableBluetooth(): Promise<void>;
111
+ /**
112
+ *
113
+ * @param serviceUUIDs [optional] not used on android, optional on ios.
114
+ * @returns
115
+ */
116
+ getConnectedPeripherals(serviceUUIDs?: string[]): Promise<Peripheral[]>;
117
+ /**
118
+ * [Android only]
119
+ * @returns
120
+ */
121
+ getBondedPeripherals(): Promise<Peripheral[]>;
122
+ getDiscoveredPeripherals(): Promise<Peripheral[]>;
123
+ /**
124
+ * [Android only]
125
+ * @param peripheralId
126
+ * @returns
127
+ */
128
+ removePeripheral(peripheralId: string): Promise<void>;
129
+ /**
130
+ * @param peripheralId
131
+ * @param serviceUUIDs [optional] not used on android, optional on ios.
132
+ * @returns
133
+ */
134
+ isPeripheralConnected(peripheralId: string, serviceUUIDs?: string[]): Promise<boolean>;
135
+ /**
136
+ * [Android only, API 21+]
137
+ * @param peripheralId
138
+ * @param connectionPriority
139
+ * @returns a promise that resolves with a boolean indicating of the connection priority was changed successfully, or rejects with an error message.
140
+ */
141
+ requestConnectionPriority(peripheralId: string, connectionPriority: ConnectionPriority): Promise<boolean>;
142
+ /**
143
+ * [Android only, API 21+]
144
+ * @param peripheralId
145
+ * @param mtu size to be requested, in bytes.
146
+ * @returns a promise resolving with the negotiated MTU if it succeeded. Beware that it might not be the one requested due to device's BLE limitations on both side of the negotiation.
147
+ */
148
+ requestMTU(peripheralId: string, mtu: number): Promise<number>;
149
+ /**
150
+ * [Android only]
151
+ * @param name
152
+ */
153
+ setName(name: string): void;
154
+ }
155
+ declare const _default: BleManager;
156
+ export default _default;