react-native-polar-bridge 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/PolarBridge.podspec
CHANGED
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
18
|
|
|
19
|
-
s.dependency 'PolarBleSdk', '~> 6.
|
|
19
|
+
s.dependency 'PolarBleSdk', '~> 6.14.0'
|
|
20
20
|
|
|
21
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/android/build.gradle
CHANGED
|
@@ -93,7 +93,7 @@ dependencies {
|
|
|
93
93
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
94
94
|
implementation 'io.reactivex.rxjava3:rxjava:3.1.11'
|
|
95
95
|
implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
|
|
96
|
-
implementation 'com.github.polarofficial:polar-ble-sdk:6.
|
|
96
|
+
implementation 'com.github.polarofficial:polar-ble-sdk:6.14.0'
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
react {
|
|
@@ -18,7 +18,7 @@ import io.reactivex.rxjava3.core.Single
|
|
|
18
18
|
import java.util.*
|
|
19
19
|
import java.util.concurrent.atomic.AtomicInteger
|
|
20
20
|
import java.util.concurrent.TimeUnit
|
|
21
|
-
import java.time
|
|
21
|
+
import java.time.*
|
|
22
22
|
|
|
23
23
|
@ReactModule(name = PolarBridgeModule.NAME)
|
|
24
24
|
class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
@@ -210,7 +210,9 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
210
210
|
)
|
|
211
211
|
|
|
212
212
|
val map: WritableMap = Arguments.createMap()
|
|
213
|
-
map.putDouble("recTimestamp", polarOfflineRecordingEntry.date
|
|
213
|
+
map.putDouble("recTimestamp", polarOfflineRecordingEntry.date
|
|
214
|
+
.toInstant(ZoneOffset.UTC)
|
|
215
|
+
.toEpochMilli().toDouble())
|
|
214
216
|
map.putString("path", polarOfflineRecordingEntry.path)
|
|
215
217
|
map.putDouble("size", polarOfflineRecordingEntry.size.toDouble())
|
|
216
218
|
array.pushMap(map)
|
|
@@ -373,10 +375,14 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
373
375
|
Log.d(TAG, "Recording ${polarOfflineRecordingEntry.path} downloaded. Size: ${polarOfflineRecordingEntry.size}")
|
|
374
376
|
when (it) {
|
|
375
377
|
is PolarOfflineRecordingData.HrOfflineRecording -> {
|
|
376
|
-
Log.d(TAG, "HR Offline Recording started at ${it.startTime
|
|
378
|
+
Log.d(TAG, "HR Offline Recording started at ${it.startTime
|
|
379
|
+
.toInstant(ZoneOffset.UTC)
|
|
380
|
+
.toEpochMilli()}")
|
|
377
381
|
var index = 0;
|
|
378
382
|
val intervalInMs = 1000; // 1Hz
|
|
379
|
-
val firstSampleDateUTC = it.startTime
|
|
383
|
+
val firstSampleDateUTC = it.startTime
|
|
384
|
+
.toInstant(ZoneOffset.UTC)
|
|
385
|
+
.toEpochMilli() + intervalInMs
|
|
380
386
|
for (sample in it.data.samples) {
|
|
381
387
|
val unixTimestamp = firstSampleDateUTC + intervalInMs * index++;
|
|
382
388
|
val timestamp = Instant.ofEpochMilli(unixTimestamp)
|
|
@@ -393,7 +399,8 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
393
399
|
}
|
|
394
400
|
}
|
|
395
401
|
is PolarOfflineRecordingData.AccOfflineRecording -> {
|
|
396
|
-
Log.d(TAG, "ACC Offline Recording started at ${it.startTime.
|
|
402
|
+
Log.d(TAG, "ACC Offline Recording started at ${it.startTime.toInstant(ZoneOffset.UTC)
|
|
403
|
+
.toEpochMilli()}")
|
|
397
404
|
var index = 0;
|
|
398
405
|
for (sample in it.data.samples) {
|
|
399
406
|
Log.d(TAG, "ACC data: time: ${sample.timeStamp} X: ${sample.x} Y: ${sample.y} Z: ${sample.z} entry ${++index} of ${it.data.samples.size}")
|
|
@@ -409,7 +416,8 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
409
416
|
}
|
|
410
417
|
}
|
|
411
418
|
is PolarOfflineRecordingData.GyroOfflineRecording -> {
|
|
412
|
-
Log.d(TAG, "GYRO Offline Recording started at ${it.startTime.
|
|
419
|
+
Log.d(TAG, "GYRO Offline Recording started at ${it.startTime.toInstant(ZoneOffset.UTC)
|
|
420
|
+
.toEpochMilli()}")
|
|
413
421
|
var index = 0;
|
|
414
422
|
for (sample in it.data.samples) {
|
|
415
423
|
Log.d(TAG, "GYRO data: ${sample.timeStamp} X: ${sample.x} Y: ${sample.y} Z: ${sample.z} entry ${++index} of ${it.data.samples.size}")
|
|
@@ -425,7 +433,8 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
425
433
|
}
|
|
426
434
|
}
|
|
427
435
|
is PolarOfflineRecordingData.PpgOfflineRecording -> {
|
|
428
|
-
Log.d(TAG, "PPG Offline Recording started at ${it.startTime.
|
|
436
|
+
Log.d(TAG, "PPG Offline Recording started at ${it.startTime.toInstant(ZoneOffset.UTC)
|
|
437
|
+
.toEpochMilli()}")
|
|
429
438
|
var index = 0;
|
|
430
439
|
for (sample in it.data.samples) {
|
|
431
440
|
Log.d(TAG, "PPG data: ${sample.timeStamp} ppg0 ${sample.channelSamples[0]} ppg1 ${sample.channelSamples[1]} ppg2 ${sample.channelSamples[2]} ambient ${sample.channelSamples[3]} entry ${++index} of ${it.data.samples.size}")
|
|
@@ -505,15 +514,14 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
505
514
|
|
|
506
515
|
// Sets the date time on the Polar device
|
|
507
516
|
override fun setDeviceTime(deviceId: String) {
|
|
508
|
-
val
|
|
509
|
-
|
|
510
|
-
Log.e(TAG, "Set device: $deviceId time to ${calendar.time}")
|
|
517
|
+
val now = LocalDateTime.now(ZoneOffset.UTC)
|
|
518
|
+
Log.e(TAG, "Set device: $deviceId time to ${now}")
|
|
511
519
|
try {
|
|
512
|
-
api.setLocalTime(deviceId,
|
|
520
|
+
api.setLocalTime(deviceId, now)
|
|
513
521
|
.observeOn(AndroidSchedulers.mainThread())
|
|
514
522
|
.subscribe(
|
|
515
523
|
{
|
|
516
|
-
val timeSetString = "time ${
|
|
524
|
+
val timeSetString = "time ${now} set to device"
|
|
517
525
|
Log.d(TAG, timeSetString)
|
|
518
526
|
},
|
|
519
527
|
{ error: Throwable -> Log.e(TAG, "set time failed: $error") }
|
|
@@ -529,13 +537,14 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
529
537
|
.observeOn(AndroidSchedulers.mainThread())
|
|
530
538
|
.subscribe(
|
|
531
539
|
{ calendar ->
|
|
532
|
-
val timeGetString = "${calendar
|
|
540
|
+
val timeGetString = "${calendar} read from the device"
|
|
533
541
|
|
|
534
542
|
val map: WritableMap = Arguments.createMap()
|
|
535
|
-
map.putString("time", "${calendar.
|
|
543
|
+
map.putString("time", "${calendar.toInstant(ZoneOffset.UTC)}")
|
|
536
544
|
// Long not supported, use double as workaround
|
|
537
545
|
// See: https://github.com/facebook/react-native/issues/9685
|
|
538
|
-
map.putDouble("timeMs", calendar.
|
|
546
|
+
map.putDouble("timeMs", calendar.toInstant(ZoneOffset.UTC)
|
|
547
|
+
.toEpochMilli().toDouble())
|
|
539
548
|
promise.resolve(map)
|
|
540
549
|
},
|
|
541
550
|
{ error: Throwable ->
|
|
@@ -567,9 +576,6 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
567
576
|
}
|
|
568
577
|
|
|
569
578
|
override fun doFactoryReset(deviceId: String) {
|
|
570
|
-
val calendar = Calendar.getInstance()
|
|
571
|
-
calendar.time = Date()
|
|
572
|
-
Log.e(TAG, "Set device: $deviceId time to ${calendar.time}")
|
|
573
579
|
try {
|
|
574
580
|
api.doFactoryReset(deviceId, preservePairingInformation = true)
|
|
575
581
|
.observeOn(AndroidSchedulers.mainThread())
|
package/ios/PolarBridge.swift
CHANGED
|
@@ -132,7 +132,7 @@ class PolarBridge: RCTEventEmitter, ObservableObject
|
|
|
132
132
|
let allSettings = api.requestFullStreamSettings(identifier, feature: feature)
|
|
133
133
|
.catch { error in
|
|
134
134
|
NSLog("Full stream settings NOT available for \(feature). Reason: \(error.localizedDescription)")
|
|
135
|
-
return Single.just(PolarSensorSetting([:]))
|
|
135
|
+
return Single.just(try PolarSensorSetting([:]))
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
return Single.zip(availableSettings, allSettings)
|