track rssi correctly

This commit is contained in:
callebtc
2025-07-14 00:13:45 +02:00
parent 06a9ec6268
commit 193918d81a
6 changed files with 146 additions and 2 deletions
@@ -41,12 +41,23 @@ class BluetoothConnectionManager(
// Delegate for component managers to call back to main manager
private val componentDelegate = object : BluetoothConnectionManagerDelegate {
override fun onPacketReceived(packet: BitchatPacket, peerID: String, device: BluetoothDevice?) {
device?.let { bluetoothDevice ->
// Get current RSSI for this device and update if available
val currentRSSI = connectionTracker.getBestRSSI(bluetoothDevice.address)
if (currentRSSI != null) {
delegate?.onRSSIUpdated(bluetoothDevice.address, currentRSSI)
}
}
delegate?.onPacketReceived(packet, peerID, device)
}
override fun onDeviceConnected(device: BluetoothDevice) {
delegate?.onDeviceConnected(device)
}
override fun onRSSIUpdated(deviceAddress: String, rssi: Int) {
delegate?.onRSSIUpdated(deviceAddress, rssi)
}
}
private val serverManager = BluetoothGattServerManager(
@@ -231,4 +242,5 @@ class BluetoothConnectionManager(
interface BluetoothConnectionManagerDelegate {
fun onPacketReceived(packet: BitchatPacket, peerID: String, device: BluetoothDevice?)
fun onDeviceConnected(device: BluetoothDevice)
fun onRSSIUpdated(deviceAddress: String, rssi: Int)
}