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.
Files changed (56) hide show
  1. package/README.md +96 -47
  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 +33 -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 +889 -837
  35. package/android/src/main/java/it/innove/ScanManager.java +24 -23
  36. package/dist/cjs/index.d.ts +147 -0
  37. package/dist/cjs/index.js +487 -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 +147 -0
  43. package/dist/esm/index.js +471 -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.m +87 -110
  49. package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  50. package/package.json +31 -4
  51. package/src/index.ts +569 -0
  52. package/src/types.ts +336 -0
  53. package/.github/FUNDING.yml +0 -3
  54. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  55. package/BleManager.js +0 -427
  56. package/index.d.ts +0 -168
@@ -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,107 @@
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 var BleState;
6
+ (function (BleState) {
7
+ /**
8
+ * [iOS only]
9
+ */
10
+ BleState["Unknown"] = "unknown";
11
+ /**
12
+ * [iOS only]
13
+ */
14
+ BleState["Resetting"] = "resetting";
15
+ BleState["Unsupported"] = "unsupported";
16
+ /**
17
+ * [iOS only]
18
+ */
19
+ BleState["Unauthorized"] = "unauthorized";
20
+ BleState["On"] = "on";
21
+ BleState["Off"] = "off";
22
+ /**
23
+ * [android only]
24
+ */
25
+ BleState["TurningOn"] = "turning_on";
26
+ /**
27
+ * [android only]
28
+ */
29
+ BleState["TurningOff"] = "turning_off";
30
+ })(BleState || (BleState = {}));
31
+ /**
32
+ * [android only]
33
+ */
34
+ export var BleScanMode;
35
+ (function (BleScanMode) {
36
+ BleScanMode[BleScanMode["Opportunistic"] = -1] = "Opportunistic";
37
+ BleScanMode[BleScanMode["LowPower"] = 0] = "LowPower";
38
+ BleScanMode[BleScanMode["Balanced"] = 1] = "Balanced";
39
+ BleScanMode[BleScanMode["LowLatency"] = 2] = "LowLatency";
40
+ })(BleScanMode || (BleScanMode = {}));
41
+ /**
42
+ * [android only]
43
+ */
44
+ export var BleScanMatchMode;
45
+ (function (BleScanMatchMode) {
46
+ BleScanMatchMode[BleScanMatchMode["Aggressive"] = 1] = "Aggressive";
47
+ BleScanMatchMode[BleScanMatchMode["Sticky"] = 2] = "Sticky";
48
+ })(BleScanMatchMode || (BleScanMatchMode = {}));
49
+ /**
50
+ * [android only]
51
+ */
52
+ export var BleScanCallbackType;
53
+ (function (BleScanCallbackType) {
54
+ BleScanCallbackType[BleScanCallbackType["AllMatches"] = 1] = "AllMatches";
55
+ BleScanCallbackType[BleScanCallbackType["FirstMatch"] = 2] = "FirstMatch";
56
+ BleScanCallbackType[BleScanCallbackType["MatchLost"] = 4] = "MatchLost";
57
+ })(BleScanCallbackType || (BleScanCallbackType = {}));
58
+ /**
59
+ * [android only]
60
+ */
61
+ export var BleScanMatchCount;
62
+ (function (BleScanMatchCount) {
63
+ BleScanMatchCount[BleScanMatchCount["OneAdvertisement"] = 1] = "OneAdvertisement";
64
+ BleScanMatchCount[BleScanMatchCount["FewAdvertisements"] = 2] = "FewAdvertisements";
65
+ BleScanMatchCount[BleScanMatchCount["MaxAdvertisements"] = 3] = "MaxAdvertisements";
66
+ })(BleScanMatchCount || (BleScanMatchCount = {}));
67
+ /**
68
+ * [android only]
69
+ */
70
+ export var BleScanPhyMode;
71
+ (function (BleScanPhyMode) {
72
+ BleScanPhyMode[BleScanPhyMode["LE_1M"] = 1] = "LE_1M";
73
+ BleScanPhyMode[BleScanPhyMode["LE_2M"] = 2] = "LE_2M";
74
+ BleScanPhyMode[BleScanPhyMode["LE_CODED"] = 3] = "LE_CODED";
75
+ BleScanPhyMode[BleScanPhyMode["ALL_SUPPORTED"] = 255] = "ALL_SUPPORTED";
76
+ })(BleScanPhyMode || (BleScanPhyMode = {}));
77
+ /**
78
+ * [android only API 21+]
79
+ */
80
+ export var ConnectionPriority;
81
+ (function (ConnectionPriority) {
82
+ ConnectionPriority[ConnectionPriority["balanced"] = 0] = "balanced";
83
+ ConnectionPriority[ConnectionPriority["high"] = 1] = "high";
84
+ ConnectionPriority[ConnectionPriority["low"] = 2] = "low";
85
+ })(ConnectionPriority || (ConnectionPriority = {}));
86
+ export var BleEventType;
87
+ (function (BleEventType) {
88
+ BleEventType["BleManagerDidUpdateState"] = "BleManagerDidUpdateState";
89
+ BleEventType["BleManagerStopScan"] = "BleManagerStopScan";
90
+ BleEventType["BleManagerDiscoverPeripheral"] = "BleManagerDiscoverPeripheral";
91
+ BleEventType["BleManagerDidUpdateValueForCharacteristic"] = "BleManagerDidUpdateValueForCharacteristic";
92
+ BleEventType["BleManagerConnectPeripheral"] = "BleManagerConnectPeripheral";
93
+ BleEventType["BleManagerDisconnectPeripheral"] = "BleManagerDisconnectPeripheral";
94
+ /**
95
+ * [Android only]
96
+ */
97
+ BleEventType["BleManagerPeripheralDidBond"] = "BleManagerPeripheralDidBond";
98
+ /**
99
+ * [iOS only]
100
+ */
101
+ BleEventType["BleManagerCentralManagerWillRestoreState"] = "BleManagerCentralManagerWillRestoreState";
102
+ /**
103
+ * [iOS only]
104
+ */
105
+ BleEventType["BleManagerDidUpdateNotificationStateFor"] = "BleManagerDidUpdateNotificationStateFor";
106
+ })(BleEventType || (BleEventType = {}));
107
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;KAGK;AACL,MAAM,CAAN,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,KAAR,QAAQ,QAwBnB;AAsGD;;GAEG;AACH,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,gEAAkB,CAAA;IAClB,qDAAY,CAAA;IACZ,qDAAY,CAAA;IACZ,yDAAc,CAAA;AAChB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,mEAAc,CAAA;IACd,2DAAU,CAAA;AACZ,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,yEAAc,CAAA;IACd,yEAAc,CAAA;IACd,uEAAa,CAAA;AACf,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,iFAAoB,CAAA;IACpB,mFAAqB,CAAA;IACrB,mFAAqB,CAAA;AACvB,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,qDAAS,CAAA;IACT,qDAAS,CAAA;IACT,2DAAY,CAAA;IACZ,uEAAmB,CAAA;AACrB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mEAAY,CAAA;IACZ,2DAAQ,CAAA;IACR,yDAAO,CAAA;AACT,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAuCD,MAAM,CAAN,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,KAAZ,YAAY,QAmBvB"}