Fix RSSI display inconsistency between devices

- Add default RSSI value (-60) for connected peers without RSSI data
- Transfer RSSI from peripheral discovery to peer after key exchange
- Fixes red dot showing for nearby devices that can't report RSSI
- Centrals (phones acting as servers) now show green by default
This commit is contained in:
jack
2025-07-04 13:35:46 +02:00
parent 6f85faa6c0
commit e6fcae6275
+18 -1
View File
@@ -658,7 +658,18 @@ class BluetoothMeshService: NSObject {
}
func getPeerRSSI() -> [String: NSNumber] {
return peerRSSI
// Create a copy with default values for connected peers without RSSI
var rssiWithDefaults = peerRSSI
// For any active peer without RSSI, assume decent signal (-60)
// This handles centrals where we can't read RSSI
for peerID in activePeers {
if rssiWithDefaults[peerID] == nil {
rssiWithDefaults[peerID] = NSNumber(value: -60) // Good signal default
}
}
return rssiWithDefaults
}
// Emergency disconnect for panic situations
@@ -1145,6 +1156,12 @@ class BluetoothMeshService: NSObject {
viewModel.registerPeerPublicKey(peerID: senderID, publicKeyData: identityKeyData)
}
// If we have RSSI from discovery, apply it to this peer
if let peripheral = peripheral,
let tempRSSI = peripheralRSSI[peripheral.identifier.uuidString] {
peerRSSI[senderID] = tempRSSI
}
// Track this peer temporarily
if senderID != "unknown" && senderID != myPeerID {
// Check if we need to update peripheral mapping from the specific peripheral that sent this