Skip to content

Commit

Permalink
Initital devce info sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Jan 25, 2024
1 parent 7fc959e commit a0b51d6
Show file tree
Hide file tree
Showing 74 changed files with 511 additions and 284 deletions.
24 changes: 23 additions & 1 deletion NAMS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@
A9BCB58D2AE84E6D00DA8588 /* CurrentPatientLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BCB58B2AE84E6D00DA8588 /* CurrentPatientLabel.swift */; };
A9BCB5902AE8588B00DA8588 /* NoInformationText.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BCB58F2AE8588B00DA8588 /* NoInformationText.swift */; };
A9BCB5912AE8588B00DA8588 /* NoInformationText.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BCB58F2AE8588B00DA8588 /* NoInformationText.swift */; };
A9C82F922B608756004703E0 /* ImpedanceMeasurement.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C82F912B608756004703E0 /* ImpedanceMeasurement.swift */; };
A9C82F932B60899B004703E0 /* ImpedanceMeasurement.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C82F912B608756004703E0 /* ImpedanceMeasurement.swift */; };
A9C82F952B6089C8004703E0 /* BluetoothServices in Frameworks */ = {isa = PBXBuildFile; productRef = A9C82F942B6089C8004703E0 /* BluetoothServices */; };
A9C82F972B6089D2004703E0 /* BluetoothServices in Frameworks */ = {isa = PBXBuildFile; productRef = A9C82F962B6089D2004703E0 /* BluetoothServices */; };
A9C9B6B42ADE191100C8C46D /* EEGDeviceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C9B6B32ADE191100C8C46D /* EEGDeviceTests.swift */; };
A9CE84512B1A9A14009CE3F4 /* DevicesSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CE84502B1A9A14009CE3F4 /* DevicesSheet.swift */; };
A9CE84522B1A9A14009CE3F4 /* DevicesSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CE84502B1A9A14009CE3F4 /* DevicesSheet.swift */; };
Expand Down Expand Up @@ -399,6 +403,7 @@
A9BCB5882AE83F7E00DA8588 /* PatientListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatientListModel.swift; sourceTree = "<group>"; };
A9BCB58B2AE84E6D00DA8588 /* CurrentPatientLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentPatientLabel.swift; sourceTree = "<group>"; };
A9BCB58F2AE8588B00DA8588 /* NoInformationText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoInformationText.swift; sourceTree = "<group>"; };
A9C82F912B608756004703E0 /* ImpedanceMeasurement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImpedanceMeasurement.swift; sourceTree = "<group>"; };
A9C9B6B32ADE191100C8C46D /* EEGDeviceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EEGDeviceTests.swift; sourceTree = "<group>"; };
A9CE84502B1A9A14009CE3F4 /* DevicesSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevicesSheet.swift; sourceTree = "<group>"; };
A9D83F912B081A47000D0C78 /* BiopotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BiopotTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -426,6 +431,7 @@
A92E34F02ADB9B7E00FE0B51 /* OrderedCollections in Frameworks */,
2FE5DC7529EDD8E6004B9AB4 /* SpeziFirebaseAccount in Frameworks */,
2F49B7762980407C00BCB272 /* Spezi in Frameworks */,
A9C82F952B6089C8004703E0 /* BluetoothServices in Frameworks */,
2FE5DC8F29EDD980004B9AB4 /* SpeziViews in Frameworks */,
2FE5DC8129EDD91D004B9AB4 /* SpeziOnboarding in Frameworks */,
2FE5DC7929EDD8E6004B9AB4 /* SpeziFirestore in Frameworks */,
Expand Down Expand Up @@ -463,6 +469,7 @@
A988FEBF2B05C7B800022A61 /* SpeziPersonalInfo in Frameworks */,
A926D7B02AB7A552000C4C2F /* Spezi in Frameworks */,
A926D7B12AB7A552000C4C2F /* SpeziViews in Frameworks */,
A9C82F972B6089D2004703E0 /* BluetoothServices in Frameworks */,
A988FEA82B03FB5A00022A61 /* SpeziBluetooth in Frameworks */,
A926D7B42AB7A552000C4C2F /* SpeziOnboarding in Frameworks */,
A926D7B52AB7A552000C4C2F /* SpeziFirestore in Frameworks */,
Expand Down Expand Up @@ -768,6 +775,7 @@
A907DA382B195D4800FB69FB /* AccelerometerSample.swift */,
A907DA3B2B195ED800FB69FB /* EEGSample.swift */,
A907DA3E2B1964B500FB69FB /* ByteBuffer+Int24.swift */,
A9C82F912B608756004703E0 /* ImpedanceMeasurement.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -885,6 +893,7 @@
A92E34EF2ADB9B7E00FE0B51 /* OrderedCollections */,
A988FEBC2B05C7AE00022A61 /* SpeziPersonalInfo */,
A988FEA52B03FB4A00022A61 /* SpeziBluetooth */,
A9C82F942B6089C8004703E0 /* BluetoothServices */,
);
productName = NAMS;
productReference = 653A254D283387FE005D4D48 /* NAMS.app */;
Expand Down Expand Up @@ -960,6 +969,7 @@
A92E34F12ADB9B9000FE0B51 /* OrderedCollections */,
A988FEBE2B05C7B800022A61 /* SpeziPersonalInfo */,
A988FEA72B03FB5A00022A61 /* SpeziBluetooth */,
A9C82F962B6089D2004703E0 /* BluetoothServices */,
);
productName = NAMS;
productReference = A926D7C32AB7A552000C4C2F /* NAMS Muse.app */;
Expand Down Expand Up @@ -1115,6 +1125,7 @@
files = (
A907DA3C2B195ED800FB69FB /* EEGSample.swift in Sources */,
A94534002AEAE1110095AAD3 /* Questionnaire+NAMS.swift in Sources */,
A9C82F922B608756004703E0 /* ImpedanceMeasurement.swift in Sources */,
A926D8302AB7B430000C4C2F /* EEGViewModel.swift in Sources */,
A94A42AE2AE9EBE300A3F9E5 /* AccountSheet.swift in Sources */,
A926D7FF2AB7B41C000C4C2F /* IXNMuseModel+Description.swift in Sources */,
Expand Down Expand Up @@ -1288,6 +1299,7 @@
A926D7912AB7A552000C4C2F /* CodableArray+RawRepresentable.swift in Sources */,
A926D7922AB7A552000C4C2F /* FeatureFlags.swift in Sources */,
A988FEB62B0453E100022A61 /* DeviceInformation.swift in Sources */,
A9C82F932B60899B004703E0 /* ImpedanceMeasurement.swift in Sources */,
A9F2ECD12AEC5EF50057C7DD /* MeasurementTask.swift in Sources */,
A9BCB5832AE8307800DA8588 /* SearchToken.swift in Sources */,
A926D7932AB7A552000C4C2F /* Bundle+Image.swift in Sources */,
Expand Down Expand Up @@ -2235,7 +2247,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/SpeziBluetooth";
requirement = {
branch = "feature/client-model";
branch = "feature/unit-testing-setup";
kind = branch;
};
};
Expand Down Expand Up @@ -2387,6 +2399,16 @@
package = 2FE5DC8D29EDD980004B9AB4 /* XCRemoteSwiftPackageReference "SpeziViews" */;
productName = SpeziPersonalInfo;
};
A9C82F942B6089C8004703E0 /* BluetoothServices */ = {
isa = XCSwiftPackageProductDependency;
package = A988FEA42B03FB4A00022A61 /* XCRemoteSwiftPackageReference "SpeziBluetooth" */;
productName = BluetoothServices;
};
A9C82F962B6089D2004703E0 /* BluetoothServices */ = {
isa = XCSwiftPackageProductDependency;
package = A988FEA42B03FB4A00022A61 /* XCRemoteSwiftPackageReference "SpeziBluetooth" */;
productName = BluetoothServices;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 653A2545283387FE005D4D48 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziBluetooth",
"state" : {
"branch" : "feature/client-model",
"revision" : "6113cf3991665ef9ff1468c3f70c1291be8bec39"
"branch" : "feature/unit-testing-setup",
"revision" : "f9db62d3b53475b52cc6f56ed92242482dd4f72d"
}
},
{
Expand Down Expand Up @@ -194,8 +194,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziOnboarding.git",
"state" : {
"revision" : "3ee713576eaeaa03200ba26bbc1269ceeb6abb25",
"version" : "1.0.1"
"revision" : "8fb6d9f1a080661c0cc564a93b82ead3c8d44d4f",
"version" : "1.0.2"
}
},
{
Expand Down Expand Up @@ -248,8 +248,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c",
"version" : "2.62.0"
"revision" : "635b2589494c97e48c62514bc8b37ced762e0a62",
"version" : "2.63.0"
}
},
{
Expand All @@ -261,6 +261,15 @@
"version" : "1.25.2"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "025bcb1165deab2e20d4eaba79967ce73013f496",
"version" : "1.2.1"
}
},
{
"identity" : "xctestextensions",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 1 addition & 1 deletion NAMS/Account/AccountButton.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// This source file is part of the Stanford Spezi Template Application project
// This source file is part of the Neurodevelopment Assessment and Monitoring System (NAMS) project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
Expand Down
2 changes: 1 addition & 1 deletion NAMS/Account/AccountSetupHeader.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// This source file is part of the Stanford Spezi Template Application project
// This source file is part of the Neurodevelopment Assessment and Monitoring System (NAMS) project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
Expand Down
12 changes: 9 additions & 3 deletions NAMS/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// This source file is part of the Stanford Spezi Template Application project
// This source file is part of the Neurodevelopment Assessment and Monitoring System (NAMS) project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
Expand Down Expand Up @@ -72,11 +72,17 @@ struct AccountSheet: View {
.set(\.name, value: PersonNameComponents(givenName: "Leland", familyName: "Stanford"))

return AccountSheet()
.environment(Account(building: details, active: MockUserIdPasswordAccountService()))
.previewWith {
AccountConfiguration(building: details, active: MockUserIdPasswordAccountService())
}
}

#Preview {
AccountSheet()
.environment(Account(MockUserIdPasswordAccountService()))
.previewWith {
AccountConfiguration {
MockUserIdPasswordAccountService()
}
}
}
#endif
4 changes: 2 additions & 2 deletions NAMS/Bluetooth/BluetoothManager.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// This source file is part of the Stanford Spezi open-source project
// This source file is part of the Neurodevelopment Assessment and Monitoring System (NAMS) project
//
// SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//
Expand Down
68 changes: 56 additions & 12 deletions NAMS/Devices/BioPot/Biopot.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// This source file is part of the Stanford Spezi open-source project
// This source file is part of the Neurodevelopment Assessment and Monitoring System (NAMS) project
//
// SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//
Expand All @@ -21,18 +21,44 @@ struct Biopot: View {
@State private var viewState: ViewState = .idle

var body: some View {
ListRow("Nearby Devices") {
Text(verbatim: "\(bluetooth.nearbyDevices(for: BiopotDevice.self).count)")
let devices = bluetooth.nearbyDevices(for: BiopotDevice.self)

// TODO: We need some place to put our modifiers!

Check failure on line 26 in NAMS/Devices/BioPot/Biopot.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (We need some place to put our ...) (todo)
Section {
Text("Make sure your device is connected and nearby!")
.listRowBackground(Color.clear)
.listRowInsets(.init(top: 0, leading: 0.2, bottom: 0, trailing: 0.2))
.viewStateAlert(state: $viewState)
.scanNearbyDevices(with: bluetooth, autoConnect: true)
}
ListRow("Device") {
if let biopot {
Text(biopot.state.localizedStringResource)
} else {
Text("Scanning ...")

if devices.isEmpty {
VStack { // TODO: Reuse!

Check failure on line 36 in NAMS/Devices/BioPot/Biopot.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (Reuse!) (todo)
Text("Searching for nearby devices ...")
.foregroundColor(.secondary)
ProgressView()
}
.frame(maxWidth: .infinity)
.listRowBackground(Color.clear)
} else {
Section {
ForEach(devices) { device in
if let name = device.name {
ListRow(name) {
Text(device.state.localizedStringResource)
}
}
}
} header: {
HStack { // TODO: reuse!

Check failure on line 53 in NAMS/Devices/BioPot/Biopot.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (reuse!) (todo)
Text("Devices")
.padding(.trailing, 10)
if bluetooth.isScanning {
ProgressView()
}
}
}
}
.viewStateAlert(state: $viewState)
.scanNearbyDevices(with: bluetooth, autoConnect: true)

testingSupport

Expand All @@ -52,10 +78,25 @@ struct Biopot: View {
ListRow("Temperature") {
Text("\(info.temperatureValue) °C")
}
if let serialNumber = biopot.deviceInformation.serialNumber {
ListRow("Serial Number") {
Text(serialNumber)
}
}
if let firmwareVersion = biopot.deviceInformation.firmwareRevision {
ListRow("Firmware Version") {
Text(firmwareVersion)
}
}
if let hardwareVersion = biopot.deviceInformation.hardwareRevision {
ListRow("Hardware Version") {
Text(hardwareVersion)
}
}
}

actionButtons
} else {
} else if biopot != nil {
Section {
ProgressView()
.listRowBackground(Color.clear)
Expand Down Expand Up @@ -86,6 +127,9 @@ struct Biopot: View {

@MainActor @ViewBuilder private var actionButtons: some View {
Section("Actions") { // section of testing actions
AsyncButton("Query Device Information", state: $viewState) {
try await biopot?.deviceInformation.retrieveDeviceInformation()
}
AsyncButton("Read Device Configuration", state: $viewState) {
try await biopot?.service.$deviceInfo.read()
}
Expand Down
Loading

0 comments on commit a0b51d6

Please sign in to comment.