react-native-ble-manager 11.5.6 → 12.0.0-rc.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 (44) hide show
  1. package/README.md +16 -3
  2. package/RNBleManager.podspec +24 -0
  3. package/android/build.gradle +116 -43
  4. package/android/gradle.properties +1 -0
  5. package/android/src/main/java/it/innove/BleManager.java +174 -148
  6. package/android/src/main/java/it/innove/BleManagerPackage.java +15 -14
  7. package/android/src/main/java/it/innove/CompanionScanner.java +39 -13
  8. package/android/src/main/java/it/innove/DefaultPeripheral.java +4 -4
  9. package/android/src/main/java/it/innove/DefaultScanManager.java +16 -16
  10. package/android/src/main/java/it/innove/Peripheral.java +20 -17
  11. package/dist/cjs/NativeBleManager.d.ts +241 -0
  12. package/dist/cjs/NativeBleManager.js +5 -0
  13. package/dist/cjs/NativeBleManager.js.map +1 -0
  14. package/dist/cjs/index.d.ts +15 -3
  15. package/dist/cjs/index.js +89 -38
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/types.d.ts +17 -11
  18. package/dist/cjs/types.js +8 -8
  19. package/dist/cjs/types.js.map +1 -1
  20. package/dist/esm/NativeBleManager.d.ts +241 -0
  21. package/dist/esm/NativeBleManager.js +3 -0
  22. package/dist/esm/NativeBleManager.js.map +1 -0
  23. package/dist/esm/index.d.ts +15 -3
  24. package/dist/esm/index.js +92 -41
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/types.d.ts +17 -11
  27. package/ios/BleManager-Bridging-Header.h +7 -1
  28. package/ios/BleManager.h +39 -2
  29. package/ios/BleManager.mm +277 -0
  30. package/ios/Helper.swift +6 -6
  31. package/ios/RNBleManager.h +7 -0
  32. package/ios/{BleManager.swift → SwiftBleManager.swift} +322 -355
  33. package/package.json +107 -56
  34. package/src/NativeBleManager.ts +409 -0
  35. package/src/index.ts +162 -77
  36. package/src/types.ts +38 -31
  37. package/android/src/main/java/it/innove/LegacyScanManager.java +0 -112
  38. package/ios/BleManager.m +0 -153
  39. package/ios/BleManager.xcodeproj/project.pbxproj +0 -324
  40. package/ios/BleManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  41. package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  42. package/ios/BleManager.xcodeproj/project.xcworkspace/xcuserdata/marco.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  43. package/ios/BleManager.xcodeproj/xcuserdata/marco.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  44. package/react-native-ble-manager.podspec +0 -17
