@magicred-1/react-native-lxmf 0.2.27 → 0.2.29

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.
@@ -48,6 +48,8 @@ class BleManager(
48
48
  private val connecting = mutableSetOf<String>()
49
49
  // Timestamp (ms) when each MAC last disconnected — enforces reconnect cooldown
50
50
  private val disconnectedAt = mutableMapOf<String, Long>()
51
+ // MACs seen in scan results but not yet GATT-connected (mirrors iOS discoveredUnpairedRNodes)
52
+ private val discoveredUnpaired = mutableSetOf<String>()
51
53
 
52
54
  private var scanner: BluetoothLeScanner? = null
53
55
  private var advertiser: BluetoothLeAdvertiser? = null
@@ -113,10 +115,12 @@ class BleManager(
113
115
  connections.values.forEach { it.disconnect(); it.close() }
114
116
  connections.clear()
115
117
  connecting.clear()
118
+ discoveredUnpaired.clear()
116
119
  Log.i(TAG, "BleManager stopped")
117
120
  }
118
121
 
119
122
  fun connectedPeerCount(): Int = module.nativeBlePeerCount()
123
+ fun unpairedRNodeCount(): Int = discoveredUnpaired.size
120
124
 
121
125
  // ── Advertising (so peers can find us) ───────────────────────────────────
122
126
 
@@ -392,6 +396,7 @@ class BleManager(
392
396
  val lastDisconnect = disconnectedAt[mac] ?: 0L
393
397
  if (System.currentTimeMillis() - lastDisconnect < RECONNECT_COOLDOWN_MS) return
394
398
  Log.i(TAG, "BLE: found peer $mac, connecting")
399
+ discoveredUnpaired.add(mac)
395
400
  connecting.add(mac)
396
401
  device.connectGatt(context, false, gattCallback, BluetoothDevice.TRANSPORT_LE)
397
402
  }
@@ -413,6 +418,7 @@ class BleManager(
413
418
  Log.i(TAG, "BLE GATT connected: $mac")
414
419
  connections[mac] = gatt
415
420
  connecting.remove(mac)
421
+ discoveredUnpaired.remove(mac)
416
422
  gatt.discoverServices()
417
423
  }
418
424
  BluetoothProfile.STATE_DISCONNECTED -> {
@@ -421,6 +427,7 @@ class BleManager(
421
427
  Log.i(TAG, "BLE GATT disconnected: $mac (status=$status)")
422
428
  connections.remove(mac)
423
429
  connecting.remove(mac)
430
+ discoveredUnpaired.remove(mac)
424
431
  disconnectedAt[mac] = System.currentTimeMillis()
425
432
  gatt.close()
426
433
  // Notify Rust
@@ -144,6 +144,10 @@ class LxmfModule : Module() {
144
144
  Function("blePeerCount") {
145
145
  nativeBlePeerCount()
146
146
  }
147
+
148
+ Function("bleUnpairedRNodeCount") {
149
+ bleManager?.unpairedRNodeCount() ?: 0
150
+ }
147
151
  }
148
152
 
149
153
  private fun drainAndEmitEvents() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicred-1/react-native-lxmf",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "description": "LXMF Reticulum mesh networking for React Native + Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",