Skip to content

Commit

Permalink
Merge pull request #7 from Presage-Security/sync
Browse files Browse the repository at this point in the history
sync upto PR#43
  • Loading branch information
1-ashraful-islam committed Aug 23, 2024
2 parents 825b00c + f2b0e1d commit 3d74285
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 314 deletions.
66 changes: 45 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,41 +1,65 @@
Sample iOS App/Test SmartSpectra SDK/Config.swift
.DS_Store
.swiftpm/.DS_Store
.swiftpm/xcode/.DS_Store
Sample iOS App/.DS_Store
SDK/.DS_Store
SDK/.swiftpm/xcode/package.xcworkspace/xcuserdata/billvivino.xcuserdatad/UserInterfaceState.xcuserstate
Sample iOS App/Test SmartSpectra SDK.xcodeproj/project.xcworkspace/xcuserdata/billvivino.xcuserdatad/UserInterfaceState.xcuserstate
# Xcode .gitignore
# macOS generated files
**/.DS_Store
.AppleDouble
.LSOverride

# Xcode specific
# Compiled object files and app products
*.o
*.dylib
*.so
*.app
*.ipa
*.dSYM.zip
*.dSYM
*.lproj/
*.swiftdoc
*.swiftmodule

# Xcode files
# Xcode project files
xcuserdata/
project.xcworkspace/xcuserdata/
project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
*.xcworkspace
*.xcuserstate

# Derived data and build output
build/
DerivedData/
**/.build/

# Swift PM
.swiftpm/xcode/package.xcworkspace/xcuserdata/
.swiftpm/xcode/package.xcworkspace/xcshareddata/
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
*.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
.swiftpm

# OS generated files
.DS_Store
.AppleDouble
.LSOverride
# CocoaPods
# Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
*.xcworkspace

# Carthage
Carthage/Build/

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

# Thumbnails
._*
## Playgrounds
timeline.xctimeline
playground.xcworkspace
132 changes: 35 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ The app contained in this repo is an example of using the SmartSpectra SDK and s

The Swift Package Manager (SPM) is a tool for managing the distribution of Swift code. It automates the process of downloading, compiling, and linking dependencies.

To add SmartSpectra iOS SDK as a dependency to your Xcode project using SPM, follow either of these two sets of steps within Xcode:
To add SmartSpectra iOS SDK as a dependency to your Xcode project using SPM, follow either of these two sets of steps within Xcode:

- Method 1:
Go to File -> "Add Package Dependencies..."
In the "Search or Enter Package URL" field, enter the URL "https://github.com/Presage-Security/SmartSpectra-iOS-SDK"
For the "Dependency Rule," select "Branch" and then "main."
For "Add to Target," select your project.
For "Add to Target," select your project.


- Method 2: Open your project in Xcode. Select your project in the Project Navigator, then click on the project in the Project/Targets Pane. Go to the Package Dependencies Tab, then click the "+" button 
Expand All @@ -53,24 +53,33 @@ Please refer to [ContentView.swift](Test%20SmartSpectra%20SDK/ContentView.swift)
- Team: Your desired developer profile
- Bundle Identifier: Your desired bundle identifier such as: `com.johnsmith.smartspectratest`
- If you are not a registered developer for the App Store follow the prompt to navigate to Settings > General > VPN & Device Management, then select your developer App certificate to trust it on your iOS device.
### Integrating the SmartSpectra Button View and Adding API key

### Integrate the SmartSpectra Button View, add api key, and configure sdk parameters

You need to integrate the `SmartSpectraButtonView` into your app which is a button that allows the user to conduct a measurement and compute physiology metrics. Here's a simple example using SwiftUI:

Note you need to ender your API key string at `"YOUR_API_KEY_HERE"`
Note you need to ender your API key string at `"YOUR_API_KEY_HERE"`. Optionally, you can also configure spot duration, whether to show frame per second (fps) during screening the measurement in the user's device.

```swift
import SwiftUI
import SmartSpectraIosSDK

struct ContentView: View {
var body: some View {
SmartSpectraButtonView(apiKey: "YOUR_API_KEY_HERE")
}
SmartSpectraButtonView(apiKey: "YOUR_API_KEY_HERE")
.task {
// Configure sdk parameters
// valid range for spot duration is between 20.0 and 120.0
sdk.setSpotDuration(30.0)
sdk.setShowFps(false)
}
}
}
```

### Displaying Strict Breathing Rate and Pulse Rate Values
You can display the strict breathing rate and pulse rate which is the average of only the high confidence breathing rate and pulse rate values over the 30 second measurement by adding the following to your view:

