generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
890 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Sources/SpeziDevices/Devices/GenericBluetoothPeripheral.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziBluetooth | ||
|
||
|
||
/// A generic bluetooth peripheral. | ||
public protocol GenericBluetoothPeripheral { | ||
/// The user-visible label. | ||
/// | ||
/// This label is used to communicate information about this device to the user. | ||
var label: String { get } | ||
|
||
/// An optional accessibility label. | ||
/// | ||
/// This label is used as the accessibility label within views when | ||
/// communicate information about this device to the user. | ||
var accessibilityLabel: String { get } | ||
|
||
/// The current peripheral state. | ||
var state: PeripheralState { get } | ||
|
||
/// Mark the device to require user attention. | ||
/// | ||
/// Marks the device to require user attention. The user should navigate to the details | ||
/// view to get more information about the device. | ||
var requiresUserAttention: Bool { get } | ||
} | ||
|
||
|
||
extension GenericBluetoothPeripheral { | ||
/// Default implementation using the devices `label`. | ||
public var accessibilityLabel: String { | ||
label | ||
} | ||
|
||
/// By default the peripheral doesn't require user attention. | ||
public var requiresUserAttention: Bool { | ||
false | ||
} | ||
} | ||
|
||
|
||
extension BluetoothPeripheral: GenericBluetoothPeripheral { | ||
public nonisolated var label: String { | ||
name ?? "Generic Peripheral" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.