@@ -0,0 +1,241 @@
1
+ import { TurboModule } from 'react-native';
2
+ import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
3
+ /**
4
+ * This represents the Turbo Module version of react-native-ble-manager.
5
+ * This adds the codegen definition to react-native generate the c++ bindings on compile time.
6
+ * That should work only on 0.75 and higher.
7
+ * Don't remove it! and please modify with caution! Knowing that can create wrong bindings into jsi and break at compile or execution time.
8
+ * - Knowing that also every type needs to match the current Objective C++ and Java callbacks types and callbacks type definitions and be aware of the current differences between implementation in both platforms.
9
+ */
10
+ export interface Spec extends TurboModule {
11
+ start(options: Object, callback: (error: CallbackError) => void): void;
12
+ scan(serviceUUIDStrings: string[], timeoutSeconds: number, allowDuplicates: boolean, scanningOptions: Object, callback: (error: CallbackError) => void): void;
13
+ stopScan(callback: (error: CallbackError) => void): void;
14
+ connect(peripheralUUID: string, options: Object, callback: (error: CallbackError) => void): void;
15
+ disconnect(peripheralUUID: string, force: boolean, callback: (error: CallbackError) => void): void;
16
+ retrieveServices(peripheralUUID: string, services: string[], callback: (error: CallbackError, peripheral: PeripheralInfo) => void): void;
17
+ readRSSI(peripheralUUID: string, callback: (error: string | null, rssi: number) => void): void;
18
+ readDescriptor(peripheralUUID: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string, callback: (error: string | null, data: number[]) => void): void;
19
+ writeDescriptor(peripheralUUID: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string, data: object[], callback: (error: string | null) => void): void;
20
+ getDiscoveredPeripherals(callback: (error: string | null, result: Peripheral[] | null) => void): void;
21
+ checkState(callback: (state: BleState) => void): void;
22
+ write(peripheralUUID: string, serviceUUID: string, characteristicUUID: string, message: object[], maxByteSize: number, callback: (error: string | null) => void): void;
23
+ writeWithoutResponse(peripheralUUID: string, serviceUUID: string, characteristicUUID: string, message: object[], maxByteSize: number, queueSleepTime: number, callback: (error: string | null) => void): void;
24
+ read(peripheralUUID: string, serviceUUID: string, characteristicUUID: string, callback: (error: string | null, data: number[]) => void): void;
25
+ startNotification(peripheralUUID: string, serviceUUID: string, characteristicUUID: string, callback: (error: string | null) => void): void;
26
+ stopNotification(peripheralUUID: string, serviceUUID: string, characteristicUUID: string, callback: (error: string | null) => void): void;
27
+ getConnectedPeripherals(serviceUUIDStrings: string[], callback: (error: string | null, result: Peripheral[] | null) => void): void;
28
+ isPeripheralConnected(peripheralUUID: string, callback: (error: Peripheral[]) => void): void;
29
+ isScanning(callback: (error: string | null, status: boolean) => void): void;
30
+ getMaximumWriteValueLengthForWithoutResponse(peripheralUUID: string, callback: (error: string | null, max: number) => void): void;
31
+ getMaximumWriteValueLengthForWithResponse(deviceUUID: string, callback: (error: string | null, max: number) => void): void;
32
+ enableBluetooth(callback: (error: string | null) => void): void;
33
+ getBondedPeripherals(callback: (error: string | null, result: Peripheral[] | null) => void): void;
34
+ createBond(peripheralUUID: string, devicePin: string, callback: (error: string | null) => void): void;
35
+ removeBond(peripheralUUID: string, callback: (error: string | null) => void): void;
36
+ removePeripheral(peripheralUUID: string, callback: (error: string | null) => void): void;
37
+ requestMTU(peripheralUUID: string, mtu: number, callback: (error: string | null, mtu: number) => void): void;
38
+ requestConnectionPriority(peripheralUUID: string, connectionPriority: number, callback: (error: string | null, status: boolean) => void): void;
39
+ refreshCache(peripheralUUID: string, callback: (error: string | null, result: boolean) => void): void;
40
+ setName(name: string): void;
41
+ getAssociatedPeripherals(callback: (error: string | null, peripherals: Peripheral[] | null) => void): void;
42
+ removeAssociatedPeripheral(peripheralUUID: string, callback: (error: string | null) => void): void;
43
+ supportsCompanion(callback: (supports: boolean) => void): void;
44
+ companionScan(serviceUUIDs: string[], option: Object, callback: (error: string | null, peripheral: Peripheral | null) => void): void;
45
+ /**
46
+ * Supported events.
47
+ */
48
+ readonly onDiscoverPeripheral: EventEmitter<Peripheral>;
49
+ readonly onStopScan: EventEmitter<EventStopScan>;
50
+ readonly onDidUpdateState: EventEmitter<EventDidUpdateState>;
51
+ readonly onDidUpdateValueForCharacteristic: EventEmitter<EventDidUpdateValueForCharacteristic>;
52
+ readonly onConnectPeripheral: EventEmitter<EventConnectPeripheral>;
53
+ readonly onDisconnectPeripheral: EventEmitter<EventDisconnectPeripheral>;
54
+ readonly onPeripheralDidBond: EventEmitter<EventPeripheralDidBond>;
55
+ readonly onCentralManagerWillRestoreState: EventEmitter<EventCentralManagerWillRestoreState>;
56
+ readonly onDidUpdateNotificationStateFor: EventEmitter<EventDidUpdateNotificationStateFor>;
57
+ readonly onCompanionPeripheral: EventEmitter<EventCompanionPeripheral>;
58
+ readonly onCompanionFailure: EventEmitter<EventCompanionFailure>;
59
+ }
60
+ declare const _default: Spec;
61
+ export default _default;
62
+ /** Turbo Module Type Definitions */
63
+ export type BleScanCallbackType = number;
64
+ export type BleScanMatchCount = number;
65
+ export type BleScanMatchMode = number;
66
+ export type BleScanMode = number;
67
+ export type BleScanPhyMode = number;
68
+ export type CallbackError = string | null;
69
+ export type BleState = string;
70
+ export type Peripheral = {
71
+ id: string;
72
+ rssi: number;
73
+ name: string | null;
74
+ advertising: {
75
+ isConnectable?: boolean;
76
+ localName?: string | null;
77
+ rawData?: {
78
+ CDVType: number[];
79
+ bytes: number[];
80
+ data: string;
81
+ };
82
+ manufacturerData?: {
83
+ CDVType: number[];
84
+ bytes: number[];
85
+ data: string;
86
+ }[] | null;
87
+ manufacturerRawData?: {
88
+ CDVType: number[];
89
+ bytes: number[];
90
+ data: string;
91
+ } | null;
92
+ serviceData?: {
93
+ CDVType: number[];
94
+ bytes: number[];
95
+ data: string;
96
+ }[] | null;
97
+ serviceUUIDs?: string[];
98
+ txPowerLevel?: number;
99
+ };
100
+ };
101
+ export type PeripheralInfo = {
102
+ id: string;
103
+ rssi: number;
104
+ name: string | null;
105
+ advertising: {
106
+ isConnectable?: boolean;
107
+ localName?: string | null;
108
+ rawData?: {
109
+ CDVType: number[];
110
+ bytes: number[];
111
+ data: string;
112
+ } | null;
113
+ manufacturerData?: {
114
+ CDVType: number[];
115
+ bytes: number[];
116
+ data: string;
117
+ }[] | null;
118
+ manufacturerRawData?: {
119
+ CDVType: number[];
120
+ bytes: number[];
121
+ data: string;
122
+ } | null;
123
+ serviceData?: {
124
+ CDVType: number[];
125
+ bytes: number[];
126
+ data: string;
127
+ }[] | null;
128
+ serviceUUIDs?: string[];
129
+ txPowerLevel?: number;
130
+ };
131
+ serviceUUIDs?: string[];
132
+ characteristics?: {
133
+ properties: {
134
+ Broadcast?: string;
135
+ Read?: string;
136
+ WriteWithoutResponse?: string;
137
+ Write?: string;
138
+ Notify?: string;
139
+ Indicate?: string;
140
+ AuthenticatedSignedWrites?: string;
141
+ ExtendedProperties?: string;
142
+ NotifyEncryptionRequired?: string;
143
+ IndicateEncryptionRequired?: string;
144
+ };
145
+ characteristic: string;
146
+ service: string;
147
+ descriptors?: {
148
+ value: string;
149
+ uuid: string;
150
+ }[];
151
+ }[];
152
+ services?: {
153
+ uuid: string;
154
+ }[];
155
+ };
156
+ export type EventStopScan = {
157
+ status: number;
158
+ };
159
+ export type EventDidUpdateState = {
160
+ state: string;
161
+ };
162
+ export type EventDiscoverPeripheral = {
163
+ id: string;
164
+ name: string;
165
+ rssi: number;
166
+ advertising: {
167
+ isConnectable: boolean;
168
+ serviceUUIDs: string[];
169
+ manufacturerData: number[];
170
+ serviceData: number[];
171
+ txPowerLevel: number;
172
+ rawData?: number | null;
173
+ };
174
+ };
175
+ export type EventDidUpdateValueForCharacteristic = {
176
+ value: number[];
177
+ peripheral: string;
178
+ characteristic: string;
179
+ service: string;
180
+ };
181
+ export type EventConnectPeripheral = {
182
+ peripheral: string;
183
+ status?: number | null;
184
+ };
185
+ export type EventDisconnectPeripheral = {
186
+ peripheral: string;
187
+ status?: number | null;
188
+ domain?: string | null;
189
+ code?: number | null;
190
+ };
191
+ export type EventPeripheralDidBond = {
192
+ id: string;
193
+ name: string;
194
+ rssi: number;
195
+ advertising: {
196
+ isConnectable: boolean;
197
+ serviceUUIDs: string[];
198
+ manufacturerData: number[];
199
+ serviceData: number[];
200
+ txPowerLevel: number;
201
+ rawData?: number | null;
202
+ };
203
+ };
204
+ export type EventCentralManagerWillRestoreState = {
205
+ peripherals: {
206
+ id: string;
207
+ name: string;
208
+ rssi: number;
209
+ advertising: {
210
+ isConnectable: boolean;
211
+ serviceUUIDs: string[];
212
+ manufacturerData: number[];
213
+ serviceData: number[];
214
+ txPowerLevel: number;
215
+ rawData?: number | null;
216
+ };
217
+ }[];
218
+ };
219
+ export type EventDidUpdateNotificationStateFor = {
220
+ peripheral: string;
221
+ characteristic: string;
222
+ isNotifying: boolean;
223
+ domain?: string | null;
224
+ code?: number | null;
225
+ };
226
+ export type EventCompanionPeripheral = {
227
+ id: string;
228
+ name: string;
229
+ rssi: number;
230
+ advertising: {
231
+ isConnectable: boolean;
232
+ serviceUUIDs: string[];
233
+ manufacturerData: number[];
234
+ serviceData: number[];
235
+ txPowerLevel: number;
236
+ rawData?: number | null;
237
+ };
238
+ };
239
+ export type EventCompanionFailure = {
240
+ error: string;
241
+ };
@@ -0,0 +1,3 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+ export default TurboModuleRegistry.get('BleManager');
3
+ //# sourceMappingURL=NativeBleManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeBleManager.js","sourceRoot":"","sources":["../../src/NativeBleManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA8MhE,eAAe,mBAAmB,CAAC,GAAG,CAAO,YAAY,CAAS,CAAC"}
@@ -1,6 +1,6 @@
1
- import { NativeEventEmitter } from "react-native";
2
- import { BleState, ConnectOptions, ConnectionPriority, CompanionScanOptions, Peripheral, PeripheralInfo, ScanOptions, StartOptions } from "./types";
3
- export * from "./types";
1
+ import { EventSubscription, NativeEventEmitter } from 'react-native';
2
+ import { BleState, ConnectOptions, ConnectionPriority, CompanionScanOptions, Peripheral, PeripheralInfo, ScanOptions, StartOptions } from './types';
3
+ export * from './types';
4
4
  declare class BleManager extends NativeEventEmitter {
5
5
  constructor();
6
6
  /**
@@ -207,6 +207,18 @@ declare class BleManager extends NativeEventEmitter {
207
207
  * @returns
208
208
  */
209
209
  getMaximumWriteValueLengthForWithResponse(peripheralId: string): Promise<number>;
210
+ onDiscoverPeripheral(callback: any): EventSubscription;
211
+ onStopScan(callback: any): EventSubscription;
212
+ onDidUpdateState(callback: any): EventSubscription;
213
+ onCentralManagerDidUpdateState(callback: any): EventSubscription;
214
+ onConnectPeripheral(callback: any): EventSubscription;
215
+ onDisconnectPeripheral(callback: any): EventSubscription;
216
+ onDidUpdateValueForCharacteristic(callback: any): EventSubscription;
217
+ onPeripheralDidBond(callback: any): EventSubscription;
218
+ onCentralManagerWillRestoreState(callback: any): EventSubscription;
219
+ onDidUpdateNotificationStateFor(callback: any): EventSubscription;
220
+ onCompanionPeripheral(callback: any): EventSubscription;
221
+ onCompanionAvailability(callback: any): EventSubscription;
210
222
  }
