Skip to content

Commit

Permalink
iOS Example: Made iOS example more user friendly. API usage is demons…
Browse files Browse the repository at this point in the history
…trated in PolarBleSdkManager.swift file.
  • Loading branch information
JOikarinen committed Jun 21, 2021
1 parent e0389ba commit 9d4b7c7
Show file tree
Hide file tree
Showing 10 changed files with 835 additions and 284 deletions.
8 changes: 1 addition & 7 deletions examples/example-ios/iosBleSdkTestApp/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Example project demonstrating usage of PolarBle SDK

# Dependencies
* [PolarBleSdk.xcframework](https://github.com/polarofficial/polar-ble-sdk/releases)
* [RxSwift 6.0](https://github.com/ReactiveX/RxSwift) or above

# Setup the example project

* Example project dependencies are already setup. Only setup your development team to build and test the capabilities of PolarBle SDK
* Example project demos multiple features found from PolarBleSDK library. To get most out of the example project you shall read the source code. The file `PolarBleSdkManager.swift` contains the interaction between the PolarBleSdk library and the example app. Other files in the example project are not relevant for the PolarBleSDK, those are for building the UI etc. While running the project you shall follow the console output to see results caused by the UI buttons.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
A4B37D34C263EBFC51C2D60B /* Pods_iosBleSdkTestApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20983D0AB4CED8600A47BC36 /* Pods_iosBleSdkTestApp.framework */; };
A50C368E267B162E00D9F150 /* ButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50C368D267B162E00D9F150 /* ButtonStyle.swift */; };
A50C3691267B271300D9F150 /* StreamSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50C3690267B271300D9F150 /* StreamSettings.swift */; };
A5367D1726676CB100CDDEBE /* Messages.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5367D1626676CB100CDDEBE /* Messages.swift */; };
A5776BA62663A28700A36BA5 /* iosBleSdkTestApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5776BA52663A28700A36BA5 /* iosBleSdkTestApp.swift */; };
A5776BA82663A28700A36BA5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5776BA72663A28700A36BA5 /* ContentView.swift */; };
Expand All @@ -16,6 +18,8 @@
A5776BB82663A28800A36BA5 /* iosBleSdkTestAppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5776BB72663A28800A36BA5 /* iosBleSdkTestAppTests.swift */; };
A5776BC32663A28800A36BA5 /* iosBleSdkTestAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5776BC22663A28800A36BA5 /* iosBleSdkTestAppUITests.swift */; };
A5776BD12663A58E00A36BA5 /* PolarBleSdkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5776BD02663A58E00A36BA5 /* PolarBleSdkManager.swift */; };
A58C85DF2679E45800F88DE7 /* UiHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58C85DE2679E45800F88DE7 /* UiHelper.swift */; };
A5D8E1922678CDCD0013464E /* StreamSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D8E1912678CDCD0013464E /* StreamSettingsView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -37,6 +41,8 @@

/* Begin PBXFileReference section */
20983D0AB4CED8600A47BC36 /* Pods_iosBleSdkTestApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosBleSdkTestApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A50C368D267B162E00D9F150 /* ButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonStyle.swift; sourceTree = "<group>"; };
A50C3690267B271300D9F150 /* StreamSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamSettings.swift; sourceTree = "<group>"; };
A5367D1626676CB100CDDEBE /* Messages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Messages.swift; sourceTree = "<group>"; };
A5776BA22663A28700A36BA5 /* iosBleSdkTestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosBleSdkTestApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
A5776BA52663A28700A36BA5 /* iosBleSdkTestApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosBleSdkTestApp.swift; sourceTree = "<group>"; };
Expand All @@ -51,6 +57,8 @@
A5776BC22663A28800A36BA5 /* iosBleSdkTestAppUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosBleSdkTestAppUITests.swift; sourceTree = "<group>"; };
A5776BC42663A28800A36BA5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A5776BD02663A58E00A36BA5 /* PolarBleSdkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolarBleSdkManager.swift; sourceTree = "<group>"; };
A58C85DE2679E45800F88DE7 /* UiHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UiHelper.swift; sourceTree = "<group>"; };
A5D8E1912678CDCD0013464E /* StreamSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamSettingsView.swift; sourceTree = "<group>"; };
B1DB285981A115801B3D58A6 /* Pods-iosBleSdkTestApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosBleSdkTestApp.debug.xcconfig"; path = "Target Support Files/Pods-iosBleSdkTestApp/Pods-iosBleSdkTestApp.debug.xcconfig"; sourceTree = "<group>"; };
DF07E3AF5F24477508A18851 /* Pods-iosBleSdkTestApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosBleSdkTestApp.release.xcconfig"; path = "Target Support Files/Pods-iosBleSdkTestApp/Pods-iosBleSdkTestApp.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -90,10 +98,21 @@
path = Pods;
sourceTree = "<group>";
};
A50C368C267B161400D9F150 /* Styles */ = {
isa = PBXGroup;
children = (
A50C368D267B162E00D9F150 /* ButtonStyle.swift */,
);
path = Styles;
sourceTree = "<group>";
};
A5367D1426676C7100CDDEBE /* Views */ = {
isa = PBXGroup;
children = (
A50C368C267B161400D9F150 /* Styles */,
A5776BA72663A28700A36BA5 /* ContentView.swift */,
A5D8E1912678CDCD0013464E /* StreamSettingsView.swift */,
A58C85DE2679E45800F88DE7 /* UiHelper.swift */,
);
path = Views;
sourceTree = "<group>";
Expand All @@ -102,6 +121,7 @@
isa = PBXGroup;
children = (
A5367D1626676CB100CDDEBE /* Messages.swift */,
A50C3690267B271300D9F150 /* StreamSettings.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -349,8 +369,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A5D8E1922678CDCD0013464E /* StreamSettingsView.swift in Sources */,
A5367D1726676CB100CDDEBE /* Messages.swift in Sources */,
A5776BA82663A28700A36BA5 /* ContentView.swift in Sources */,
A58C85DF2679E45800F88DE7 /* UiHelper.swift in Sources */,
A50C3691267B271300D9F150 /* StreamSettings.swift in Sources */,
A50C368E267B162E00D9F150 /* ButtonStyle.swift in Sources */,
A5776BD12663A58E00A36BA5 /* PolarBleSdkManager.swift in Sources */,
A5776BA62663A28700A36BA5 /* iosBleSdkTestApp.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Copyright © 2019 Polar Electro Oy. All rights reserved.
/// Copyright © 2021 Polar Electro Oy. All rights reserved.

import Foundation

struct ErrorMessage: Identifiable {
struct Message: Identifiable {
let id = UUID()
let text: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// Copyright © 2021 Polar Electro Oy. All rights reserved.

import Foundation
import PolarBleSdk

struct StreamSettings: Identifiable, Hashable {
let id = UUID()
let feature: DeviceStreamingFeature
var settings: [StreamSetting] = []
var sortedSettings: [StreamSetting] { return settings.sorted{ $0.type.rawValue < $1.type.rawValue }}
}

struct StreamSetting: Identifiable, Hashable {
let id = UUID()
let type: PolarSensorSetting.SettingType
var values: [Int] = []
var sortedValues: [Int] { return values.sorted(by:<)}
}
Loading

0 comments on commit 9d4b7c7

Please sign in to comment.