feat: Merge SaltyTag BLE — GPS/IMU streaming to UWB tag, anchor display, UWB position authority #5

Open
sl-ios wants to merge 19 commits from sl-ios/saltytag-merge into main
Showing only changes of commit 7b911d3591 - Show all commits

View File

@ -82,7 +82,11 @@ final class BLEManager: NSObject, ObservableObject {
private func doStartScan() {
DispatchQueue.main.async { self.connectionState = .scanning }
central.scanForPeripherals(withServices: [Self.serviceUUID],
// Scan for ALL peripherals NimBLE (ESP32) puts service UUIDs in the scan
// response, not the primary advertisement. iOS won't call didDiscover for
// service-filtered scans unless the UUID is in the primary ADV_IND packet.
// We filter by device name prefix in didDiscover instead.
central.scanForPeripherals(withServices: nil,
options: [CBCentralManagerScanOptionAllowDuplicatesKey: false])
// Auto-stop after 15 s if nothing found
scanTimer?.invalidate()
@ -122,9 +126,8 @@ extension BLEManager: CBCentralManagerDelegate {
didDiscover peripheral: CBPeripheral,
advertisementData: [String: Any],
rssi RSSI: NSNumber) {
// Match by service advertisement or device name prefix
let name = peripheral.name ?? ""
guard name.hasPrefix("UWB_TAG") || name.isEmpty == false else { return }
// Only connect to UWB_TAG devices (name prefix set by NimBLE on tag firmware)
guard let name = peripheral.name, name.hasPrefix("UWB_TAG") else { return }
stopScan()
self.peripheral = peripheral
peripheral.delegate = self