munim-bluetooth 0.3.24 → 0.3.26

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 (28) hide show
  1. package/android/src/main/AndroidManifest.xml +10 -0
  2. package/android/src/main/java/com/munimbluetooth/HybridMunimBluetooth.kt +87 -0
  3. package/android/src/main/java/com/munimbluetooth/MunimBluetoothBackgroundService.kt +344 -0
  4. package/ios/HybridMunimBluetooth.swift +265 -22
  5. package/lib/commonjs/index.js +21 -0
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/module/index.js +19 -0
  8. package/lib/module/index.js.map +1 -1
  9. package/lib/typescript/src/index.d.ts +15 -2
  10. package/lib/typescript/src/index.d.ts.map +1 -1
  11. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts +25 -3
  12. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts.map +1 -1
  13. package/nitrogen/generated/android/c++/JBackgroundSessionOptions.hpp +107 -0
  14. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +12 -0
  15. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +2 -0
  16. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BackgroundSessionOptions.kt +59 -0
  17. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +28 -20
  18. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Umbrella.hpp +3 -0
  19. package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.hpp +15 -0
  20. package/nitrogen/generated/ios/swift/BackgroundSessionOptions.swift +154 -0
  21. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +2 -0
  22. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +43 -21
  23. package/nitrogen/generated/shared/c++/BackgroundSessionOptions.hpp +115 -0
  24. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.cpp +2 -0
  25. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.hpp +5 -0
  26. package/package.json +1 -1
  27. package/src/index.ts +23 -0
  28. package/src/specs/munim-bluetooth.nitro.ts +28 -3
@@ -84,7 +84,7 @@ open class HybridMunimBluetoothSpec_cxx {
84
84
  }
85
85
  }
86
86
 
87
-
87
+
88
88
 
