mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Accessorymanager background discovery (#1542)
* Don't add new BLE devices to the device list in the backgournd * Bump version * Update Meshtastic/MeshtasticApp.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/MeshtasticApp.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
5c22b8b6e0
commit
487f24b99a
3 changed files with 8 additions and 2 deletions
|
|
@ -52,8 +52,12 @@ extension AccessoryManager {
|
|||
existing.rssi = newDevice.rssi
|
||||
self.devices[index] = existing
|
||||
} else {
|
||||
// This is a new device, add it to our list
|
||||
self.devices.append(newDevice)
|
||||
// This is a new device, add it to our list if we are in the foreground
|
||||
if !(self.isInBackground) {
|
||||
self.devices.append(newDevice)
|
||||
} else {
|
||||
Logger.transport.debug("🔎 [Discovery] Found a new device but not in the foreground, not adding to our list: peripheral \(newDevice.name)")
|
||||
}
|
||||
}
|
||||
|
||||
if self.shouldAutomaticallyConnectToPreferredPeripheral,
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ class AccessoryManager: ObservableObject, MqttClientProxyManagerDelegate {
|
|||
@Published var lastConnectionError: Error?
|
||||
@Published var isConnected: Bool = false
|
||||
@Published var isConnecting: Bool = false
|
||||
@Published var isInBackground: Bool = false
|
||||
|
||||
var activeConnection: (device: Device, connection: any Connection)?
|
||||
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ struct MeshtasticAppleApp: App {
|
|||
}
|
||||
}
|
||||
.onChange(of: scenePhase) { (_, newScenePhase) in
|
||||
accessoryManager.isInBackground = (newScenePhase == .background)
|
||||
switch newScenePhase {
|
||||
case .background:
|
||||
Logger.services.info("🎬 [App] Scene is in the background")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue