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.
- package/README.md +131 -44
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.name +1 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +18 -0
- package/android/.idea/jarRepositories.xml +40 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +17 -17
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +3 -1
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -0
- package/android/local.properties +8 -0
- package/android/src/main/java/it/innove/BleManager.java +38 -17
- package/android/src/main/java/it/innove/LegacyScanManager.java +33 -28
- package/android/src/main/java/it/innove/LollipopPeripheral.java +66 -65
- package/android/src/main/java/it/innove/LollipopScanManager.java +52 -25
- package/android/src/main/java/it/innove/Peripheral.java +973 -838
- package/android/src/main/java/it/innove/ScanManager.java +24 -23
- package/dist/cjs/index.d.ts +156 -0
- package/dist/cjs/index.js +507 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.d.ts +311 -0
- package/dist/cjs/types.js +110 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/index.d.ts +156 -0
- package/dist/esm/index.js +491 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +311 -0
- package/dist/esm/types.js +107 -0
- package/dist/esm/types.js.map +1 -0
- package/ios/BleManager.h +1 -0
- package/ios/BleManager.m +213 -115
- package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/BleManager.xcodeproj/project.xcworkspace/xcuserdata/marco.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/BleManager.xcodeproj/xcuserdata/marco.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/CBPeripheral+Extensions.m +1 -1
- package/package.json +31 -4
- package/src/index.ts +595 -0
- package/src/types.ts +336 -0
- package/.github/FUNDING.yml +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/BleManager.js +0 -427
- package/index.d.ts +0 -294
|
@@ -3,6 +3,7 @@ package it.innove;
|
|
|
3
3
|
|
|
4
4
|
import android.bluetooth.BluetoothAdapter;
|
|
5
5
|
import android.content.Context;
|
|
6
|
+
|
|
6
7
|
import com.facebook.react.bridge.Callback;
|
|
7
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
9
|
import com.facebook.react.bridge.ReactContext;
|
|
@@ -13,27 +14,27 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
13
14
|
|
|
14
15
|
public abstract class ScanManager {
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
protected BluetoothAdapter bluetoothAdapter;
|
|
18
|
+
protected Context context;
|
|
19
|
+
protected ReactContext reactContext;
|
|
20
|
+
protected BleManager bleManager;
|
|
21
|
+
protected AtomicInteger scanSessionId = new AtomicInteger();
|
|
22
|
+
|
|
23
|
+
public ScanManager(ReactApplicationContext reactContext, BleManager bleManager) {
|
|
24
|
+
context = reactContext;
|
|
25
|
+
this.reactContext = reactContext;
|
|
26
|
+
this.bleManager = bleManager;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
protected BluetoothAdapter getBluetoothAdapter() {
|
|
30
|
+
if (bluetoothAdapter == null) {
|
|
31
|
+
android.bluetooth.BluetoothManager manager = (android.bluetooth.BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
|
|
32
|
+
bluetoothAdapter = manager.getAdapter();
|
|
33
|
+
}
|
|
34
|
+
return bluetoothAdapter;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public abstract void stopScan(Callback callback);
|
|
38
|
+
|
|
39
|
+
public abstract void scan(ReadableArray serviceUUIDs, final int scanSeconds, ReadableMap options, Callback callback);
|
|
39
40
|
}
|
|
@@ -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;
|