Skip to content

Commit

Permalink
Bluetooth Device Pairing Infrastructure and Health Measurements (#1)
Browse files Browse the repository at this point in the history
# Bluetooth Device Pairing Infrastructure and Health Measurements

## ♻️ Current situation & Problem
This is the initial PR for SpeziDevices. It introduces three targets
`SpeziDevices`, `SpeziDevicesUI` and `SpeziOmron`.

SpeziDevices provides device pairing and health measurements
functionality for `BluetoothDevice`s implemented using `SpeziBluetooth`.
SpeziDevicesUI provides UI components on top of that, e.g., visualizing
paired devices, editing their information, showing nearby pairable
devices, showing new health measurements, etc.
SpeziOmron provides reusable implementations of Omron Bluetooth
peripherals like the SC150 weight scale and the BP5250 blood pressure
cuff.

## ⚙️ Release Notes 
* Introduce `PairedDevices` module to manage paired devices.
Discovering, pairing and connecting to them.
* Introduce `HealthMeasurements` to manage health measurements from
Bluetooth Devices and converting them to HealthKit samples.
* Introduce SpeziOmron with reusable Omron device implementations.


## 📚 Documentation
All targets contain DocC catalogs, documenting all their types.


## ✅ Testing
This PR adds extensive unit testing of components and has an UI Test app
to test UI components.


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
Supereg authored Jul 2, 2024
1 parent 91d8479 commit 6b5e24f
Show file tree
Hide file tree
Showing 116 changed files with 8,722 additions and 757 deletions.
93 changes: 11 additions & 82 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the Stanford SpeziDevices open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand All @@ -18,107 +18,36 @@ on:
jobs:
packageios:
name: Build and Test Swift Package iOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
resultBundle: TemplatePackage-iOS.xcresult
artifactname: TemplatePackage-iOS.xcresult
packagewatchos:
name: Build and Test Swift Package watchOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
destination: 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)'
resultBundle: TemplatePackage-watchOS.xcresult
artifactname: TemplatePackage-watchOS.xcresult
packagevisionos:
name: Build and Test Swift Package visionOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
resultBundle: TemplatePackage-visionOS.xcresult
artifactname: TemplatePackage-visionOS.xcresult
packagetvos:
name: Build and Test Swift Package tvOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
resultBundle: TemplatePackage-tvOS.xcresult
destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)'
artifactname: TemplatePackage-tvOS.xcresult
packagemacos:
name: Build and Test Swift Package macOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
resultBundle: TemplatePackage-macOS.xcresult
destination: 'platform=macOS,arch=arm64'
artifactname: TemplatePackage-macOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziDevices-Package
resultBundle: SpeziDevices-iOS.xcresult
artifactname: SpeziDevices-iOS.xcresult
ios:
name: Build and Test iOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
resultBundle: TestApp-iOS.xcresult
artifactname: TestApp-iOS.xcresult
ipados:
name: Build and Test iPadOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=iOS Simulator,name=iPad Air (5th generation)'
resultBundle: TestApp-iPadOS.xcresult
artifactname: TestApp-iPadOS.xcresult
watchos:
name: Build and Test watchOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestAppWatchApp
destination: 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)'
resultBundle: TestApp-watchOS.xcresult
artifactname: TestApp-watchOS.xcresult
visionos:
name: Build and Test visionOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
resultBundle: TestApp-visionOS.xcresult
artifactname: TestApp-visionOS.xcresult
tvos:
name: Build and Test tvOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)'
resultBundle: TestApp-tvOS.xcresult
artifactname: TestApp-tvOS.xcresult
codeql:
name: CodeQL
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
codeql: true
test: false
scheme: TemplatePackage
scheme: SpeziDevices-Package
permissions:
security-events: write
actions: read
uploadcoveragereport:
name: Upload Coverage Report
needs: [packageios, packagewatchos, packagevisionos, packagetvos, packagemacos, ios, ipados, watchos, visionos, tvos]
needs: [packageios, ios]
uses: StanfordBDHG/.github/.github/workflows/create-and-upload-coverage-report.yml@v2
with:
coveragereports: TemplatePackage-iOS.xcresult TemplatePackage-watchOS.xcresult TemplatePackage-visionOS.xcresult TemplatePackage-tvOS.xcresult TemplatePackage-macOS.xcresult TestApp-iOS.xcresult TestApp-iPadOS.xcresult TestApp-watchOS.xcresult TestApp-visionOS.xcresult TestApp-tvOS.xcresult
coveragereports: SpeziDevices-iOS.xcresult TestApp-iOS.xcresult
secrets:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the Stanford SpeziDevices open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the Stanford SpeziDevices open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down
6 changes: 4 additions & 2 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the Stanford SpeziDevices open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand All @@ -11,4 +11,6 @@ builder:
configs:
- platform: ios
documentation_targets:
- TemplatePackage
- SpeziDevices
- SpeziDevicesUI
- SpeziOmron
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the Stanford SpeziDevices open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down
12 changes: 6 additions & 6 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the Stanford SpeziDevices open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand All @@ -12,9 +12,9 @@ authors:
- family-names: "Schmiedmayer"
given-names: "Paul"
orcid: "https://orcid.org/0000-0002-8607-9148"
- family-names: "Ravi"
given-names: "Vishnu"
orcid: "https://orcid.org/0000-0003-0359-1275"
title: "TemplatePackage"
- family-names: "Bauer"
given-names: "Andreas"
orcid: "https://orcid.org/0000-0002-1680-237X"
title: "SpeziDevices"
doi: 10.5281/zenodo.7538165
url: "https://github.com/StanfordBDHG/SwiftPackageTemplate"
url: "https://github.com/StanfordSpezi/SpeziDevices"
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the Stanford SpeziDevices open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand All @@ -14,4 +14,4 @@ TemplatePackage contributors
====================

