mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 04:05:20 +00:00
Remove debug logging after fixing connection issues
- Keep improved connection stability logic (3 minute timeout, 10s duplicate check) - Remove all DEBUG print statements to clean up console output - Connection issues are now resolved
This commit is contained in:
@@ -255,6 +255,8 @@
|
|||||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
INFOPLIST_FILE = bitchat/Info.plist;
|
INFOPLIST_FILE = bitchat/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -285,6 +287,8 @@
|
|||||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
INFOPLIST_FILE = bitchat/Info.plist;
|
INFOPLIST_FILE = bitchat/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|||||||
@@ -373,6 +373,7 @@ class BluetoothMeshService: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startServices() {
|
func startServices() {
|
||||||
|
// Starting services
|
||||||
// Start both central and peripheral services
|
// Start both central and peripheral services
|
||||||
if centralManager.state == .poweredOn {
|
if centralManager.state == .poweredOn {
|
||||||
startScanning()
|
startScanning()
|
||||||
@@ -829,7 +830,7 @@ class BluetoothMeshService: NSObject {
|
|||||||
for peerID in peersToRemove {
|
for peerID in peersToRemove {
|
||||||
// Check if this peer has an active peripheral connection
|
// Check if this peer has an active peripheral connection
|
||||||
if let peripheral = connectedPeripherals[peerID], peripheral.state == .connected {
|
if let peripheral = connectedPeripherals[peerID], peripheral.state == .connected {
|
||||||
print("[DEBUG-CLEANUP] Skipping removal of \(peerID) - still has active connection")
|
// Skipping removal - still has active connection
|
||||||
// Update last seen time to prevent immediate re-removal
|
// Update last seen time to prevent immediate re-removal
|
||||||
peerLastSeenTimestamps[peerID] = Date()
|
peerLastSeenTimestamps[peerID] = Date()
|
||||||
continue
|
continue
|
||||||
@@ -851,7 +852,7 @@ class BluetoothMeshService: NSObject {
|
|||||||
peerNicknamesLock.unlock()
|
peerNicknamesLock.unlock()
|
||||||
|
|
||||||
let lastSeenAgo = peerLastSeenTimestamps[peerID].map { now.timeIntervalSince($0) } ?? 999
|
let lastSeenAgo = peerLastSeenTimestamps[peerID].map { now.timeIntervalSince($0) } ?? 999
|
||||||
print("[DEBUG-CLEANUP] Removed stale peer \(peerID) (\(nickname ?? "unknown")), last seen \(Int(lastSeenAgo))s ago")
|
// Removed stale peer
|
||||||
}
|
}
|
||||||
activePeersLock.unlock()
|
activePeersLock.unlock()
|
||||||
|
|
||||||
@@ -1465,16 +1466,16 @@ class BluetoothMeshService: NSObject {
|
|||||||
if !wasRecentlySeen {
|
if !wasRecentlySeen {
|
||||||
// Found a stale peer ID with the same nickname
|
// Found a stale peer ID with the same nickname
|
||||||
stalePeerIDs.append(existingPeerID)
|
stalePeerIDs.append(existingPeerID)
|
||||||
print("[DEBUG-DUPLICATE] Found stale peer ID \(existingPeerID) with same nickname '\(nickname)' as new peer \(senderID)")
|
// Found stale peer ID
|
||||||
} else {
|
} else {
|
||||||
print("[DEBUG-DUPLICATE] Peer \(existingPeerID) has same nickname '\(nickname)' but was seen recently, keeping both")
|
// Peer was seen recently, keeping both
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove stale peer IDs
|
// Remove stale peer IDs
|
||||||
for stalePeerID in stalePeerIDs {
|
for stalePeerID in stalePeerIDs {
|
||||||
print("[DEBUG-DUPLICATE] Removing stale peer \(stalePeerID) -> '\(nickname)' (replaced by \(senderID))")
|
// Removing stale peer
|
||||||
peerNicknames.removeValue(forKey: stalePeerID)
|
peerNicknames.removeValue(forKey: stalePeerID)
|
||||||
|
|
||||||
// Also remove from active peers
|
// Also remove from active peers
|
||||||
@@ -1789,6 +1790,7 @@ class BluetoothMeshService: NSObject {
|
|||||||
|
|
||||||
extension BluetoothMeshService: CBCentralManagerDelegate {
|
extension BluetoothMeshService: CBCentralManagerDelegate {
|
||||||
func centralManagerDidUpdateState(_ central: CBCentralManager) {
|
func centralManagerDidUpdateState(_ central: CBCentralManager) {
|
||||||
|
// Central manager state updated
|
||||||
if central.state == .poweredOn {
|
if central.state == .poweredOn {
|
||||||
startScanning()
|
startScanning()
|
||||||
|
|
||||||
@@ -1881,7 +1883,7 @@ extension BluetoothMeshService: CBCentralManagerDelegate {
|
|||||||
let tempID = peripheral.identifier.uuidString
|
let tempID = peripheral.identifier.uuidString
|
||||||
connectedPeripherals[tempID] = peripheral
|
connectedPeripherals[tempID] = peripheral
|
||||||
|
|
||||||
print("[DEBUG-CONNECT] Connected to peripheral \(peripheral.name ?? "unknown") with temp ID \(tempID)")
|
// Connected to peripheral
|
||||||
|
|
||||||
// Don't show connected message yet - wait for key exchange
|
// Don't show connected message yet - wait for key exchange
|
||||||
// This prevents the connect/disconnect/connect pattern
|
// This prevents the connect/disconnect/connect pattern
|
||||||
@@ -1899,12 +1901,9 @@ extension BluetoothMeshService: CBCentralManagerDelegate {
|
|||||||
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
|
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
|
||||||
let peripheralID = peripheral.identifier.uuidString
|
let peripheralID = peripheral.identifier.uuidString
|
||||||
|
|
||||||
print("[DEBUG-DISCONNECT] Peripheral \(peripheralID) disconnected, error: \(error?.localizedDescription ?? "none")")
|
|
||||||
|
|
||||||
// Check if this was an intentional disconnect
|
// Check if this was an intentional disconnect
|
||||||
if intentionalDisconnects.contains(peripheralID) {
|
if intentionalDisconnects.contains(peripheralID) {
|
||||||
intentionalDisconnects.remove(peripheralID)
|
intentionalDisconnects.remove(peripheralID)
|
||||||
print("[DEBUG-DISCONNECT] Was intentional disconnect")
|
|
||||||
// Don't process this disconnect further
|
// Don't process this disconnect further
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -2130,6 +2129,7 @@ extension BluetoothMeshService: CBPeripheralDelegate {
|
|||||||
|
|
||||||
extension BluetoothMeshService: CBPeripheralManagerDelegate {
|
extension BluetoothMeshService: CBPeripheralManagerDelegate {
|
||||||
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
|
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
|
||||||
|
// Peripheral manager state updated
|
||||||
switch peripheral.state {
|
switch peripheral.state {
|
||||||
case .poweredOn:
|
case .poweredOn:
|
||||||
setupPeripheral()
|
setupPeripheral()
|
||||||
|
|||||||
Reference in New Issue
Block a user