```Swift
SmartSpectraSwiftUIView()
```
Expand All @@ -81,94 +90,25 @@ To extract metrics data from the SDK import the following into your content view
```
`SmartSpectraIosSDK.shared` has 13 observable objects:

- `sdk.strictPulseRate` - (Double) the strict pulse rate (high confidence average over 30 seconds)
- `sdk.strictBreathingRate` - (Double) the strict breathing rate (high confidence average over 30 seconds)
- `sdk.pulseValues` - [(time: Double, value: Double)] Pulse rates
- `sdk.pulseConfidence` - [(time: Double, value: Double)] Pulse rate confidences
- `sdk.pulsePleth` - [(time: Double, value: Double)] Pulse waveform or pleth
- `sdk.breathingValues` - [(time: Double, value: Double)] Breathing rates
- `sdk.breathingPleth` - [(time: Double, value: Double)] Breathing movement waveform or pleth
- `sdk.breathingAmplitude` - [(time: Double, value: Doube)] Breathing rate confidences
- `sdk.apnea` - [(time: Double, value: Double)] Apnea detection
- `sdk.breathingBaseline` - [(time: Double, value: Double)] Breathing baseline
- `sdk.phasic` - [(time: Double, value: Double)] Phasic (ie changes in relative blood pressure)
- `sdk.rrl` - [(time: Double, value: Double)] Respiratory line length
- `sdk.ie` - [(time: Double, value: Double)] The inhale exhale ratio
- `sdk.uploadDate` - (String) upload date time
- `sdk.version` - (String) the version of API used
- `sdk.userID` - (String) the user ID
- `sdk.jsonMetrics` - (Dictionary) containing the metrics available according to your api key. See Data Format below for the contents and structure. **Warning: json structure is subject to change use at your own risk.**

### Data Format
`sdk.jsonMetrics` is structured as follows:
```json
{
"error": "",
"version": "3.10.1",
"pulse": {
"hr":{
"10":{
"value": 58.9,
"confidence": 0.95,
},
"11":{
"value": 58.2,
"confidence": 0.94,
},
"12":{
"value": 58.1,
"confidence": 0.91,
},
},
"hr_trace":{
"0":{ "value": 0.5},
"0.033":{ "value": 0.56},
"0.066":{ "value": 0.59}
},
"hr_spec":{
"10":{ "value": [], "freq":[]},
"11":{ "value": [], "freq":[]},
"12":{ "value": [], "freq":[]}
},
"hrv":{},
},
"breath": {
"rr":{
"15":{
"value": 18.9,
"confidence": 0.95,
},
"16":{
"value": 18.2,
"confidence": 0.94,
},
"17":{
"value": 18.1,
"confidence": 0.91,
},
},
"rr_trace":{
"0":{ "value": 0.5},
"0.033":{ "value": 0.56},
"0.066":{ "value": 0.59}
},
"rr_spec":{
"15":{ "value": [], "freq":[]},
"16":{ "value": [], "freq":[]},
"17":{ "value": [], "freq":[]}
},
"rrl":{"0":{ "value": 0.5}},
"apnea":{"0":{ "value": false}},
"ie":{"0":{ "value": 1.5}},
"amplitude":{"0":{ "value": 0.5}},
"baseline":{"0":{ "value": 0.5}}
},
"pressure": {
"phasic":{"0":{ "value": 0.5}},
}
}
```

| Result Key | Value Type | Description |
|------------------------------|--------------------------------------------|------------------------------------------------------------------------|
| `sdk.strictPulseRate` | (Double) | The strict pulse rate (high confidence average over spot duration) |
| `sdk.strictBreathingRate` | (Double) | The strict breathing rate (high confidence average over spot duration) |
| `sdk.pulseValues` | [(time: Double, value: Double)] | Pulse rates |
| `sdk.pulseConfidence` | [(time: Double, value: Double)] | Pulse rate confidences |
| `sdk.pulsePleth` | [(time: Double, value: Double)] | Pulse waveform or pleth |
| `sdk.hrv` | [(time: Double, value: Double)] | Pulse rate variability (RMSSD) **(Requires 60+ second Spot Duration)** |
| `sdk.breathingValues` | [(time: Double, value: Double)] | Breathing rates |
| `sdk.breathingPleth` | [(time: Double, value: Double)] | Breathing movement waveform or pleth |
| `sdk.breathingAmplitude` | [(time: Double, value: Double)] | Breathing rate confidences |
| `sdk.apnea` | [(time: Double, value: Bool)] | Apnea detection |
| `sdk.breathingBaseline` | [(time: Double, value: Double)] | Breathing baseline |
| `sdk.phasic` | [(time: Double, value: Double)] | Phasic (ie changes in relative blood pressure) |
| `sdk.rrl` | [(time: Double, value: Double)] | Respiratory line length |
| `sdk.ie` | [(time: Double, value: Double)] | The inhale exhale ratio |
| `sdk.uploadDate` | (String) | upload date time |
| `sdk.version` | (String) | the version of API used |
| `sdk.userID` | (String) | the user ID |

## Device Orientation
We do not recommend landscape support. We recommend removing the "Landscape Left," "Landscape Right," and "Portrait Upside Down" modes from your supported interface orientations.
Expand All @@ -178,6 +118,4 @@ For additional support, contact support@presagetech.com or submit a github issue



## Known Bugs
- HRV is not returning.

[//]: # (## Known Bugs)
Loading

0 comments on commit 3d74285

Please sign in to comment.