Skip to content

Commit

Permalink
Update screenshots to include BP7000 (#11)
Browse files Browse the repository at this point in the history
# Update screenshots to include BP7000

## ♻️ Current situation & Problem
This PR updates the screenshots for SpeziDevicesUI to include the BP7000
device.


## ⚙️ Release Notes 
* Demonstrate the BP7000 model in screenshots.


## 📚 Documentation
--


## ✅ Testing
Modified the TestApp for screenshot creation.

## 📝 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).
Supereg authored Aug 28, 2024
1 parent 32b3792 commit cfba769
Showing 9 changed files with 86 additions and 43 deletions.
7 changes: 4 additions & 3 deletions Sources/SpeziDevices/PairedDevices.swift
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ import SwiftUI
/// - ``isConnected(device:)``
/// - ``updateName(for:name:)``
@Observable
public final class PairedDevices: @unchecked Sendable {
public final class PairedDevices {
/// Determines if the device discovery sheet should be presented.
@MainActor public var shouldPresentDevicePairing = false

@@ -120,7 +120,7 @@ public final class PairedDevices: @unchecked Sendable {
@Dependency(Bluetooth.self) @ObservationIgnored private var bluetooth: Bluetooth?
@Dependency(ConfigureTipKit.self) @ObservationIgnored private var tipKit

private var modelContainer: ModelContainer?
@MainActor private var modelContainer: ModelContainer?

/// Determine if Bluetooth is scanning to discovery nearby devices.
///
@@ -142,6 +142,7 @@ public final class PairedDevices: @unchecked Sendable {

/// Configures the Module.
@_documentation(visibility: internal)
@MainActor
public func configure() {
if bluetooth == nil {
self.logger.warning("PairedDevices Module initialized without Bluetooth dependency!")
@@ -363,7 +364,7 @@ public final class PairedDevices: @unchecked Sendable {
}


extension PairedDevices: Module, EnvironmentAccessible, DefaultInitializable {}
extension PairedDevices: Module, EnvironmentAccessible, DefaultInitializable, @unchecked Sendable {}

// MARK: - Device Pairing

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Sources/SpeziOmron/Devices/OmronBloodPressureCuff.swift
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ extension OmronBloodPressureCuff {
systolic: MedFloat16 = 103,
diastolic: MedFloat16 = 64,
pulseRate: MedFloat16 = 62,
name: String = "BP5250",
state: PeripheralState = .disconnected,
nearby: Bool = true,
manufacturerData: OmronManufacturerData = OmronManufacturerData(pairingMode: .pairingMode, users: [
@@ -145,7 +146,7 @@ extension OmronBloodPressureCuff {
let device = OmronBloodPressureCuff()

device.$id.inject(UUID())
device.$name.inject("BP5250")
device.$name.inject(name)
device.$state.inject(state)
device.$nearby.inject(nearby)

109 changes: 70 additions & 39 deletions Tests/UITests/TestApp/DevicesTestView.swift
Original file line number Diff line number Diff line change
@@ -36,47 +36,71 @@ struct DevicesTestView: View {
@State private var didRegister = false
@State private var device = MockDevice.createMockDevice()
@State private var weightScale = OmronWeightScale.createMockDevice(manufacturerData: .omronManufacturerData(mode: .transferMode))
@State private var bloodPressureCuff = OmronBloodPressureCuff.createMockDevice(manufacturerData: .omronManufacturerData(mode: .transferMode))
@State private var bloodPressureCuffBP5250 = OmronBloodPressureCuff.createMockDevice(
manufacturerData: .omronManufacturerData(mode: .transferMode)
)
@State private var bloodPressureCuffBP7000 = OmronBloodPressureCuff.createMockDevice(
name: "BP7000",
manufacturerData: .omronManufacturerData(mode: .transferMode)
)

@State private var viewState: ViewState = .idle

@ToolbarContentBuilder @MainActor private var toolbarContent: some ToolbarContent {
ToolbarItemGroup(placement: .secondaryAction) {
Button("Discover Device", systemImage: "plus.rectangle.fill.on.rectangle.fill") {
device.isInPairingMode = true
device.$advertisementData.inject(AdvertisementData()) // trigger onChange advertisement
}
AsyncButton(state: $viewState) {
try await device.connect()
try await weightScale.connect()
try await bloodPressureCuffBP5250.connect()
try await bloodPressureCuffBP7000.connect()
} label: {
Label("Connect", systemImage: "cable.connector")
}
AsyncButton {
await device.disconnect()
await weightScale.disconnect()
await bloodPressureCuffBP5250.disconnect()
await bloodPressureCuffBP7000.disconnect()
} label: {
Label("Disconnect", systemImage: "cable.connector.slash")
}

omronDevicesMenu
}
}

@MainActor private var omronDevicesMenu: some View {
Menu("Omron Devices", systemImage: "heart.text.square") {
Button("Discover Weight Scale", systemImage: "scalemass.fill") {
weightScale.$advertisementData.inject(AdvertisementData(
manufacturerData: OmronManufacturerData.omronManufacturerData(mode: .pairingMode).encode()
))
}
Menu("Discover Blood Pressure Cuff", systemImage: "heart.fill") {
Button("BP 5250") {
bloodPressureCuffBP5250.$advertisementData.inject(AdvertisementData(
manufacturerData: OmronManufacturerData.omronManufacturerData(mode: .pairingMode).encode()
))
}

Button("BP 7000") {
bloodPressureCuffBP7000.$advertisementData.inject(AdvertisementData(
manufacturerData: OmronManufacturerData.omronManufacturerData(mode: .pairingMode).encode()
))
}
}
}
}

var body: some View {
NavigationStack {
DevicesView(appName: "Example", pairingHint: "Enable pairing mode on the device.")
.toolbar {
ToolbarItemGroup(placement: .secondaryAction) {
Button("Discover Device", systemImage: "plus.rectangle.fill.on.rectangle.fill") {
device.isInPairingMode = true
device.$advertisementData.inject(AdvertisementData()) // trigger onChange advertisement
}
AsyncButton(state: $viewState) {
try await device.connect()
try await weightScale.connect()
try await bloodPressureCuff.connect()
} label: {
Label("Connect", systemImage: "cable.connector")
}
AsyncButton {
await device.disconnect()
await weightScale.disconnect()
await bloodPressureCuff.disconnect()
} label: {
Label("Disconnect", systemImage: "cable.connector.slash")
}

Menu("Omron Devices", systemImage: "heart.text.square") {
Button("Discover Weight Scale", systemImage: "scalemass.fill") {
weightScale.$advertisementData.inject(AdvertisementData(
manufacturerData: OmronManufacturerData.omronManufacturerData(mode: .pairingMode).encode()
))
}
Button("Discovery Blood Pressure Cuff", systemImage: "heart.fill") {
bloodPressureCuff.$advertisementData.inject(AdvertisementData(
manufacturerData: OmronManufacturerData.omronManufacturerData(mode: .pairingMode).encode()
))
}
}
}
toolbarContent
}
}
.viewStateAlert(state: $viewState)
@@ -87,16 +111,23 @@ struct DevicesTestView: View {

moduleLoading.loadMockDevice(device)
moduleLoading.loadMockDevice(weightScale)
moduleLoading.loadMockDevice(bloodPressureCuff)
moduleLoading.loadMockDevice(bloodPressureCuffBP5250)
moduleLoading.loadMockDevice(bloodPressureCuffBP7000)

// simulator this being called in the configure method of the device
pairedDevices.configure(device: device, accessing: device.$state, device.$advertisementData, device.$nearby)
pairedDevices.configure(device: weightScale, accessing: weightScale.$state, weightScale.$advertisementData, weightScale.$nearby)
pairedDevices.configure(
device: bloodPressureCuff,
accessing: bloodPressureCuff.$state,
bloodPressureCuff.$advertisementData,
bloodPressureCuff.$nearby
device: bloodPressureCuffBP5250,
accessing: bloodPressureCuffBP5250.$state,
bloodPressureCuffBP5250.$advertisementData,
bloodPressureCuffBP5250.$nearby
)
pairedDevices.configure(
device: bloodPressureCuffBP7000,
accessing: bloodPressureCuffBP7000.$state,
bloodPressureCuffBP7000.$advertisementData,
bloodPressureCuffBP7000.$nearby
)
didRegister = true
}

0 comments on commit cfba769

Please sign in to comment.