Fix critical packet format bugs matching SDK: frame select/type/trigger/disable commands now send empty data, RSSI@1m corrected to -59 dBm. Add DebugLog, read-config mode, service point list, and dev scheme. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
912 B
Swift
33 lines
912 B
Swift
import Foundation
|
|
|
|
/// Simple in-app debug log — viewable from ScanView
|
|
class DebugLog: ObservableObject {
|
|
static let shared = DebugLog()
|
|
|
|
@Published var entries: [String] = []
|
|
|
|
private let maxEntries = 200
|
|
|
|
func log(_ message: String) {
|
|
let ts = DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .medium)
|
|
let entry = "[\(ts)] \(message)"
|
|
NSLog("[DebugLog] \(message)")
|
|
DispatchQueue.main.async {
|
|
self.entries.append(entry)
|
|
if self.entries.count > self.maxEntries {
|
|
self.entries.removeFirst(self.entries.count - self.maxEntries)
|
|
}
|
|
}
|
|
}
|
|
|
|
func clear() {
|
|
DispatchQueue.main.async {
|
|
self.entries.removeAll()
|
|
}
|
|
}
|
|
|
|
/// Get all entries as a single string for clipboard
|
|
var allText: String {
|
|
entries.joined(separator: "\n")
|
|
}
|
|
}
|