mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 17:45:19 +00:00
Fix RSSI nil display issue (#316)
* Add comprehensive RSSI debugging logs - Log RSSI capture during discovery phase - Log RSSI reading after peripheral connection - Log didReadRSSI results including validation and retries - Log getPeerRSSI() calls and dictionary contents - Log RSSI transfer from temp IDs to real peer IDs - Add UI logging to trace nil RSSI values in ContentView - Track RSSI flow from Bluetooth discovery to UI display * Add detailed logging for RSSI transfer from temp ID to real peer ID - Log peripheral mapping updates during announce packet handling - Track connectedPeripherals state before and after mapping - Log RSSI transfer from peripheralRSSI to peerRSSI - Identify whether temp ID is found and properly transferred * Add peripheral lookup fallback for announce packets - Log whether peripheral is present when announce received - Add fallback to look up peripheral if not passed as parameter - This handles cases where announce is received via relay * Add comprehensive state logging to getPeerRSSI - Log connectedPeripherals mapping state - Log peripheralRSSI dictionary contents - Log UI-side RSSI lookup attempts with dictionary state - Track exactly what's in the RSSI lookup tables * Log peer list shown in UI * Ensure RSSI transfers even when no temp ID mapping exists * Add debugging for announce packets without peripheral reference * Fix build errors and add type annotations * Fix RSSI mapping for relayed announce packets - Add fallback logic to match unmapped peripherals with announced peers - Transfer RSSI from temp UUID to real peer ID when single unmapped peripheral exists - Implement periodic RSSI updates every 10 seconds for all connected peripherals - Improve RSSI debugging logs to track mapping state * Fix RSSI mapping condition for single unmapped peripheral - Remove peerNicknames.count == 0 condition that was preventing mapping - Map single unmapped peripheral to announcing peer regardless of nickname state - Remove temp RSSI entries when transferring to real peer ID - Improve logging to show successful RSSI transfers * Improve getPeerRSSI to skip temp IDs and check known peers - Skip temp IDs (non-16 character) when iterating connectedPeripherals - Add fallback to check peerNicknames for known peers without peripherals - Check both peerRSSI and peripheralRSSI for known peers - Improve RSSI lookup coverage for edge cases * Remove RSSI debug logging and fix build warnings - Remove all RSSI-related debug logging added during troubleshooting - Keep functional RSSI tracking code intact - Fix unused variable warnings in didReadRSSI and updateAllPeripheralRSSI - Clean up verbose logging while maintaining core functionality --------- Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -600,19 +600,27 @@ struct ContentView: View {
|
||||
|
||||
// Show all connected peers
|
||||
let peersToShow: [String] = viewModel.connectedPeers
|
||||
let _ = print("ContentView: Showing \(peersToShow.count) peers: \(peersToShow.joined(separator: ", "))")
|
||||
|
||||
// Pre-compute peer data outside ForEach to reduce overhead
|
||||
let peerData = peersToShow.map { peerID in
|
||||
PeerDisplayData(
|
||||
let rssiValue = peerRSSI[peerID]?.intValue
|
||||
if rssiValue == nil {
|
||||
print("ContentView: No RSSI for peer \(peerID) in dictionary with \(peerRSSI.count) entries")
|
||||
print("ContentView: peerRSSI keys: \(peerRSSI.keys.joined(separator: ", "))")
|
||||
} else {
|
||||
print("ContentView: RSSI for peer \(peerID) is \(rssiValue!)")
|
||||
}
|
||||
return PeerDisplayData(
|
||||
id: peerID,
|
||||
displayName: peerID == myPeerID ? viewModel.nickname : (peerNicknames[peerID] ?? "anon\(peerID.prefix(4))"),
|
||||
rssi: peerRSSI[peerID]?.intValue,
|
||||
rssi: rssiValue,
|
||||
isFavorite: viewModel.isFavorite(peerID: peerID),
|
||||
isMe: peerID == myPeerID,
|
||||
hasUnreadMessages: viewModel.unreadPrivateMessages.contains(peerID),
|
||||
encryptionStatus: viewModel.getEncryptionStatus(for: peerID)
|
||||
)
|
||||
}.sorted { peer1, peer2 in
|
||||
}.sorted { (peer1: PeerDisplayData, peer2: PeerDisplayData) in
|
||||
// Sort: favorites first, then alphabetically by nickname
|
||||
if peer1.isFavorite != peer2.isFavorite {
|
||||
return peer1.isFavorite
|
||||
|
||||
Reference in New Issue
Block a user