react-native-ble-nitro 1.0.0 → 1.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 +19 -15
- package/ios/BleNitroBleManager.swift +77 -43
- package/lib/commonjs/index.d.ts +15 -13
- package/lib/commonjs/index.d.ts.map +1 -1
- package/lib/commonjs/index.js +76 -139
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +13 -10
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
- package/lib/index.d.ts +15 -13
- package/lib/index.js +75 -138
- package/lib/specs/NativeBleNitro.nitro.d.ts +13 -10
- package/nitrogen/generated/android/BleNitroOnLoad.cpp +2 -8
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +90 -49
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +9 -10
- package/nitrogen/generated/android/c++/JOperationResult.hpp +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +11 -60
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/OperationResult.kt +32 -0
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +5 -29
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +69 -78
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +39 -24
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +9 -10
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +60 -112
- package/nitrogen/generated/ios/swift/OperationResult.swift +64 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +13 -11
- package/nitrogen/generated/shared/c++/OperationResult.hpp +72 -0
- package/package.json +1 -1
- package/src/__tests__/index.test.ts +19 -22
- package/src/index.ts +100 -156
- package/src/specs/NativeBleNitro.nitro.ts +14 -10
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +0 -74
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_BLEDevice_.hpp +0 -99
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +0 -93
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool.kt +0 -81
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_BLEDevice_.kt +0 -81
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_std__string_.kt +0 -81
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__vector_BLEDevice_.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +0 -47
package/README.md
CHANGED
|
@@ -83,22 +83,22 @@ const ble = BleNitro.instance();
|
|
|
83
83
|
|
|
84
84
|
```typescript
|
|
85
85
|
// Check if Bluetooth is enabled
|
|
86
|
-
const isEnabled =
|
|
86
|
+
const isEnabled = ble.isBluetoothEnabled();
|
|
87
87
|
|
|
88
88
|
// Get current Bluetooth state
|
|
89
|
-
const state =
|
|
89
|
+
const state = ble.state();
|
|
90
90
|
// Returns: BLEState.PoweredOn, BLEState.PoweredOff, etc.
|
|
91
91
|
|
|
92
92
|
// Request to enable Bluetooth (Android only)
|
|
93
93
|
await ble.requestBluetoothEnable();
|
|
94
94
|
|
|
95
95
|
// Subscribe to state changes
|
|
96
|
-
const subscription =
|
|
96
|
+
const subscription = ble.subscribeToStateChange((state) => {
|
|
97
97
|
console.log('Bluetooth state changed:', state);
|
|
98
98
|
}, true); // true = emit initial state
|
|
99
99
|
|
|
100
100
|
// Unsubscribe from state changes
|
|
101
|
-
|
|
101
|
+
subscription.remove();
|
|
102
102
|
|
|
103
103
|
// Open Bluetooth settings
|
|
104
104
|
await ble.openSettings();
|
|
@@ -108,7 +108,7 @@ await ble.openSettings();
|
|
|
108
108
|
|
|
109
109
|
```typescript
|
|
110
110
|
// Start scanning for devices
|
|
111
|
-
|
|
111
|
+
ble.startScan({
|
|
112
112
|
serviceUUIDs: ['180d'], // Optional: filter by service UUIDs
|
|
113
113
|
rssiThreshold: -80, // Optional: minimum signal strength
|
|
114
114
|
allowDuplicates: false // Optional: allow duplicate discoveries
|
|
@@ -117,13 +117,13 @@ await ble.startScan({
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
// Stop scanning
|
|
120
|
-
|
|
120
|
+
ble.stopScan();
|
|
121
121
|
|
|
122
122
|
// Check if currently scanning
|
|
123
|
-
const isScanning =
|
|
123
|
+
const isScanning = ble.isScanning();
|
|
124
124
|
|
|
125
125
|
// Get already connected devices
|
|
126
|
-
const connectedDevices =
|
|
126
|
+
const connectedDevices = ble.getConnectedDevices(['180d']); // Optional: filter by service UUIDs
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
#### 🔗 Device Connection
|
|
@@ -147,7 +147,7 @@ const deviceId = await ble.connect(deviceId);
|
|
|
147
147
|
await ble.disconnect(deviceId);
|
|
148
148
|
|
|
149
149
|
// Check connection status
|
|
150
|
-
const isConnected =
|
|
150
|
+
const isConnected = ble.isConnected(deviceId);
|
|
151
151
|
```
|
|
152
152
|
|
|
153
153
|
#### 🔧 Service Discovery
|
|
@@ -162,13 +162,13 @@ const services = await ble.getServices(deviceId);
|
|
|
162
162
|
// Always returns full 128-bit UUIDs
|
|
163
163
|
|
|
164
164
|
// Get characteristics for a service
|
|
165
|
-
const characteristics =
|
|
165
|
+
const characteristics = ble.getCharacteristics(deviceId, serviceUUID);
|
|
166
166
|
// Returns: ['00002a37-0000-1000-8000-00805f9b34fb', '00002a38-0000-1000-8000-00805f9b34fb', ...]
|
|
167
167
|
// Always returns full 128-bit UUIDs
|
|
168
168
|
|
|
169
169
|
// Note: You can use either short or long form UUIDs as input:
|
|
170
|
-
const characteristics1 =
|
|
171
|
-
const characteristics2 =
|
|
170
|
+
const characteristics1 = ble.getCharacteristics(deviceId, '180d'); // Short form
|
|
171
|
+
const characteristics2 = ble.getCharacteristics(deviceId, '0000180d-0000-1000-8000-00805f9b34fb'); // Long form
|
|
172
172
|
// Both work identically - conversion handled automatically
|
|
173
173
|
```
|
|
174
174
|
|
|
@@ -211,7 +211,7 @@ await ble.writeCharacteristic(
|
|
|
211
211
|
|
|
212
212
|
```typescript
|
|
213
213
|
// Subscribe to characteristic notifications
|
|
214
|
-
const subscription =
|
|
214
|
+
const subscription = ble.subscribeToCharacteristic(
|
|
215
215
|
deviceId,
|
|
216
216
|
serviceUUID,
|
|
217
217
|
characteristicUUID,
|
|
@@ -222,7 +222,7 @@ const subscription = await ble.subscribeToCharacteristic(
|
|
|
222
222
|
);
|
|
223
223
|
|
|
224
224
|
// Unsubscribe from notifications
|
|
225
|
-
|
|
225
|
+
subscription.remove();
|
|
226
226
|
|
|
227
227
|
// Or unsubscribe directly
|
|
228
228
|
await ble.unsubscribeFromCharacteristic(deviceId, serviceUUID, characteristicUUID);
|
|
@@ -240,7 +240,7 @@ const HEART_RATE_MEASUREMENT = '2a37';
|
|
|
240
240
|
const deviceId = await ble.connect(heartRateDeviceId);
|
|
241
241
|
await ble.discoverServices(deviceId);
|
|
242
242
|
|
|
243
|
-
const subscription =
|
|
243
|
+
const subscription = ble.subscribeToCharacteristic(
|
|
244
244
|
deviceId,
|
|
245
245
|
HEART_RATE_SERVICE,
|
|
246
246
|
HEART_RATE_MEASUREMENT,
|
|
@@ -249,6 +249,9 @@ const subscription = await ble.subscribeToCharacteristic(
|
|
|
249
249
|
console.log('Heart rate:', heartRate, 'BPM');
|
|
250
250
|
}
|
|
251
251
|
);
|
|
252
|
+
|
|
253
|
+
// Unsubscribe when done
|
|
254
|
+
subscription.remove();
|
|
252
255
|
```
|
|
253
256
|
|
|
254
257
|
#### Battery Level Reading
|
|
@@ -482,6 +485,7 @@ MIT License - see [LICENSE](./LICENSE) file.
|
|
|
482
485
|
- [Marc Rousavy](https://github.com/mrousavy) - Creator of Nitro Modules and CEO of Margelo
|
|
483
486
|
- [Nitro Modules](https://nitro.margelo.com/) - High-performance native module framework
|
|
484
487
|
- [Margelo](https://margelo.com/) - Nitro Modules creators
|
|
488
|
+
- [Alvinotuya84](https://github.com/Alvinotuya84) - For the API inspiration I took from his repo [react-native-bluetooth-nitro-nexus](https://github.com/Alvinotuya84/react-native-bluetooth-nitro-nexus)
|
|
485
489
|
|
|
486
490
|
## 📞 Support
|
|
487
491
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import CoreBluetooth
|
|
3
3
|
import NitroModules
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* iOS implementation of the BLE Nitro Manager
|
|
7
6
|
* Implements the HybridNativeBleNitroSpec protocol for Core Bluetooth operations
|
|
@@ -19,7 +18,7 @@ public class BleNitroBleManager: HybridNativeBleNitroSpec {
|
|
|
19
18
|
private var isCurrentlyScanning = false
|
|
20
19
|
private var currentScanFilter: ScanFilter?
|
|
21
20
|
private var centralManagerDelegate: BleCentralManagerDelegate!
|
|
22
|
-
|
|
21
|
+
|
|
23
22
|
// MARK: - Initialization
|
|
24
23
|
public override init() {
|
|
25
24
|
super.init()
|
|
@@ -32,39 +31,27 @@ public class BleNitroBleManager: HybridNativeBleNitroSpec {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
// MARK: - State Management
|
|
35
|
-
public func state(
|
|
34
|
+
public func state() throws -> BLEState {
|
|
36
35
|
let bleState = mapCBManagerStateToBLEState(centralManager.state)
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public func isBluetoothEnabled(callback: @escaping (Bool) -> Void) throws {
|
|
41
|
-
let isEnabled = centralManager.state == .poweredOn
|
|
42
|
-
callback(isEnabled)
|
|
36
|
+
return bleState
|
|
43
37
|
}
|
|
44
38
|
|
|
45
39
|
public func requestBluetoothEnable(callback: @escaping (Bool, String) -> Void) throws {
|
|
46
40
|
// iOS doesn't allow programmatic Bluetooth enabling
|
|
47
41
|
// We can only check the current state
|
|
48
|
-
|
|
49
|
-
callback(true, "")
|
|
50
|
-
} else {
|
|
51
|
-
callback(false, "Bluetooth must be enabled manually in Settings")
|
|
52
|
-
}
|
|
42
|
+
callback(false, "Not supported")
|
|
53
43
|
}
|
|
54
44
|
|
|
55
45
|
public func subscribeToStateChange(
|
|
56
|
-
stateCallback: @escaping (BLEState) -> Void
|
|
57
|
-
|
|
58
|
-
) throws {
|
|
46
|
+
stateCallback: @escaping (BLEState) -> Void
|
|
47
|
+
) throws -> OperationResult {
|
|
59
48
|
self.stateChangeCallback = stateCallback
|
|
60
|
-
|
|
49
|
+
return OperationResult(success: true, error: nil)
|
|
61
50
|
}
|
|
62
51
|
|
|
63
|
-
public func unsubscribeFromStateChange(
|
|
64
|
-
resultCallback: @escaping (Bool, String) -> Void
|
|
65
|
-
) throws {
|
|
52
|
+
public func unsubscribeFromStateChange() throws -> OperationResult {
|
|
66
53
|
self.stateChangeCallback = nil
|
|
67
|
-
|
|
54
|
+
return OperationResult(success: true, error: nil)
|
|
68
55
|
}
|
|
69
56
|
|
|
70
57
|
// MARK: - Scanning Operations
|
|
@@ -91,25 +78,25 @@ public class BleNitroBleManager: HybridNativeBleNitroSpec {
|
|
|
91
78
|
centralManager.scanForPeripherals(withServices: serviceUUIDs, options: options)
|
|
92
79
|
}
|
|
93
80
|
|
|
94
|
-
public func stopScan(
|
|
81
|
+
public func stopScan() throws -> Bool {
|
|
95
82
|
centralManager.stopScan()
|
|
96
83
|
isCurrentlyScanning = false
|
|
97
84
|
scanCallback = nil
|
|
98
85
|
currentScanFilter = nil
|
|
99
86
|
// Keep discovered peripherals for potential connections
|
|
100
|
-
|
|
87
|
+
return true
|
|
101
88
|
}
|
|
102
89
|
|
|
103
|
-
public func isScanning(
|
|
104
|
-
|
|
90
|
+
public func isScanning() throws -> Bool {
|
|
91
|
+
return isCurrentlyScanning
|
|
105
92
|
}
|
|
106
93
|
|
|
107
94
|
// MARK: - Device Discovery
|
|
108
|
-
public func getConnectedDevices(
|
|
95
|
+
public func getConnectedDevices(services: [String]) throws -> [BLEDevice] {
|
|
109
96
|
var connectedDevices: [BLEDevice] = []
|
|
110
97
|
|
|
98
|
+
// First check our tracked connected peripherals
|
|
111
99
|
for (deviceId, peripheral) in connectedPeripherals {
|
|
112
|
-
// Create BLEDevice from connected peripheral
|
|
113
100
|
let device = BLEDevice(
|
|
114
101
|
id: deviceId,
|
|
115
102
|
name: peripheral.name ?? "Unknown Device",
|
|
@@ -121,7 +108,58 @@ public class BleNitroBleManager: HybridNativeBleNitroSpec {
|
|
|
121
108
|
connectedDevices.append(device)
|
|
122
109
|
}
|
|
123
110
|
|
|
124
|
-
|
|
111
|
+
// Check previously discovered peripherals to see if any are still connected
|
|
112
|
+
for (deviceId, peripheral) in discoveredPeripherals {
|
|
113
|
+
// Skip if we already know it's connected
|
|
114
|
+
if connectedPeripherals.keys.contains(deviceId) {
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Check if this peripheral is actually connected by checking its state
|
|
119
|
+
if peripheral.state == .connected {
|
|
120
|
+
let device = BLEDevice(
|
|
121
|
+
id: deviceId,
|
|
122
|
+
name: peripheral.name ?? "Unknown Device",
|
|
123
|
+
rssi: 0,
|
|
124
|
+
manufacturerData: ManufacturerData(companyIdentifiers: []),
|
|
125
|
+
serviceUUIDs: peripheral.services?.map { $0.uuid.uuidString } ?? [],
|
|
126
|
+
isConnectable: true
|
|
127
|
+
)
|
|
128
|
+
connectedDevices.append(device)
|
|
129
|
+
|
|
130
|
+
// Add to our tracking dictionary
|
|
131
|
+
connectedPeripherals[deviceId] = peripheral
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Query system connected peripherals with specified services
|
|
136
|
+
let withServices: [CBUUID] = services.compactMap { CBUUID(string: $0) }
|
|
137
|
+
|
|
138
|
+
for service in withServices {
|
|
139
|
+
let peripherals = centralManager.retrieveConnectedPeripherals(withServices: [service])
|
|
140
|
+
for peripheral in peripherals {
|
|
141
|
+
let deviceId = peripheral.identifier.uuidString
|
|
142
|
+
|
|
143
|
+
// Only add if we don't already have it in our list
|
|
144
|
+
if !connectedPeripherals.keys.contains(deviceId) {
|
|
145
|
+
let device = BLEDevice(
|
|
146
|
+
id: deviceId,
|
|
147
|
+
name: peripheral.name ?? "Unknown Device",
|
|
148
|
+
rssi: 0,
|
|
149
|
+
manufacturerData: ManufacturerData(companyIdentifiers: []),
|
|
150
|
+
serviceUUIDs: peripheral.services?.map { $0.uuid.uuidString } ?? [],
|
|
151
|
+
isConnectable: true
|
|
152
|
+
)
|
|
153
|
+
connectedDevices.append(device)
|
|
154
|
+
|
|
155
|
+
// Add to our tracking dictionaries for future use
|
|
156
|
+
discoveredPeripherals[deviceId] = peripheral
|
|
157
|
+
connectedPeripherals[deviceId] = peripheral
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return connectedDevices
|
|
125
163
|
}
|
|
126
164
|
|
|
127
165
|
// MARK: - Connection Management
|
|
@@ -164,11 +202,11 @@ public class BleNitroBleManager: HybridNativeBleNitroSpec {
|
|
|
164
202
|
centralManager.cancelPeripheralConnection(peripheral)
|
|
165
203
|
}
|
|
166
204
|
|
|
167
|
-
public func isConnected(deviceId: String
|
|
205
|
+
public func isConnected(deviceId: String) throws -> Bool {
|
|
168
206
|
if let peripheral = connectedPeripherals[deviceId] {
|
|
169
|
-
|
|
207
|
+
return peripheral.state == .connected
|
|
170
208
|
} else {
|
|
171
|
-
|
|
209
|
+
return false
|
|
172
210
|
}
|
|
173
211
|
}
|
|
174
212
|
|
|
@@ -183,35 +221,31 @@ public class BleNitroBleManager: HybridNativeBleNitroSpec {
|
|
|
183
221
|
peripheral.discoverServices(nil)
|
|
184
222
|
}
|
|
185
223
|
|
|
186
|
-
public func getServices(deviceId: String
|
|
224
|
+
public func getServices(deviceId: String) throws -> [String] {
|
|
187
225
|
guard let peripheral = connectedPeripherals[deviceId] else {
|
|
188
|
-
|
|
189
|
-
return
|
|
226
|
+
return []
|
|
190
227
|
}
|
|
191
228
|
|
|
192
229
|
let serviceUUIDs = peripheral.services?.map { $0.uuid.uuidString } ?? []
|
|
193
|
-
|
|
230
|
+
return serviceUUIDs
|
|
194
231
|
}
|
|
195
232
|
|
|
196
233
|
public func getCharacteristics(
|
|
197
234
|
deviceId: String,
|
|
198
235
|
serviceId: String,
|
|
199
|
-
|
|
200
|
-
) throws {
|
|
236
|
+
) throws -> [String] {
|
|
201
237
|
guard let peripheral = connectedPeripherals[deviceId] else {
|
|
202
|
-
|
|
203
|
-
return
|
|
238
|
+
return []
|
|
204
239
|
}
|
|
205
240
|
|
|
206
241
|
// Find service using CBUUID comparison
|
|
207
242
|
let serviceUUID = CBUUID(string: serviceId)
|
|
208
243
|
guard let service = peripheral.services?.first(where: { $0.uuid == serviceUUID }) else {
|
|
209
|
-
|
|
210
|
-
return
|
|
244
|
+
return []
|
|
211
245
|
}
|
|
212
246
|
|
|
213
247
|
let characteristicUUIDs = service.characteristics?.map { $0.uuid.uuidString } ?? []
|
|
214
|
-
|
|
248
|
+
return characteristicUUIDs
|
|
215
249
|
}
|
|
216
250
|
|
|
217
251
|
// MARK: - Characteristic Operations
|
package/lib/commonjs/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type DisconnectEventCallback = (deviceId: string, interrupted: boolean, e
|
|
|
24
24
|
export type OperationCallback = (success: boolean, error: string) => void;
|
|
25
25
|
export type CharacteristicUpdateCallback = (characteristicId: string, data: number[]) => void;
|
|
26
26
|
export type Subscription = {
|
|
27
|
-
remove: () =>
|
|
27
|
+
remove: () => void;
|
|
28
28
|
};
|
|
29
29
|
export declare enum BLEState {
|
|
30
30
|
Unknown = "Unknown",
|
|
@@ -52,22 +52,23 @@ export declare class BleNitro {
|
|
|
52
52
|
* @param callback Callback function called when a device is found
|
|
53
53
|
* @returns Promise resolving to success state
|
|
54
54
|
*/
|
|
55
|
-
startScan(filter: ScanFilter | undefined, callback: ScanCallback):
|
|
55
|
+
startScan(filter: ScanFilter | undefined, callback: ScanCallback): void;
|
|
56
56
|
/**
|
|
57
57
|
* Stop scanning for Bluetooth devices
|
|
58
58
|
* @returns Promise resolving to success state
|
|
59
59
|
*/
|
|
60
|
-
stopScan():
|
|
60
|
+
stopScan(): void;
|
|
61
61
|
/**
|
|
62
62
|
* Check if currently scanning for devices
|
|
63
63
|
* @returns Promise resolving to scanning state
|
|
64
64
|
*/
|
|
65
|
-
isScanning():
|
|
65
|
+
isScanning(): boolean;
|
|
66
66
|
/**
|
|
67
67
|
* Get all currently connected devices
|
|
68
|
-
* @
|
|
68
|
+
* @param services Optional list of service UUIDs to filter by
|
|
69
|
+
* @returns Array of connected devices
|
|
69
70
|
*/
|
|
70
|
-
getConnectedDevices():
|
|
71
|
+
getConnectedDevices(services?: string[]): BLEDevice[];
|
|
71
72
|
/**
|
|
72
73
|
* Connect to a Bluetooth device
|
|
73
74
|
* @param deviceId ID of the device to connect to
|
|
@@ -80,13 +81,13 @@ export declare class BleNitro {
|
|
|
80
81
|
* @param deviceId ID of the device to disconnect from
|
|
81
82
|
* @returns Promise resolving when disconnected
|
|
82
83
|
*/
|
|
83
|
-
disconnect(deviceId: string): Promise<
|
|
84
|
+
disconnect(deviceId: string): Promise<void>;
|
|
84
85
|
/**
|
|
85
86
|
* Check if connected to a device
|
|
86
87
|
* @param deviceId ID of the device to check
|
|
87
88
|
* @returns Promise resolving to connection state
|
|
88
89
|
*/
|
|
89
|
-
isConnected(deviceId: string):
|
|
90
|
+
isConnected(deviceId: string): boolean;
|
|
90
91
|
/**
|
|
91
92
|
* Discover services for a connected device
|
|
92
93
|
* @param deviceId ID of the device
|
|
@@ -105,7 +106,7 @@ export declare class BleNitro {
|
|
|
105
106
|
* @param serviceId ID of the service
|
|
106
107
|
* @returns Promise resolving to array of characteristic UUIDs
|
|
107
108
|
*/
|
|
108
|
-
getCharacteristics(deviceId: string, serviceId: string):
|
|
109
|
+
getCharacteristics(deviceId: string, serviceId: string): string[];
|
|
109
110
|
/**
|
|
110
111
|
* Read a characteristic value
|
|
111
112
|
* @param deviceId ID of the device
|
|
@@ -132,7 +133,7 @@ export declare class BleNitro {
|
|
|
132
133
|
* @param callback Callback function called when notification is received
|
|
133
134
|
* @returns Promise resolving when subscription is complete
|
|
134
135
|
*/
|
|
135
|
-
subscribeToCharacteristic(deviceId: string, serviceId: string, characteristicId: string, callback: CharacteristicUpdateCallback):
|
|
136
|
+
subscribeToCharacteristic(deviceId: string, serviceId: string, characteristicId: string, callback: CharacteristicUpdateCallback): Subscription;
|
|
136
137
|
/**
|
|
137
138
|
* Unsubscribe from characteristic notifications
|
|
138
139
|
* @param deviceId ID of the device
|
|
@@ -145,9 +146,10 @@ export declare class BleNitro {
|
|
|
145
146
|
* Check if Bluetooth is enabled
|
|
146
147
|
* @returns Promise resolving to Bluetooth state
|
|
147
148
|
*/
|
|
148
|
-
isBluetoothEnabled():
|
|
149
|
+
isBluetoothEnabled(): boolean;
|
|
149
150
|
/**
|
|
150
151
|
* Request to enable Bluetooth
|
|
152
|
+
* Only works on Android
|
|
151
153
|
* @returns Promise resolving when Bluetooth is enabled
|
|
152
154
|
*/
|
|
153
155
|
requestBluetoothEnable(): Promise<boolean>;
|
|
@@ -156,7 +158,7 @@ export declare class BleNitro {
|
|
|
156
158
|
* @returns Promise resolving to Bluetooth state
|
|
157
159
|
* @see BLEState
|
|
158
160
|
*/
|
|
159
|
-
state():
|
|
161
|
+
state(): BLEState;
|
|
160
162
|
/**
|
|
161
163
|
* Subscribe to Bluetooth state changes
|
|
162
164
|
* @param callback Callback function called when state changes
|
|
@@ -164,7 +166,7 @@ export declare class BleNitro {
|
|
|
164
166
|
* @returns Promise resolving when subscription is complete
|
|
165
167
|
* @see BLEState
|
|
166
168
|
*/
|
|
167
|
-
subscribeToStateChange(callback: (state: BLEState) => void, emitInitial?: boolean):
|
|
169
|
+
subscribeToStateChange(callback: (state: BLEState) => void, emitInitial?: boolean): Subscription;
|
|
168
170
|
/**
|
|
169
171
|
* Open Bluetooth settings
|
|
170
172
|
* @returns Promise resolving when settings are opened
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,qBAAqB,EAAE,CAAC;CAC7C;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;AACvD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,KACV,IAAI,CAAC;AACV,MAAM,MAAM,uBAAuB,GAAG,CACpC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,OAAO,EACpB,KAAK,EAAE,MAAM,KACV,IAAI,CAAC;AACV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,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