211
223
  declare const _default: BleManager;
212
224
  export default _default;
package/dist/esm/index.js CHANGED
@@ -1,10 +1,25 @@
1
- import { NativeEventEmitter, NativeModules } from "react-native";
2
- import { BleScanCallbackType, BleScanMatchCount, BleScanMatchMode, BleScanMode, } from "./types";
3
- export * from "./types";
4
- let bleManager = NativeModules.BleManager;
1
+ import { NativeEventEmitter, NativeModules, } from 'react-native';
2
+ import { BleScanCallbackType, BleScanMatchCount, BleScanMatchMode, BleScanMode, } from './types';
3
+ export * from './types';
4
+ // @ts-expect-error This applies the turbo module version only when turbo is enabled for backwards compatibility.
5
+ const isTurboModuleEnabled = (global === null || global === void 0 ? void 0 : global.__turboModuleProxy) != null;
6
+ if (isTurboModuleEnabled) {
7
+ // Warn users that this is a release candidate and should be used with caution.
8
+ console.warn(`
9
+ You're using a turbo module version of react-native-version!\n
10
+ If something is broken please feedback on "issues" https://github.com/innoveit/react-native-ble-manager\n
11
+ Please use with caution cause it's not quite stable yet.
12
+ `);
13
+ }
14
+ const BleManagerModule = isTurboModuleEnabled
15
+ ? require('./NativeBleManager').default
16
+ : NativeModules.BleManager;
5
17
  class BleManager extends NativeEventEmitter {
6
18
  constructor() {
7
- super(bleManager);
19
+ if (!BleManagerModule) {
20
+ throw new Error('BleManagerModule not found');
21
+ }
22
+ super(BleManagerModule);
8
23
  this.isPeripheralConnected = this.isPeripheralConnected.bind(this);
9
24
  }
10
25
  /**
@@ -16,7 +31,7 @@ class BleManager extends NativeEventEmitter {
16
31
  */
17
32
  read(peripheralId, serviceUUID, characteristicUUID) {
18
33
  return new Promise((fulfill, reject) => {
19
- bleManager.read(peripheralId, serviceUUID, characteristicUUID, (error, data) => {
34
+ BleManagerModule.read(peripheralId, serviceUUID, characteristicUUID, (error, data) => {
20
35
  if (error) {
21
36
  reject(error);
22
37
  }
@@ -36,7 +51,7 @@ class BleManager extends NativeEventEmitter {
36
51
  */
37
52
  readDescriptor(peripheralId, serviceUUID, characteristicUUID, descriptorUUID) {
38
53
  return new Promise((fulfill, reject) => {
39
- bleManager.readDescriptor(peripheralId, serviceUUID, characteristicUUID, descriptorUUID, (error, data) => {
54
+ BleManagerModule.readDescriptor(peripheralId, serviceUUID, characteristicUUID, descriptorUUID, (error, data) => {
40
55
  if (error) {
41
56
  reject(error);
42
57
  }
@@ -57,7 +72,7 @@ class BleManager extends NativeEventEmitter {
57
72
  */
58
73
  writeDescriptor(peripheralId, serviceUUID, characteristicUUID, descriptorUUID, data) {
59
74
  return new Promise((fulfill, reject) => {
60
- bleManager.writeDescriptor(peripheralId, serviceUUID, characteristicUUID, descriptorUUID, data, (error) => {
75
+ BleManagerModule.writeDescriptor(peripheralId, serviceUUID, characteristicUUID, descriptorUUID, data, (error) => {
61
76
  if (error) {
62
77
  reject(error);
63
78
  }
@@ -74,7 +89,7 @@ class BleManager extends NativeEventEmitter {
74
89
  */
75
90
  readRSSI(peripheralId) {
76
91
  return new Promise((fulfill, reject) => {
77
- bleManager.readRSSI(peripheralId, (error, rssi) => {
92
+ BleManagerModule.readRSSI(peripheralId, (error, rssi) => {
78
93
  if (error) {
79
94
  reject(error);
80
95
  }
@@ -91,7 +106,7 @@ class BleManager extends NativeEventEmitter {
91
106
  */
92
107
  refreshCache(peripheralId) {
93
108
  return new Promise((fulfill, reject) => {
94
- bleManager.refreshCache(peripheralId, (error, result) => {
109
+ BleManagerModule.refreshCache(peripheralId, (error, result) => {
95
110
  if (error) {
96
111
  reject(error);
97
112
  }
@@ -109,7 +124,7 @@ class BleManager extends NativeEventEmitter {
109
124
  */
110
125
  retrieveServices(peripheralId, serviceUUIDs = []) {
111
126
  return new Promise((fulfill, reject) => {
112
- bleManager.retrieveServices(peripheralId, serviceUUIDs, (error, peripheral) => {
127
+ BleManagerModule.retrieveServices(peripheralId, serviceUUIDs, (error, peripheral) => {
113
128
  if (error) {
114
129
  reject(error);
115
130
  }
@@ -130,7 +145,7 @@ class BleManager extends NativeEventEmitter {
130
145
  */
131
146
  write(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize = 20) {
132
147
  return new Promise((fulfill, reject) => {
133
- bleManager.write(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize, (error) => {
148
+ BleManagerModule.write(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize, (error) => {
134
149
  if (error) {
135
150
  reject(error);
136
151
  }
@@ -152,7 +167,7 @@ class BleManager extends NativeEventEmitter {
152
167
  */
153
168
  writeWithoutResponse(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize = 20, queueSleepTime = 10) {
154
169
  return new Promise((fulfill, reject) => {
155
- bleManager.writeWithoutResponse(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize, queueSleepTime, (error) => {
170
+ BleManagerModule.writeWithoutResponse(peripheralId, serviceUUID, characteristicUUID, data, maxByteSize, queueSleepTime, (error) => {
156
171
  if (error) {
157
172
  reject(error);
158
173
  }
@@ -167,7 +182,7 @@ class BleManager extends NativeEventEmitter {
167
182
  if (!options) {
168
183
  options = {};
169
184
  }
170
- bleManager.connect(peripheralId, options, (error) => {
185
+ BleManagerModule.connect(peripheralId, options, (error) => {
171
186
  if (error) {
172
187
  reject(error);
173
188
  }
@@ -185,7 +200,7 @@ class BleManager extends NativeEventEmitter {
185
200
  */
186
201
  createBond(peripheralId, peripheralPin = null) {
187
202
  return new Promise((fulfill, reject) => {
188
- bleManager.createBond(peripheralId, peripheralPin, (error) => {
203
+ BleManagerModule.createBond(peripheralId, peripheralPin, (error) => {
189
204
  if (error) {
190
205
  reject(error);
191
206
  }
@@ -202,7 +217,7 @@ class BleManager extends NativeEventEmitter {
202
217
  */
203
218
  removeBond(peripheralId) {
204
219
  return new Promise((fulfill, reject) => {
205
- bleManager.removeBond(peripheralId, (error) => {
220
+ BleManagerModule.removeBond(peripheralId, (error) => {
206
221
  if (error) {
207
222
  reject(error);
208
223
  }
@@ -220,7 +235,7 @@ class BleManager extends NativeEventEmitter {
220
235
  */
221
236
  disconnect(peripheralId, force = true) {
222
237
  return new Promise((fulfill, reject) => {
223
- bleManager.disconnect(peripheralId, force, (error) => {
238
+ BleManagerModule.disconnect(peripheralId, force, (error) => {
224
239
  if (error) {
225
240
  reject(error);
226
241
  }
@@ -232,7 +247,7 @@ class BleManager extends NativeEventEmitter {
232
247
  }
233
248
  startNotification(peripheralId, serviceUUID, characteristicUUID) {
234
249
  return new Promise((fulfill, reject) => {
235
- bleManager.startNotification(peripheralId, serviceUUID, characteristicUUID, (error) => {
250
+ BleManagerModule.startNotification(peripheralId, serviceUUID, characteristicUUID, (error) => {
236
251
  if (error) {
237
252
  reject(error);
238
253
  }
@@ -252,7 +267,7 @@ class BleManager extends NativeEventEmitter {
252
267
  */
253
268
  startNotificationUseBuffer(peripheralId, serviceUUID, characteristicUUID, buffer) {
254
269
  return new Promise((fulfill, reject) => {
255
- bleManager.startNotificationUseBuffer(peripheralId, serviceUUID, characteristicUUID, buffer, (error) => {
270
+ BleManagerModule.startNotificationUseBuffer(peripheralId, serviceUUID, characteristicUUID, buffer, (error) => {
256
271
  if (error) {
257
272
  reject(error);
258
273
  }
@@ -264,7 +279,7 @@ class BleManager extends NativeEventEmitter {
264
279
  }
265
280
  stopNotification(peripheralId, serviceUUID, characteristicUUID) {
266
281
  return new Promise((fulfill, reject) => {
267
- bleManager.stopNotification(peripheralId, serviceUUID, characteristicUUID, (error) => {
282
+ BleManagerModule.stopNotification(peripheralId, serviceUUID, characteristicUUID, (error) => {
268
283
  if (error) {
269
284
  reject(error);
270
285
  }
@@ -276,7 +291,7 @@ class BleManager extends NativeEventEmitter {
276
291
  }
277
292
  checkState() {
278
293
  return new Promise((fulfill, _) => {
279
- bleManager.checkState((state) => {
294
+ BleManagerModule.checkState((state) => {
280
295
  fulfill(state);
281
296
  });
282
297
  });
@@ -286,7 +301,7 @@ class BleManager extends NativeEventEmitter {
286
301
  if (options == null) {
287
302
  options = {};
288
303
  }
289
- bleManager.start(options, (error) => {
304
+ BleManagerModule.start(options, (error) => {
290
305
  if (error) {
291
306
  reject(error);
292
307
  }
@@ -339,13 +354,13 @@ class BleManager extends NativeEventEmitter {
339
354
  delete scanningOptions.exactAdvertisingName;
340
355
  }
341
356
  else {
342
- if (typeof scanningOptions.exactAdvertisingName === "string") {
357
+ if (typeof scanningOptions.exactAdvertisingName === 'string') {
343
358
  scanningOptions.exactAdvertisingName = [
344
359
  scanningOptions.exactAdvertisingName,
345
360
  ];
346
361
  }
347
362
  }
348
- bleManager.scan(serviceUUIDs, seconds, allowDuplicates, scanningOptions, (error) => {
363
+ BleManagerModule.scan(serviceUUIDs, seconds, allowDuplicates, scanningOptions, (error) => {
349
364
  if (error) {
350
365
  reject(error);
351
366
  }
@@ -357,7 +372,7 @@ class BleManager extends NativeEventEmitter {
357
372
  }
358
373
  stopScan() {
359
374
  return new Promise((fulfill, reject) => {
360
- bleManager.stopScan((error) => {
375
+ BleManagerModule.stopScan((error) => {
361
376
  if (error) {
362
377
  reject(error);
363
378
  }
@@ -373,7 +388,7 @@ class BleManager extends NativeEventEmitter {
373
388
  */
374
389
  enableBluetooth() {
375
390
  return new Promise((fulfill, reject) => {
376
- bleManager.enableBluetooth((error) => {
391
+ BleManagerModule.enableBluetooth((error) => {
377
392
  if (error) {
378
393
  reject(error);
379
394
  }
@@ -390,7 +405,7 @@ class BleManager extends NativeEventEmitter {
390
405
  */
391
406
  getConnectedPeripherals(serviceUUIDs = []) {
392
407
  return new Promise((fulfill, reject) => {
393
- bleManager.getConnectedPeripherals(serviceUUIDs, (error, result) => {
408
+ BleManagerModule.getConnectedPeripherals(serviceUUIDs, (error, result) => {
394
409
  if (error) {
395
410
  reject(error);
396
411
  }
@@ -411,7 +426,7 @@ class BleManager extends NativeEventEmitter {
411
426
  */
412
427
  getBondedPeripherals() {
413
428
  return new Promise((fulfill, reject) => {
414
- bleManager.getBondedPeripherals((error, result) => {
429
+ BleManagerModule.getBondedPeripherals((error, result) => {
415
430
  if (error) {
416
431
  reject(error);
417
432
  }
@@ -428,7 +443,7 @@ class BleManager extends NativeEventEmitter {
428
443
  }
429
444
  getDiscoveredPeripherals() {
430
445
  return new Promise((fulfill, reject) => {
431
- bleManager.getDiscoveredPeripherals((error, result) => {
446
+ BleManagerModule.getDiscoveredPeripherals((error, result) => {
432
447
  if (error) {
433
448
  reject(error);
434
449
  }
@@ -450,7 +465,7 @@ class BleManager extends NativeEventEmitter {
450
465
  */
451
466
  removePeripheral(peripheralId) {
452
467
  return new Promise((fulfill, reject) => {
453
- bleManager.removePeripheral(peripheralId, (error) => {
468
+ BleManagerModule.removePeripheral(peripheralId, (error) => {
454
469
  if (error) {
455
470
  reject(error);
456
471
  }
@@ -482,7 +497,7 @@ class BleManager extends NativeEventEmitter {
482
497
  */
483
498
  isScanning() {
484
499
  return new Promise((fulfill, reject) => {
485
- bleManager.isScanning((error, status) => {
500
+ BleManagerModule.isScanning((error, status) => {
486
501
  if (error) {
487
502
  reject(error);
488
503
  }
@@ -500,7 +515,7 @@ class BleManager extends NativeEventEmitter {
500
515
  */
501
516
  requestConnectionPriority(peripheralId, connectionPriority) {
502
517
  return new Promise((fulfill, reject) => {
503
- bleManager.requestConnectionPriority(peripheralId, connectionPriority, (error, status) => {
518
+ BleManagerModule.requestConnectionPriority(peripheralId, connectionPriority, (error, status) => {
504
519
  if (error) {
505
520
  reject(error);
506
521
  }
@@ -518,7 +533,7 @@ class BleManager extends NativeEventEmitter {
518
533
  */
519
534
  requestMTU(peripheralId, mtu) {
520
535
  return new Promise((fulfill, reject) => {
521
- bleManager.requestMTU(peripheralId, mtu, (error, mtu) => {
536
+ BleManagerModule.requestMTU(peripheralId, mtu, (error, mtu) => {
522
537
  if (error) {
523
538
  reject(error);
524
539
  }
@@ -535,7 +550,7 @@ class BleManager extends NativeEventEmitter {
535
550
  */
536
551
  getAssociatedPeripherals() {
537
552
  return new Promise((fulfill, reject) => {
538
- bleManager.getAssociatedPeripherals((error, peripherals) => {
553
+ BleManagerModule.getAssociatedPeripherals((error, peripherals) => {
539
554
  if (error) {
540
555
  reject(error);
541
556
  }
@@ -553,7 +568,7 @@ class BleManager extends NativeEventEmitter {
553
568
  */
554
569
  removeAssociatedPeripheral(peripheralId) {
555
570
  return new Promise((fulfill, reject) => {
556
- bleManager.removeAssociatedPeripheral(peripheralId, (error) => {
571
+ BleManagerModule.removeAssociatedPeripheral(peripheralId, (error) => {
557
572
  if (error !== null) {
558
573
  reject(error);
559
574
  }
@@ -571,8 +586,8 @@ class BleManager extends NativeEventEmitter {
571
586
  * @return Promise resolving to a boolean.
572
587
  */
573
588
  supportsCompanion() {
574
- return new Promise(fulfill => {
575
- bleManager.supportsCompanion((supports) => fulfill(supports));
589
+ return new Promise((fulfill) => {
590
+ BleManagerModule.supportsCompanion((supports) => fulfill(supports));
576
591
  });
577
592
  }
578
593
  /**
@@ -582,7 +597,7 @@ class BleManager extends NativeEventEmitter {
582
597
  */
583
598
  companionScan(serviceUUIDs, options = {}) {
584
599
  return new Promise((fulfill, reject) => {
585
- bleManager.companionScan(serviceUUIDs, options, (error, peripheral) => {
600
+ BleManagerModule.companionScan(serviceUUIDs, options, (error, peripheral) => {
586
601
  if (error) {
587
602
  reject(error);
588
603
  }
@@ -597,7 +612,7 @@ class BleManager extends NativeEventEmitter {
597
612
  * @param name
598
613
  */
599
614
  setName(name) {
600
- bleManager.setName(name);
615
+ BleManagerModule.setName(name);
601
616
  }
602
617
  /**
603
618
  * [iOS only]
@@ -606,7 +621,7 @@ class BleManager extends NativeEventEmitter {
606
621
  */
607
622
  getMaximumWriteValueLengthForWithoutResponse(peripheralId) {
608
623
  return new Promise((fulfill, reject) => {
609
- bleManager.getMaximumWriteValueLengthForWithoutResponse(peripheralId, (error, max) => {
624
+ BleManagerModule.getMaximumWriteValueLengthForWithoutResponse(peripheralId, (error, max) => {
610
625
  if (error) {
611
626
  reject(error);
612
627
  }
@@ -623,7 +638,7 @@ class BleManager extends NativeEventEmitter {
623
638
  */
624
639
  getMaximumWriteValueLengthForWithResponse(peripheralId) {
625
640
  return new Promise((fulfill, reject) => {
626
- bleManager.getMaximumWriteValueLengthForWithResponse(peripheralId, (error, max) => {
641
+ BleManagerModule.getMaximumWriteValueLengthForWithResponse(peripheralId, (error, max) => {
627
642
  if (error) {
628
643
  reject(error);
629
644
  }
@@ -633,6 +648,42 @@ class BleManager extends NativeEventEmitter {
633
648
  });
634
649
  });
635
650
  }
651
+ onDiscoverPeripheral(callback) {
652
+ return BleManagerModule.onDiscoverPeripheral(callback);
653
+ }
654
+ onStopScan(callback) {
655
+ return BleManagerModule.onStopScan(callback);
656
+ }
657
+ onDidUpdateState(callback) {
658
+ return BleManagerModule.onStateChange(callback);
659
+ }
660
+ onCentralManagerDidUpdateState(callback) {
661
+ return BleManagerModule.onCentralManagerDidUpdateState(callback);
662
+ }
663
+ onConnectPeripheral(callback) {
664
+ return BleManagerModule.onConnectPeripheral(callback);
665
+ }
666
+ onDisconnectPeripheral(callback) {
667
+ return BleManagerModule.onDisconnectPeripheral(callback);
668
+ }
669
+ onDidUpdateValueForCharacteristic(callback) {
670
+ return BleManagerModule.onDidUpdateValueForCharacteristic(callback);
671
+ }
672
+ onPeripheralDidBond(callback) {
673
+ return BleManagerModule.onPeripheralDidBond(callback);
674
+ }
675
+ onCentralManagerWillRestoreState(callback) {
676
+ return BleManagerModule.onCentralManagerWillRestoreState(callback);
677
+ }
678
+ onDidUpdateNotificationStateFor(callback) {
679
+ return BleManagerModule.onDidUpdateNotificationStateFor(callback);
680
+ }
681
+ onCompanionPeripheral(callback) {
682
+ return BleManagerModule.onCompanionPeripheral(callback);
683
+ }
684
+ onCompanionAvailability(callback) {
685
+ return BleManagerModule.onCompanionAvailability(callback);
686
+ }
636
687
  }
637
688
  export default new BleManager();
638
689
  //# sourceMappingURL=index.js.map