diff --git a/SulTee/SulTee/BLEStatusView.swift b/SulTee/SulTee/BLEStatusView.swift index b9548ae..73570f1 100644 --- a/SulTee/SulTee/BLEStatusView.swift +++ b/SulTee/SulTee/BLEStatusView.swift @@ -74,7 +74,7 @@ struct BLEStatusView: View { Label { VStack(alignment: .leading, spacing: 2) { Text("GPS → Tag") - Text("5 Hz · 20 bytes/packet") + Text("1 Hz · 20 bytes/packet") .font(.caption).foregroundStyle(.secondary) } } icon: { @@ -86,7 +86,7 @@ struct BLEStatusView: View { Label { VStack(alignment: .leading, spacing: 2) { Text("IMU → Tag") - Text("10 Hz · 22 bytes/packet (accel + gyro + mag)") + Text("2 Hz · 22 bytes/packet (accel + gyro + mag)") .font(.caption).foregroundStyle(.secondary) } } icon: { diff --git a/SulTee/SulTee/SensorManager.swift b/SulTee/SulTee/SensorManager.swift index c3b3820..32dfc51 100644 --- a/SulTee/SulTee/SensorManager.swift +++ b/SulTee/SulTee/SensorManager.swift @@ -116,8 +116,8 @@ final class SensorManager: NSObject, ObservableObject { // MARK: - Timers private var mqttGPSTimer: Timer? // 1 Hz MQTT publish - private var bleGPSTimer: Timer? // 5 Hz BLE GPS write - private var bleIMUTimer: Timer? // 10 Hz BLE IMU write + private var bleGPSTimer: Timer? // 1 Hz BLE GPS write + private var bleIMUTimer: Timer? // 2 Hz BLE IMU write private var uwbStalenessTimer: Timer? private var rateTimer: Timer? @@ -263,13 +263,13 @@ final class SensorManager: NSObject, ObservableObject { private func startBLETimers() { stopBLETimers() - // GPS → tag at 5 Hz (200 ms) - bleGPSTimer = Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true) { [weak self] _ in + // GPS → tag at 1 Hz (1000 ms) — throttled to avoid flooding constrained ESP32 + bleGPSTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in guard let self, let loc = self.lastKnownLocation else { return } self.ble.sendGPS(BLEPackets.gpsPacket(from: loc)) } - // IMU → tag at 10 Hz (100 ms) - bleIMUTimer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { [weak self] _ in + // IMU → tag at 2 Hz (500 ms) — throttled to avoid flooding constrained ESP32 + bleIMUTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { [weak self] _ in guard let self, let motion = self.lastKnownMotion else { return } self.ble.sendIMU(BLEPackets.imuPacket(from: motion)) }