89
89
  /**
90
90
  * Get the memory size of the Swift class (plus size of any other allocations)
@@ -121,7 +121,7 @@ open class HybridMunimBluetoothSpec_cxx {
121
121
  }
122
122
 
123
123
  // Properties
124
-
124
+
125
125
 
126
126
  // Methods
127
127
  @inline(__always)
@@ -134,7 +134,7 @@ open class HybridMunimBluetoothSpec_cxx {
134
134
  return bridge.create_Result_void_(__exceptionPtr)
135
135
  }
136
136
  }
137
-
137
+
138
138
  @inline(__always)
139
139
  public final func updateAdvertisingData(advertisingData: AdvertisingDataTypes) -> bridge.Result_void_ {
140
140
  do {
@@ -145,7 +145,7 @@ open class HybridMunimBluetoothSpec_cxx {
145
145
  return bridge.create_Result_void_(__exceptionPtr)
146
146
  }
147
147
  }
148
-
148
+
149
149
  @inline(__always)
150
150
  public final func getAdvertisingData() -> bridge.Result_std__shared_ptr_Promise_AdvertisingDataTypes___ {
151
151
  do {
@@ -164,7 +164,7 @@ open class HybridMunimBluetoothSpec_cxx {
164
164
  return bridge.create_Result_std__shared_ptr_Promise_AdvertisingDataTypes___(__exceptionPtr)
165
165
  }
166
166
  }
167
-
167
+
168
168
  @inline(__always)
169
169
  public final func stopAdvertising() -> bridge.Result_void_ {
170
170
  do {
@@ -175,7 +175,7 @@ open class HybridMunimBluetoothSpec_cxx {
175
175
  return bridge.create_Result_void_(__exceptionPtr)
176
176
  }
177
177
  }
178
-
178
+
179
179
  @inline(__always)
180
180
  public final func setServices(services: bridge.std__vector_GATTService_) -> bridge.Result_void_ {
181
181
  do {
@@ -186,7 +186,7 @@ open class HybridMunimBluetoothSpec_cxx {
186
186
  return bridge.create_Result_void_(__exceptionPtr)
187
187
  }
188
188
  }
189
-
189
+
190
190
  @inline(__always)
191
191
  public final func isBluetoothEnabled() -> bridge.Result_std__shared_ptr_Promise_bool___ {
192
192
  do {
@@ -205,7 +205,7 @@ open class HybridMunimBluetoothSpec_cxx {
205
205
  return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
206
206
  }
207
207
  }
208
-
208
+
209
209
  @inline(__always)
210
210
  public final func requestBluetoothPermission() -> bridge.Result_std__shared_ptr_Promise_bool___ {
211
211
  do {
@@ -224,7 +224,7 @@ open class HybridMunimBluetoothSpec_cxx {
224
224
  return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
225
225
  }
226
226
  }
227
-
227
+
228
228
  @inline(__always)
229
229
  public final func startScan(options: bridge.std__optional_ScanOptions_) -> bridge.Result_void_ {
230
230
  do {
@@ -235,7 +235,7 @@ open class HybridMunimBluetoothSpec_cxx {
235
235
  return bridge.create_Result_void_(__exceptionPtr)
236
236
  }
237
237
  }
238
-
238
+
239
239
  @inline(__always)
240
240
  public final func stopScan() -> bridge.Result_void_ {
241
241
  do {
@@ -246,7 +246,7 @@ open class HybridMunimBluetoothSpec_cxx {
246
246
  return bridge.create_Result_void_(__exceptionPtr)
247
247
  }
248
248
  }
249
-
249
+
250
250
  @inline(__always)
251
251
  public final func connect(deviceId: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
252
252
  do {
@@ -265,7 +265,7 @@ open class HybridMunimBluetoothSpec_cxx {
265
265
  return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
266
266
  }
267
267
  }
268
-
268
+
269
269
  @inline(__always)
270
270
  public final func disconnect(deviceId: std.string) -> bridge.Result_void_ {
271
271
  do {
@@ -276,7 +276,7 @@ open class HybridMunimBluetoothSpec_cxx {
276
276
  return bridge.create_Result_void_(__exceptionPtr)
277
277
  }
278
278
  }
279
-
279
+
280
280
  @inline(__always)
281
281
  public final func discoverServices(deviceId: std.string) -> bridge.Result_std__shared_ptr_Promise_std__vector_GATTService____ {
282
282
  do {
@@ -301,7 +301,7 @@ open class HybridMunimBluetoothSpec_cxx {
301
301
  return bridge.create_Result_std__shared_ptr_Promise_std__vector_GATTService____(__exceptionPtr)
302
302
  }
303
303
  }
304
-
304
+
305
305
  @inline(__always)
306
306
  public final func readCharacteristic(deviceId: std.string, serviceUUID: std.string, characteristicUUID: std.string) -> bridge.Result_std__shared_ptr_Promise_CharacteristicValue___ {
307
307
  do {
@@ -320,7 +320,7 @@ open class HybridMunimBluetoothSpec_cxx {
320
320
  return bridge.create_Result_std__shared_ptr_Promise_CharacteristicValue___(__exceptionPtr)
321
321
  }
322
322
  }
323
-
323
+
324
324
  @inline(__always)
325
325
  public final func writeCharacteristic(deviceId: std.string, serviceUUID: std.string, characteristicUUID: std.string, value: std.string, writeType: bridge.std__optional_WriteType_) -> bridge.Result_std__shared_ptr_Promise_void___ {
326
326
  do {
@@ -339,7 +339,7 @@ open class HybridMunimBluetoothSpec_cxx {
339
339
  return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
340
340
  }
341
341
  }
342
-
342
+
343
343
  @inline(__always)
344
344
  public final func subscribeToCharacteristic(deviceId: std.string, serviceUUID: std.string, characteristicUUID: std.string) -> bridge.Result_void_ {
345
345
  do {
@@ -350,7 +350,7 @@ open class HybridMunimBluetoothSpec_cxx {
350
350
  return bridge.create_Result_void_(__exceptionPtr)
351
351
  }
352
352
  }
353
-
353
+
354
354
  @inline(__always)
355
355
  public final func unsubscribeFromCharacteristic(deviceId: std.string, serviceUUID: std.string, characteristicUUID: std.string) -> bridge.Result_void_ {
356
356
  do {
@@ -361,7 +361,7 @@ open class HybridMunimBluetoothSpec_cxx {
361
361
  return bridge.create_Result_void_(__exceptionPtr)
362
362
  }
363
363
  }
364
-
364
+
365
365
  @inline(__always)
366
366
  public final func getConnectedDevices() -> bridge.Result_std__shared_ptr_Promise_std__vector_std__string____ {
367
367
  do {
@@ -386,7 +386,7 @@ open class HybridMunimBluetoothSpec_cxx {
386
386
  return bridge.create_Result_std__shared_ptr_Promise_std__vector_std__string____(__exceptionPtr)
387
387
  }
388
388
  }
389
-
389
+
390
390
  @inline(__always)
391
391
  public final func readRSSI(deviceId: std.string) -> bridge.Result_std__shared_ptr_Promise_double___ {
392
392
  do {
@@ -405,7 +405,29 @@ open class HybridMunimBluetoothSpec_cxx {
405
405
  return bridge.create_Result_std__shared_ptr_Promise_double___(__exceptionPtr)
406
406
  }
407
407
  }
408
-
408
+
409
+ @inline(__always)
410
+ public final func startBackgroundSession(options: BackgroundSessionOptions) -> bridge.Result_void_ {
411
+ do {
412
+ try self.__implementation.startBackgroundSession(options: options)
413
+ return bridge.create_Result_void_()
414
+ } catch (let __error) {
415
+ let __exceptionPtr = __error.toCpp()
416
+ return bridge.create_Result_void_(__exceptionPtr)
417
+ }
418
+ }
419
+
420
+ @inline(__always)
421
+ public final func stopBackgroundSession() -> bridge.Result_void_ {
422
+ do {
423
+ try self.__implementation.stopBackgroundSession()
424
+ return bridge.create_Result_void_()
425
+ } catch (let __error) {
426
+ let __exceptionPtr = __error.toCpp()
427
+ return bridge.create_Result_void_(__exceptionPtr)
428
+ }
429
+ }
430
+
409
431
  @inline(__always)
410
432
  public final func addListener(eventName: std.string) -> bridge.Result_void_ {
411
433
  do {
@@ -416,7 +438,7 @@ open class HybridMunimBluetoothSpec_cxx {
416
438
  return bridge.create_Result_void_(__exceptionPtr)
417
439
  }
418
440
  }
419
-
441
+
420
442
  @inline(__always)
421
443
  public final func removeListeners(count: Double) -> bridge.Result_void_ {
422
444
  do {
@@ -0,0 +1,115 @@
1
+ ///
2
+ /// BackgroundSessionOptions.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `ScanMode` to properly resolve imports.
32
+ namespace margelo::nitro::munimbluetooth { enum class ScanMode; }
33
+
34
+ #include <string>
35
+ #include <vector>
36
+ #include <optional>
37
+ #include "ScanMode.hpp"
38
+
39
+ namespace margelo::nitro::munimbluetooth {
40
+
41
+ /**
42
+ * A struct which can be represented as a JavaScript object (BackgroundSessionOptions).
43
+ */
44
+ struct BackgroundSessionOptions final {
45
+ public:
46
+ std::vector<std::string> serviceUUIDs SWIFT_PRIVATE;
47
+ std::optional<std::string> localName SWIFT_PRIVATE;
48
+ std::optional<bool> allowDuplicates SWIFT_PRIVATE;
49
+ std::optional<ScanMode> scanMode SWIFT_PRIVATE;
50
+ std::optional<std::string> androidNotificationChannelId SWIFT_PRIVATE;
51
+ std::optional<std::string> androidNotificationChannelName SWIFT_PRIVATE;
52
+ std::optional<std::string> androidNotificationTitle SWIFT_PRIVATE;
53
+ std::optional<std::string> androidNotificationText SWIFT_PRIVATE;
54
+
55
+ public:
56
+ BackgroundSessionOptions() = default;
57
+ explicit BackgroundSessionOptions(std::vector<std::string> serviceUUIDs, std::optional<std::string> localName, std::optional<bool> allowDuplicates, std::optional<ScanMode> scanMode, std::optional<std::string> androidNotificationChannelId, std::optional<std::string> androidNotificationChannelName, std::optional<std::string> androidNotificationTitle, std::optional<std::string> androidNotificationText): serviceUUIDs(serviceUUIDs), localName(localName), allowDuplicates(allowDuplicates), scanMode(scanMode), androidNotificationChannelId(androidNotificationChannelId), androidNotificationChannelName(androidNotificationChannelName), androidNotificationTitle(androidNotificationTitle), androidNotificationText(androidNotificationText) {}
58
+
59
+ public:
60
+ friend bool operator==(const BackgroundSessionOptions& lhs, const BackgroundSessionOptions& rhs) = default;
61
+ };
62
+
63
+ } // namespace margelo::nitro::munimbluetooth
64
+
65
+ namespace margelo::nitro {
66
+
67
+ // C++ BackgroundSessionOptions <> JS BackgroundSessionOptions (object)
68
+ template <>
69
+ struct JSIConverter<margelo::nitro::munimbluetooth::BackgroundSessionOptions> final {
70
+ static inline margelo::nitro::munimbluetooth::BackgroundSessionOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
71
+ jsi::Object obj = arg.asObject(runtime);
72
+ return margelo::nitro::munimbluetooth::BackgroundSessionOptions(
73
+ JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"))),
74
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "localName"))),
75
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowDuplicates"))),
76
+ JSIConverter<std::optional<margelo::nitro::munimbluetooth::ScanMode>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scanMode"))),
77
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationChannelId"))),
78
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationChannelName"))),
79
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationTitle"))),
80
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationText")))
81
+ );
82
+ }
83
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::BackgroundSessionOptions& arg) {
84
+ jsi::Object obj(runtime);
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.serviceUUIDs));
86
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "localName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.localName));
87
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowDuplicates"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.allowDuplicates));
88
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "scanMode"), JSIConverter<std::optional<margelo::nitro::munimbluetooth::ScanMode>>::toJSI(runtime, arg.scanMode));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationChannelId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.androidNotificationChannelId));
90
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationChannelName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.androidNotificationChannelName));
91
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationTitle"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.androidNotificationTitle));
92
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationText"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.androidNotificationText));
93
+ return obj;
94
+ }
95
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
96
+ if (!value.isObject()) {
97
+ return false;
98
+ }
99
+ jsi::Object obj = value.getObject(runtime);
100
+ if (!nitro::isPlainObject(runtime, obj)) {
101
+ return false;
102
+ }
103
+ if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs")))) return false;
104
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "localName")))) return false;
105
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowDuplicates")))) return false;
106
+ if (!JSIConverter<std::optional<margelo::nitro::munimbluetooth::ScanMode>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scanMode")))) return false;
107
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationChannelId")))) return false;
108
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationChannelName")))) return false;
109
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationTitle")))) return false;
110
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidNotificationText")))) return false;
111
+ return true;
112
+ }
113
+ };
114
+
115
+ } // namespace margelo::nitro
@@ -32,6 +32,8 @@ namespace margelo::nitro::munimbluetooth {
32
32
  prototype.registerHybridMethod("unsubscribeFromCharacteristic", &HybridMunimBluetoothSpec::unsubscribeFromCharacteristic);
33
33
  prototype.registerHybridMethod("getConnectedDevices", &HybridMunimBluetoothSpec::getConnectedDevices);
34
34
  prototype.registerHybridMethod("readRSSI", &HybridMunimBluetoothSpec::readRSSI);
35
+ prototype.registerHybridMethod("startBackgroundSession", &HybridMunimBluetoothSpec::startBackgroundSession);
36
+ prototype.registerHybridMethod("stopBackgroundSession", &HybridMunimBluetoothSpec::stopBackgroundSession);
35
37
  prototype.registerHybridMethod("addListener", &HybridMunimBluetoothSpec::addListener);
36
38
  prototype.registerHybridMethod("removeListeners", &HybridMunimBluetoothSpec::removeListeners);
37
39
  });
