diff --git a/bitchat/Services/AudioRecordingService.swift b/bitchat/Services/AudioRecordingService.swift index af254305..85f1ae2d 100644 --- a/bitchat/Services/AudioRecordingService.swift +++ b/bitchat/Services/AudioRecordingService.swift @@ -72,10 +72,14 @@ class AudioRecordingService: NSObject, ObservableObject { audioRecorder?.delegate = self audioRecorder?.prepareToRecord() // Important: prepare before recording + print("[AUDIO] Created recorder with URL: \(audioFilename)") + print("[AUDIO] Recorder prepared: \(audioRecorder?.prepareToRecord() ?? false)") + if audioRecorder?.record() == true { isRecording = true recordingStartTime = Date() recordingTime = 0 + print("[AUDIO] Recording started successfully") // Start timer to update recording time and enforce max duration recordingTimer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { [weak self] _ in diff --git a/bitchat/Services/BluetoothMeshService.swift b/bitchat/Services/BluetoothMeshService.swift index 821ddd9d..3e78d9d7 100644 --- a/bitchat/Services/BluetoothMeshService.swift +++ b/bitchat/Services/BluetoothMeshService.swift @@ -373,10 +373,19 @@ class BluetoothMeshService: NSObject { // Send to subscribed centrals (as peripheral) if characteristic != nil && !subscribedCentrals.isEmpty { - peripheralManager.updateValue(data, for: characteristic, onSubscribedCentrals: subscribedCentrals) - print("[BROADCAST] Sent to \(subscribedCentrals.count) subscribed centrals") + let success = peripheralManager.updateValue(data, for: characteristic, onSubscribedCentrals: subscribedCentrals) + if success { + print("[BROADCAST] Successfully sent to \(subscribedCentrals.count) subscribed centrals") + } else { + print("[BROADCAST] Failed to send to centrals - queue full, will retry on delegate callback") + } } else { - print("[BROADCAST] No subscribed centrals to send to") + if characteristic == nil { + print("[BROADCAST] No characteristic available") + } + if subscribedCentrals.isEmpty { + print("[BROADCAST] No subscribed centrals") + } } } diff --git a/bitchat/ViewModels/ChatViewModel.swift b/bitchat/ViewModels/ChatViewModel.swift index 6bf521af..18462a25 100644 --- a/bitchat/ViewModels/ChatViewModel.swift +++ b/bitchat/ViewModels/ChatViewModel.swift @@ -631,6 +631,8 @@ extension ChatViewModel: BitchatDelegate { } func sendVoiceNote(_ audioData: Data, duration: TimeInterval) { + print("[VIEWMODEL] sendVoiceNote called with audio data: \(audioData.count) bytes, duration: \(duration)s") + let message = BitchatMessage( sender: nickname, content: "🎤 \(String(format: "%.1f", duration))s", @@ -642,6 +644,8 @@ extension ChatViewModel: BitchatDelegate { ) messages.append(message) + print("[VIEWMODEL] Added voice note to local messages, sending via mesh...") + // Send via mesh meshService.sendVoiceNote(audioData, duration: duration) } diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index efd366c7..9ab04d3f 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -370,7 +370,7 @@ struct ContentView: View { // Regular messages with tappable sender name HStack(alignment: .top, spacing: 0) { // Timestamp - Text("[\\(viewModel.formatTimestamp(message.timestamp))] ") + Text("[\(viewModel.formatTimestamp(message.timestamp))] ") .font(.system(size: 12, design: .monospaced)) .foregroundColor(secondaryTextColor) @@ -382,14 +382,14 @@ struct ContentView: View { } }) { let senderColor = viewModel.getSenderColor(for: message, colorScheme: colorScheme) - Text("<\\(message.sender)>") + Text("<\(message.sender)>") .font(.system(size: 12, weight: .medium, design: .monospaced)) .foregroundColor(senderColor) } .buttonStyle(.plain) } else { // Own messages not tappable - Text("<\\(message.sender)>") + Text("<\(message.sender)>") .font(.system(size: 12, weight: .medium, design: .monospaced)) .foregroundColor(textColor) }