Skip to content

Commit

Permalink
Example apps updated to use PolarBleSdk version 5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuli Määttä committed Sep 28, 2023
1 parent 9a41f76 commit c0f3648
Show file tree
Hide file tree
Showing 38 changed files with 3,113 additions and 1,776 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
}

dependencies {
implementation 'com.github.polarofficial:polar-ble-sdk:5.1.0'
implementation 'com.github.polarofficial:polar-ble-sdk:5.4.0'
implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MainActivity : AppCompatActivity() {
}

// ATTENTION! Replace with the device ID from your device.
private var deviceId = "8C4E5023"
private var deviceId = "BC15022D"

private val api: PolarBleApi by lazy {
// Notice all features are enabled
Expand All @@ -48,7 +48,8 @@ class MainActivity : AppCompatActivity() {
PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_OFFLINE_RECORDING,
PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_ONLINE_STREAMING,
PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_DEVICE_TIME_SETUP,
PolarBleApi.PolarBleSdkFeature.FEATURE_DEVICE_INFO
PolarBleApi.PolarBleSdkFeature.FEATURE_DEVICE_INFO,
PolarBleApi.PolarBleSdkFeature.FEATURE_POLAR_LED_ANIMATION
)
)
}
Expand Down Expand Up @@ -95,6 +96,8 @@ class MainActivity : AppCompatActivity() {
private lateinit var getTimeButton: Button
private lateinit var toggleSdkModeButton: Button
private lateinit var getDiskSpaceButton: Button
private lateinit var changeLedAnimationStatusButton: Button
private lateinit var doFactoryResetButton: Button

//Verity Sense offline recording use
private lateinit var listRecordingsButton: Button
Expand Down Expand Up @@ -130,6 +133,9 @@ class MainActivity : AppCompatActivity() {
getTimeButton = findViewById(R.id.get_time)
toggleSdkModeButton = findViewById(R.id.toggle_SDK_mode)
getDiskSpaceButton = findViewById(R.id.get_disk_space)
changeLedAnimationStatusButton = findViewById(R.id.change_led_animation_status)
doFactoryResetButton = findViewById(R.id.do_factory_reset)

//Verity Sense recording buttons
listRecordingsButton = findViewById(R.id.list_recordings)
startRecordingButton = findViewById(R.id.start_recording)
Expand Down Expand Up @@ -858,6 +864,36 @@ class MainActivity : AppCompatActivity() {
)
}

var enableAnimation = false
changeLedAnimationStatusButton.setOnClickListener {
api.enableLedAnimation(deviceId, enableAnimation)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
Log.d(TAG, "ledAnimationEnabled set to $enableAnimation")
showToast("ledAnimationEnabled set to $enableAnimation")
changeLedAnimationStatusButton.text =
if (enableAnimation) getString(R.string.disable_led_animation) else getString(
R.string.enable_led_animation
)
enableAnimation = !enableAnimation
},
{ error: Throwable -> Log.e(TAG, "changeLedAnimationStatus failed: $error") }
)
}

doFactoryResetButton.setOnClickListener {
api.doFactoryReset(deviceId, preservePairingInformation = true)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
Log.d(TAG, "send do factory reset to device")
showToast("send do factory reset to device")
},
{ error: Throwable -> Log.e(TAG, "doFactoryReset() failed: $error") }
)
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
requestPermissions(arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT), PERMISSION_REQUEST_CODE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,17 @@
android:layout_height="wrap_content"
android:text="@string/delete_recording" />

<Button
android:id="@+id/change_led_animation_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/disable_led_animation" />

<Button
android:id="@+id/do_factory_reset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/do_factory_reset" />

</LinearLayout>
</ScrollView>
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@
<string name="download_recording">download one verity sense recording</string>
<string name="delete_recording">delete one verity sense recording</string>
<string name="get_disk_space">Get disk space</string>
<string name="enable_led_animation">Enable led animation</string>
<string name="disable_led_animation">Disable led animation</string>
<string name="do_factory_reset">Do factory reset</string>
</resources>
2 changes: 1 addition & 1 deletion examples/example-ios/iosBleSdkTestApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ platform :ios, '15.0'
use_frameworks!

target 'iosBleSdkTestApp' do
pod 'PolarBleSdk', '5.1.0'
pod 'PolarBleSdk', '5.4.0'
end
12 changes: 6 additions & 6 deletions examples/example-ios/iosBleSdkTestApp/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PODS:
- PolarBleSdk (5.1.0):
- PolarBleSdk (5.4.0):
- RxSwift (~> 6.5.0)
- SwiftProtobuf (~> 1.0)
- RxSwift (6.5.0)
- SwiftProtobuf (1.21.0)
- SwiftProtobuf (1.23.0)

DEPENDENCIES:
- PolarBleSdk (= 5.1.0)
- PolarBleSdk (= 5.4.0)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
Expand All @@ -15,10 +15,10 @@ SPEC REPOS:
- SwiftProtobuf

SPEC CHECKSUMS:
PolarBleSdk: 4ff4df5c3767b6c31673ada5537dc259278cc008
PolarBleSdk: 980933f58cb2856c3627f40a54c91b9351a07736
RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8
SwiftProtobuf: afced68785854575756db965e9da52bbf3dc45e7
SwiftProtobuf: b70d65f419fbfe61a2d58003456ca5da58e337d6

PODFILE CHECKSUM: 1751472de49b7355b8c3024af5c35fb40289ae27
PODFILE CHECKSUM: 8863ef757b09be0ef76e6c71a5f4ae7ede826a76

COCOAPODS: 1.12.0
12 changes: 6 additions & 6 deletions examples/example-ios/iosBleSdkTestApp/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c0f3648

Please sign in to comment.