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() { private func doStartScan() {
DispatchQueue.main.async { self.connectionState = .scanning } 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]) options: [CBCentralManagerScanOptionAllowDuplicatesKey: false])
// Auto-stop after 15 s if nothing found // Auto-stop after 15 s if nothing found
scanTimer?.invalidate() scanTimer?.invalidate()
@ -122,9 +126,8 @@ extension BLEManager: CBCentralManagerDelegate {
didDiscover peripheral: CBPeripheral, didDiscover peripheral: CBPeripheral,
advertisementData: [String: Any], advertisementData: [String: Any],
rssi RSSI: NSNumber) { rssi RSSI: NSNumber) {
// Match by service advertisement or device name prefix // Only connect to UWB_TAG devices (name prefix set by NimBLE on tag firmware)
let name = peripheral.name ?? "" guard let name = peripheral.name, name.hasPrefix("UWB_TAG") else { return }
guard name.hasPrefix("UWB_TAG") || name.isEmpty == false else { return }
stopScan() stopScan()
self.peripheral = peripheral self.peripheral = peripheral
peripheral.delegate = self peripheral.delegate = self