@@ -25,6 +25,8 @@ namespace margelo::nitro::munimbluetooth { struct ScanOptions; }
25
25
  namespace margelo::nitro::munimbluetooth { struct CharacteristicValue; }
26
26
  // Forward declaration of `WriteType` to properly resolve imports.
27
27
  namespace margelo::nitro::munimbluetooth { enum class WriteType; }
28
+ // Forward declaration of `BackgroundSessionOptions` to properly resolve imports.
29
+ namespace margelo::nitro::munimbluetooth { struct BackgroundSessionOptions; }
28
30
 
29
31
  #include "AdvertisingOptions.hpp"
30
32
  #include "AdvertisingDataTypes.hpp"
@@ -36,6 +38,7 @@ namespace margelo::nitro::munimbluetooth { enum class WriteType; }
36
38
  #include <string>
37
39
  #include "CharacteristicValue.hpp"
38
40
  #include "WriteType.hpp"
41
+ #include "BackgroundSessionOptions.hpp"
39
42
 
40
43
  namespace margelo::nitro::munimbluetooth {
41
44
 
@@ -86,6 +89,8 @@ namespace margelo::nitro::munimbluetooth {
86
89
  virtual void unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) = 0;
87
90
  virtual std::shared_ptr<Promise<std::vector<std::string>>> getConnectedDevices() = 0;
88
91
  virtual std::shared_ptr<Promise<double>> readRSSI(const std::string& deviceId) = 0;
92
+ virtual void startBackgroundSession(const BackgroundSessionOptions& options) = 0;
93
+ virtual void stopBackgroundSession() = 0;
89
94
  virtual void addListener(const std::string& eventName) = 0;
90
95
  virtual void removeListeners(double count) = 0;
91
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "munim-bluetooth",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "A comprehensive React Native library for all your Bluetooth Low Energy (BLE) needs, supporting both peripheral and central roles with Expo support",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import type {
9
9
  MunimBluetooth as MunimBluetoothSpec,
10
10
  AdvertisingDataTypes,
11
11
  BLEDevice,
12
+ BackgroundSessionOptions,
12
13
  ScanOptions,
13
14
  GATTService,
14
15
  CharacteristicValue,
@@ -281,6 +282,25 @@ export function readRSSI(deviceId: string): Promise<number> {
281
282
  return MunimBluetooth.readRSSI(deviceId)
282
283
  }
283
284
 
285
+ /**
286
+ * Start a best-effort background BLE session.
287
+ *
288
+ * Android uses a foreground service. iOS relies on the host app's Bluetooth
289
+ * background modes and state restoration.
290
+ */
291
+ export function startBackgroundSession(
292
+ options: BackgroundSessionOptions
293
+ ): void {
294
+ return MunimBluetooth.startBackgroundSession(options)
295
+ }
296
+
297
+ /**
298
+ * Stop the active background BLE session.
299
+ */
300
+ export function stopBackgroundSession(): void {
301
+ return MunimBluetooth.stopBackgroundSession()
302
+ }
303
+
284
304
  // ========== Event Management ==========
285
305
 
286
306
  /**
@@ -348,6 +368,7 @@ export function removeListeners(count: number): void {
348
368
  export type {
349
369
  AdvertisingDataTypes,
350
370
  BLEDevice,
371
+ BackgroundSessionOptions,
351
372
  ScanOptions,
352
373
  GATTService,
353
374
  CharacteristicValue,
@@ -375,6 +396,8 @@ export default {
375
396
  unsubscribeFromCharacteristic,
376
397
  getConnectedDevices,
377
398
  readRSSI,
399
+ startBackgroundSession,
400
+ stopBackgroundSession,
378
401
  // Events
379
402
  addDeviceFoundListener,
380
403
  addEventListener,
@@ -96,6 +96,17 @@ export interface AdvertisingOptions {
96
96
  advertisingData?: AdvertisingDataTypes
97
97
  }
98
98
 
99
+ export interface BackgroundSessionOptions {
100
+ serviceUUIDs: string[]
101
+ localName?: string
102
+ allowDuplicates?: boolean
103
+ scanMode?: ScanMode
104
+ androidNotificationChannelId?: string
105
+ androidNotificationChannelName?: string
106
+ androidNotificationTitle?: string
107
+ androidNotificationText?: string
108
+ }
109
+
99
110
  export interface MunimBluetooth
100
111
  extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
101
112
  // ========== Peripheral Features ==========
@@ -254,11 +265,25 @@ export interface MunimBluetooth
254
265
  /**
255
266
  * Read RSSI (signal strength) for a connected device.
256
267
  *
257
- * @param deviceId - The unique identifier of the connected device.
258
- * @returns Promise resolving to RSSI value in dBm.
259
- */
268
+ * @param deviceId - The unique identifier of the connected device.
269
+ * @returns Promise resolving to RSSI value in dBm.
270
+ */
260
271
  readRSSI(deviceId: string): Promise<number>
261
272
 
273
+ /**
274
+ * Start a best-effort background BLE session.
275
+ *
276
+ * Android uses a foreground service so BLE can continue after the app leaves the foreground.
277
+ * iOS keeps the central/peripheral managers running and relies on the host app's Bluetooth
278
+ * background modes for best-effort background operation.
279
+ */
280
+ startBackgroundSession(options: BackgroundSessionOptions): void
281
+
282
+ /**
283
+ * Stop the active background BLE session.
284
+ */
285
+ stopBackgroundSession(): void
286
+
262
287
  // ========== Event Management ==========
263
288
 
264
289
  /**