mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 00:25:20 +00:00
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:
@@ -658,7 +658,18 @@ class BluetoothMeshService: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPeerRSSI() -> [String: NSNumber] {
|
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
|
// Emergency disconnect for panic situations
|
||||||
@@ -1145,6 +1156,12 @@ class BluetoothMeshService: NSObject {
|
|||||||
viewModel.registerPeerPublicKey(peerID: senderID, publicKeyData: identityKeyData)
|
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
|
// Track this peer temporarily
|
||||||
if senderID != "unknown" && senderID != myPeerID {
|
if senderID != "unknown" && senderID != myPeerID {
|
||||||
// Check if we need to update peripheral mapping from the specific peripheral that sent this
|
// Check if we need to update peripheral mapping from the specific peripheral that sent this
|
||||||
|
|||||||
Reference in New Issue
Block a user