* [Paul Schmiedmayer](https://github.com/PSchmiedmayer)
* [Vishnu Ravi](https://github.com/vishnuravi)
* [Andreas Bauer](https://github.com/Supereg)
122 changes: 111 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,37 +1,137 @@
// swift-tools-version:5.9

//
// This source file is part of the TemplatePackage open source project
// This source file is part of the Stanford SpeziDevices open source project
//
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//

import class Foundation.ProcessInfo
import PackageDescription


#if swift(<6)
let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("StrictConcurrency")
#else
let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("StrictConcurrency")
#endif


let package = Package(
name: "TemplatePackage",
name: "SpeziDevices",
defaultLocalization: "en",
platforms: [
.iOS(.v17),
.watchOS(.v10),
.visionOS(.v1),
.tvOS(.v17),
.macOS(.v14)
.visionOS(.v1)
],
products: [
.library(name: "TemplatePackage", targets: ["TemplatePackage"])
.library(name: "SpeziDevices", targets: ["SpeziDevices"]),
.library(name: "SpeziDevicesUI", targets: ["SpeziDevicesUI"]),
.library(name: "SpeziOmron", targets: ["SpeziOmron"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.1"),
.package(url: "https://github.com/StanfordSpezi/SpeziFoundation", from: "1.1.1"),
.package(url: "https://github.com/StanfordSpezi/Spezi.git", from: "1.4.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziViews.git", from: "1.5.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziBluetooth", from: "2.0.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziNetworking", from: "2.1.1"),
.package(url: "https://github.com/StanfordBDHG/XCTestExtensions.git", .upToNextMinor(from: "0.4.12"))
] + swiftLintPackage(),
targets: [
.target(
name: "TemplatePackage"
name: "SpeziDevices",
dependencies: [
.product(name: "OrderedCollections", package: "swift-collections"),
.product(name: "SpeziFoundation", package: "SpeziFoundation"),
.product(name: "SpeziBluetooth", package: "SpeziBluetooth"),
.product(name: "SpeziBluetoothServices", package: "SpeziBluetooth"),
.product(name: "SpeziViews", package: "SpeziViews"),
.product(name: "Spezi", package: "Spezi")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "SpeziDevicesUI",
dependencies: [
.target(name: "SpeziDevices"),
.product(name: "SpeziViews", package: "SpeziViews"),
.product(name: "SpeziValidation", package: "SpeziViews"),
.product(name: "SpeziBluetooth", package: "SpeziBluetooth")
],
resources: [
.process("Resources")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "SpeziOmron",
dependencies: [
.target(name: "SpeziDevices"),
.product(name: "SpeziBluetooth", package: "SpeziBluetooth"),
.product(name: "SpeziBluetoothServices", package: "SpeziBluetooth")
],
resources: [
.process("Resources")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.testTarget(
name: "SpeziDevicesTests",
dependencies: [
.target(name: "SpeziDevices"),
.product(name: "SpeziFoundation", package: "SpeziFoundation"),
.product(name: "XCTSpezi", package: "Spezi"),
.product(name: "SpeziBluetooth", package: "SpeziBluetooth"),
.product(name: "SpeziBluetoothServices", package: "SpeziBluetooth"),
.product(name: "XCTestExtensions", package: "XCTestExtensions")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.testTarget(
name: "TemplatePackageTests",
name: "SpeziOmronTests",
dependencies: [
.target(name: "TemplatePackage")
]
.target(name: "SpeziOmron"),
.product(name: "SpeziBluetooth", package: "SpeziBluetooth"),
.product(name: "XCTByteCoding", package: "SpeziNetworking"),
.product(name: "XCTestExtensions", package: "XCTestExtensions")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
)
]
)


func swiftLintPlugin() -> [Target.PluginUsage] {
// Fully quit Xcode and open again with `open --env SPEZI_DEVELOPMENT_SWIFTLINT /Applications/Xcode.app`
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint")]
} else {
[]
}
}

func swiftLintPackage() -> [PackageDescription.Package.Dependency] {
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.package(url: "https://github.com/realm/SwiftLint.git", .upToNextMinor(from: "0.55.1"))]
} else {
[]
}
}
Loading

0 comments on commit 6b5e24f

Please sign in to comment.