Skip to content

Commit

Permalink
Provide similar mechnaism for health measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Jun 24, 2024
1 parent df765ba commit 02fd0c9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Sources/SpeziDevices/HealthMeasurements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import OSLog
import Spezi
import SpeziBluetooth
import SpeziBluetoothServices


/// Manage and process incoming health measurements.
Expand All @@ -27,7 +28,25 @@ public class HealthMeasurements { // TODO: code example?

required public init() {}

// TODO: rename!
public func configureReceivingMeasurements<Device: HealthDevice>(for device: Device, on service: WeightScaleService) {

Check warning on line 31 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package tvOS / Test using xcodebuild or run fastlane

Missing Docs Violation: public declarations should be documented (missing_docs)

Check warning on line 31 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package macOS / Test using xcodebuild or run fastlane

Missing Docs Violation: public declarations should be documented (missing_docs)

Check warning on line 31 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package iOS / Test using xcodebuild or run fastlane

Missing Docs Violation: public declarations should be documented (missing_docs)

Check warning on line 31 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package watchOS / Test using xcodebuild or run fastlane

Missing Docs Violation: public declarations should be documented (missing_docs)

Check warning on line 31 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package visionOS / Test using xcodebuild or run fastlane

Missing Docs Violation: public declarations should be documented (missing_docs)

Check warning on line 31 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / CodeQL / Test using xcodebuild or run fastlane

Missing Docs Violation: public declarations should be documented (missing_docs)
service.$weightMeasurement.onChange { [weak self, weak device, weak service] measurement in
guard let device, let service else {
return
}
self?.handleNewMeasurement(.weight(measurement, service.features ?? []), from: device)
}
}

public func configureReceivingMeasurements<Device: HealthDevice>(for device: Device, on service: BloodPressureService) {
service.$bloodPressureMeasurement.onChange { [weak self, weak device, weak service] measurement in
guard let device, let service else {
return
}
self?.handleNewMeasurement(.bloodPressure(measurement, service.features ?? []), from: device)
}
}

// TODO: rename! make private?

Check warning on line 49 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package watchOS / Test using xcodebuild or run fastlane

Todo Violation: TODOs should be resolved (rename! make private?) (todo)

Check warning on line 49 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package visionOS / Test using xcodebuild or run fastlane

Todo Violation: TODOs should be resolved (rename! make private?) (todo)

Check warning on line 49 in Sources/SpeziDevices/HealthMeasurements.swift

View workflow job for this annotation

GitHub Actions / CodeQL / Test using xcodebuild or run fastlane

Todo Violation: TODOs should be resolved (rename! make private?) (todo)
public func handleNewMeasurement<Device: HealthDevice>(_ measurement: BluetoothHealthMeasurement, from device: Device) {
let hkDevice = device.hkDevice

Expand Down

0 comments on commit 02fd0c9

Please sign in to comment.