react-native-ble-manager 11.5.7 → 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.
- package/README.md +16 -3
- package/RNBleManager.podspec +24 -0
- package/android/build.gradle +116 -43
- package/android/gradle.properties +1 -0
- package/android/src/main/java/it/innove/BleManager.java +174 -148
- package/android/src/main/java/it/innove/BleManagerPackage.java +15 -14
- package/android/src/main/java/it/innove/CompanionScanner.java +13 -3
- package/android/src/main/java/it/innove/DefaultPeripheral.java +4 -4
- package/android/src/main/java/it/innove/DefaultScanManager.java +16 -16
- package/android/src/main/java/it/innove/Peripheral.java +20 -17
- package/dist/cjs/NativeBleManager.d.ts +241 -0
- package/dist/cjs/NativeBleManager.js +5 -0
- package/dist/cjs/NativeBleManager.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -3
- package/dist/cjs/index.js +89 -38
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types.d.ts +11 -11
- package/dist/esm/NativeBleManager.d.ts +241 -0
- package/dist/esm/NativeBleManager.js +3 -0
- package/dist/esm/NativeBleManager.js.map +1 -0
- package/dist/esm/index.d.ts +15 -3
- package/dist/esm/index.js +92 -41
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +11 -11
- package/ios/BleManager-Bridging-Header.h +7 -1
- package/ios/BleManager.h +39 -2
- package/ios/BleManager.mm +277 -0
- package/ios/Helper.swift +6 -6
- package/ios/RNBleManager.h +7 -0
- package/ios/{BleManager.swift → SwiftBleManager.swift} +322 -355
- package/package.json +107 -56
- package/src/NativeBleManager.ts +409 -0
- package/src/index.ts +162 -77
- package/src/types.ts +31 -31
- package/android/src/main/java/it/innove/LegacyScanManager.java +0 -112
- package/ios/BleManager.m +0 -153
- package/ios/BleManager.xcodeproj/project.pbxproj +0 -324
- package/ios/BleManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/react-native-ble-manager.podspec +0 -17
|
@@ -132,20 +132,20 @@ public class DefaultScanManager extends ScanManager {
|
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
Log.d(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
BleManager.LOG_TAG,
|
|
136
|
+
String.format(
|
|
137
|
+
"Filter on manufacturerId: %d; manufacturerData: %s; manufacturerDataMask: %s",
|
|
138
|
+
manufacturerId,
|
|
139
|
+
Arrays.toString(manufacturerDataBytes),
|
|
140
|
+
Arrays.toString(manufacturerDataMaskBytes)
|
|
141
|
+
)
|
|
142
142
|
);
|
|
143
143
|
ScanFilter filter = new ScanFilter.Builder()
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
.setManufacturerData(
|
|
145
|
+
manufacturerId,
|
|
146
|
+
manufacturerDataBytes,
|
|
147
|
+
manufacturerDataMaskBytes
|
|
148
|
+
).build();
|
|
149
149
|
filters.add(filter);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -179,7 +179,7 @@ public class DefaultScanManager extends ScanManager {
|
|
|
179
179
|
|
|
180
180
|
WritableMap map = Arguments.createMap();
|
|
181
181
|
map.putInt("status", 10);
|
|
182
|
-
bleManager.
|
|
182
|
+
bleManager.emitOnStopScan(map);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
});
|
|
@@ -208,7 +208,7 @@ public class DefaultScanManager extends ScanManager {
|
|
|
208
208
|
|
|
209
209
|
DefaultPeripheral peripheral = (DefaultPeripheral) bleManager.getPeripheral(result.getDevice());
|
|
210
210
|
if (peripheral == null) {
|
|
211
|
-
peripheral = new DefaultPeripheral(bleManager
|
|
211
|
+
peripheral = new DefaultPeripheral(bleManager, result);
|
|
212
212
|
} else {
|
|
213
213
|
peripheral.updateData(result);
|
|
214
214
|
peripheral.updateRssi(result.getRssi());
|
|
@@ -216,7 +216,7 @@ public class DefaultScanManager extends ScanManager {
|
|
|
216
216
|
bleManager.savePeripheral(peripheral);
|
|
217
217
|
|
|
218
218
|
WritableMap map = peripheral.asWritableMap();
|
|
219
|
-
bleManager.
|
|
219
|
+
bleManager.emitOnDiscoverPeripheral(map);
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
private final ScanCallback mScanCallback = new ScanCallback() {
|
|
@@ -251,7 +251,7 @@ public class DefaultScanManager extends ScanManager {
|
|
|
251
251
|
isScanning = false;
|
|
252
252
|
WritableMap map = Arguments.createMap();
|
|
253
253
|
map.putInt("status", errorCode);
|
|
254
|
-
bleManager.
|
|
254
|
+
bleManager.emitOnStopScan(map);
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
|
|
@@ -60,7 +60,7 @@ public class Peripheral extends BluetoothGattCallback {
|
|
|
60
60
|
protected volatile int advertisingRSSI;
|
|
61
61
|
private volatile boolean connected = false;
|
|
62
62
|
private volatile boolean connecting = false;
|
|
63
|
-
private
|
|
63
|
+
private BleManager bleManager;
|
|
64
64
|
|
|
65
65
|
private BluetoothGatt gatt;
|
|
66
66
|
|
|
@@ -81,34 +81,38 @@ public class Peripheral extends BluetoothGattCallback {
|
|
|
81
81
|
|
|
82
82
|
private List<byte[]> writeQueue = new ArrayList<>();
|
|
83
83
|
|
|
84
|
-
public Peripheral(BluetoothDevice device, int advertisingRSSI, byte[] scanRecord,
|
|
84
|
+
public Peripheral(BluetoothDevice device, int advertisingRSSI, byte[] scanRecord, BleManager bleManager) {
|
|
85
85
|
this.device = device;
|
|
86
86
|
this.bufferedCharacteristics = new ConcurrentHashMap<String, NotifyBufferContainer>();
|
|
87
87
|
this.advertisingRSSI = advertisingRSSI;
|
|
88
88
|
this.advertisingDataBytes = scanRecord;
|
|
89
|
-
this.
|
|
89
|
+
this.bleManager = bleManager;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
public Peripheral(BluetoothDevice device,
|
|
92
|
+
public Peripheral(BluetoothDevice device, BleManager bleManager) {
|
|
93
93
|
this.device = device;
|
|
94
94
|
this.bufferedCharacteristics = new ConcurrentHashMap<String, NotifyBufferContainer>();
|
|
95
|
-
this.
|
|
95
|
+
this.bleManager = bleManager;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
private void
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
private void sendConnectionEvent(BluetoothDevice device, int status) {
|
|
99
|
+
WritableMap map = Arguments.createMap();
|
|
100
|
+
map.putString("peripheral", device.getAddress());
|
|
101
|
+
if (status != -1) {
|
|
102
|
+
map.putInt("status", status);
|
|
101
103
|
}
|
|
104
|
+
bleManager.emitOnConnectPeripheral(map);
|
|
105
|
+
Log.d(BleManager.LOG_TAG, "Peripheral connected:" + device.getAddress());
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
private void
|
|
108
|
+
private void sendDisconnectionEvent(BluetoothDevice device, int status) {
|
|
105
109
|
WritableMap map = Arguments.createMap();
|
|
106
110
|
map.putString("peripheral", device.getAddress());
|
|
107
111
|
if (status != -1) {
|
|
108
112
|
map.putInt("status", status);
|
|
109
113
|
}
|
|
110
|
-
|
|
111
|
-
Log.d(BleManager.LOG_TAG, "Peripheral
|
|
114
|
+
bleManager.emitOnDisconnectPeripheral(map);
|
|
115
|
+
Log.d(BleManager.LOG_TAG, "Peripheral disconnected:" + device.getAddress());
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
public void connect(final Callback callback, Activity activity, ReadableMap options) {
|
|
@@ -172,11 +176,11 @@ public class Peripheral extends BluetoothGattCallback {
|
|
|
172
176
|
if (force) {
|
|
173
177
|
gatt.close();
|
|
174
178
|
gatt = null;
|
|
175
|
-
|
|
179
|
+
sendDisconnectionEvent(device, BluetoothGatt.GATT_SUCCESS);
|
|
176
180
|
}
|
|
177
181
|
Log.d(BleManager.LOG_TAG, "Disconnect");
|
|
178
182
|
} catch (Exception e) {
|
|
179
|
-
|
|
183
|
+
sendDisconnectionEvent(device, BluetoothGatt.GATT_FAILURE);
|
|
180
184
|
Log.d(BleManager.LOG_TAG, "Error on disconnect", e);
|
|
181
185
|
}
|
|
182
186
|
} else
|
|
@@ -335,7 +339,7 @@ public class Peripheral extends BluetoothGattCallback {
|
|
|
335
339
|
|
|
336
340
|
mainHandler.post(discoverServicesRunnable);
|
|
337
341
|
|
|
338
|
-
sendConnectionEvent(device,
|
|
342
|
+
sendConnectionEvent(device, status);
|
|
339
343
|
|
|
340
344
|
Log.d(BleManager.LOG_TAG, "Connected to: " + device.getAddress());
|
|
341
345
|
for (Callback connectCallback : connectCallbacks) {
|
|
@@ -406,8 +410,7 @@ public class Peripheral extends BluetoothGattCallback {
|
|
|
406
410
|
gatt.disconnect();
|
|
407
411
|
gatt.close();
|
|
408
412
|
gatt = null;
|
|
409
|
-
|
|
410
|
-
|
|
413
|
+
sendDisconnectionEvent(device, BluetoothGatt.GATT_SUCCESS);
|
|
411
414
|
}
|
|
412
415
|
|
|
413
416
|
});
|
|
@@ -464,7 +467,7 @@ public class Peripheral extends BluetoothGattCallback {
|
|
|
464
467
|
map.putString("characteristic", charString);
|
|
465
468
|
map.putString("service", service);
|
|
466
469
|
map.putArray("value", BleManager.bytesToWritableArray(dataValue));
|
|
467
|
-
|
|
470
|
+
bleManager.emitOnDidUpdateNotificationStateFor(map);
|
|
468
471
|
|
|
469
472
|
// Check if rest exists. If so it needs to be added to the clean buffer
|
|
470
473
|
dataValue = rest;
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"NativeBleManager.js","sourceRoot":"","sources":["../../src/NativeBleManager.ts"],"names":[],"mappings":";;AAAA,+CAAgE;AA8MhE,kBAAe,kCAAmB,CAAC,GAAG,CAAO,YAAY,CAAS,CAAC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NativeEventEmitter } from
|
|
2
|
-
import { BleState, ConnectOptions, ConnectionPriority, CompanionScanOptions, Peripheral, PeripheralInfo, ScanOptions, StartOptions } from
|
|
3
|
-
export * from
|
|
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;
|