react-native-polar-bridge 0.1.4 → 0.1.5
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/README.md +21 -1
- package/android/generated/java/com/polarbridge/NativePolarBridgeSpec.java +9 -1
- package/android/generated/jni/RNPolarBridgeSpec-generated.cpp +13 -1
- package/android/generated/jni/react/renderer/components/RNPolarBridgeSpec/RNPolarBridgeSpecJSI-generated.cpp +17 -2
- package/android/generated/jni/react/renderer/components/RNPolarBridgeSpec/RNPolarBridgeSpecJSI.h +21 -3
- package/android/src/main/java/com/polarbridge/PolarBridgeModule.kt +269 -78
- package/ios/generated/RNPolarBridgeSpec/RNPolarBridgeSpec-generated.mm +15 -1
- package/ios/generated/RNPolarBridgeSpec/RNPolarBridgeSpec.h +11 -1
- package/ios/generated/RNPolarBridgeSpecJSI-generated.cpp +17 -2
- package/ios/generated/RNPolarBridgeSpecJSI.h +21 -3
- package/lib/module/NativePolarBridge.ts +4 -2
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativePolarBridge.d.ts +4 -2
- package/lib/typescript/src/NativePolarBridge.d.ts.map +1 -1
- package/lib/typescript/src/PolarDataModel.d.ts +4 -0
- package/lib/typescript/src/PolarDataModel.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/NativePolarBridge.ts +4 -2
- package/src/PolarDataModel.tsx +5 -0
- package/src/index.tsx +8 -0
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ export default function App(){
|
|
|
25
25
|
|
|
26
26
|
// ...
|
|
27
27
|
|
|
28
|
-
connectToDevice(deviceId)
|
|
28
|
+
connectToDevice(deviceId).then((device: DeviceConnected) =>{
|
|
29
|
+
console.log(`Connected Polar Device: ${device.connectedDeviceId} Battery Level: ${device.batteryLevel}%`);
|
|
30
|
+
});
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
```
|
|
@@ -159,6 +161,24 @@ const ppgListener = polarEmitter.addListener(emittedEventId.POLAR_PPG_DATA, (dat
|
|
|
159
161
|
> ppgListener.remove();
|
|
160
162
|
> ```
|
|
161
163
|
|
|
164
|
+
### Offline Recording
|
|
165
|
+
|
|
166
|
+
Start Offline Recording
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
startOfflineRecording(connectedDeviceId, offlineRecordingFeatureList).then((data) =>{
|
|
170
|
+
console.log('Polar Start Offline Recording', `Result: ${data.result}`);
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Stop Offline Recording
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
stopOfflineRecording(connectedDeviceId, offlineRecordingFeatureList).then((data) =>{
|
|
178
|
+
console.log('Polar Stop Offline Recording', `Result: ${data.result}`);
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
162
182
|
### Offline Recording Trigger
|
|
163
183
|
|
|
164
184
|
Offline recording can be initiated with `PolarBleApi.startOfflineRecording()`. With recording trigger, we can configure the Polar device to start the recording either on exercise start with `TRIGGER_EXERCISE_START` or when the Polar device has been turned on with `TRIGGER_SYSTEM_START`.
|
|
@@ -39,7 +39,7 @@ public abstract class NativePolarBridgeSpec extends ReactContextBaseJavaModule i
|
|
|
39
39
|
|
|
40
40
|
@ReactMethod
|
|
41
41
|
@DoNotStrip
|
|
42
|
-
public abstract void connectToDevice(String deviceId);
|
|
42
|
+
public abstract void connectToDevice(String deviceId, Promise promise);
|
|
43
43
|
|
|
44
44
|
@ReactMethod
|
|
45
45
|
@DoNotStrip
|
|
@@ -81,6 +81,14 @@ public abstract class NativePolarBridgeSpec extends ReactContextBaseJavaModule i
|
|
|
81
81
|
@DoNotStrip
|
|
82
82
|
public abstract void getDiskSpace(String deviceId, Promise promise);
|
|
83
83
|
|
|
84
|
+
@ReactMethod
|
|
85
|
+
@DoNotStrip
|
|
86
|
+
public abstract void startOfflineRecording(String deviceId, ReadableArray features, Promise promise);
|
|
87
|
+
|
|
88
|
+
@ReactMethod
|
|
89
|
+
@DoNotStrip
|
|
90
|
+
public abstract void stopOfflineRecording(String deviceId, ReadableArray features, Promise promise);
|
|
91
|
+
|
|
84
92
|
@ReactMethod
|
|
85
93
|
@DoNotStrip
|
|
86
94
|
public abstract void setPolarRecordingTrigger(String deviceId, double recordingMode, ReadableArray features);
|
|
@@ -19,7 +19,7 @@ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_multiply(fac
|
|
|
19
19
|
|
|
20
20
|
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_connectToDevice(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
21
|
static jmethodID cachedMethodId = nullptr;
|
|
22
|
-
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt,
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "connectToDevice", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_disconnectFromDevice(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
@@ -72,6 +72,16 @@ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_getDiskSpace
|
|
|
72
72
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getDiskSpace", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_startOfflineRecording(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
76
|
+
static jmethodID cachedMethodId = nullptr;
|
|
77
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "startOfflineRecording", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_stopOfflineRecording(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
81
|
+
static jmethodID cachedMethodId = nullptr;
|
|
82
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "stopOfflineRecording", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_setPolarRecordingTrigger(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
76
86
|
static jmethodID cachedMethodId = nullptr;
|
|
77
87
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "setPolarRecordingTrigger", "(Ljava/lang/String;DLcom/facebook/react/bridge/ReadableArray;)V", args, count, cachedMethodId);
|
|
@@ -131,6 +141,8 @@ NativePolarBridgeSpecJSI::NativePolarBridgeSpecJSI(const JavaTurboModule::InitPa
|
|
|
131
141
|
methodMap_["getDeviceTime"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_getDeviceTime};
|
|
132
142
|
methodMap_["setDeviceTime"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_setDeviceTime};
|
|
133
143
|
methodMap_["getDiskSpace"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_getDiskSpace};
|
|
144
|
+
methodMap_["startOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeSpecJSI_startOfflineRecording};
|
|
145
|
+
methodMap_["stopOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeSpecJSI_stopOfflineRecording};
|
|
134
146
|
methodMap_["setPolarRecordingTrigger"] = MethodMetadata {3, __hostFunction_NativePolarBridgeSpecJSI_setPolarRecordingTrigger};
|
|
135
147
|
methodMap_["fetchOfflineRecordings"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_fetchOfflineRecordings};
|
|
136
148
|
methodMap_["downloadOfflineRecordings"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_downloadOfflineRecordings};
|
|
@@ -19,11 +19,10 @@ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_multiply(jsi::Runti
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_connectToDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
|
-
static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->connectToDevice(
|
|
22
|
+
return static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->connectToDevice(
|
|
23
23
|
rt,
|
|
24
24
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
25
25
|
);
|
|
26
|
-
return jsi::Value::undefined();
|
|
27
26
|
}
|
|
28
27
|
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_disconnectFromDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
29
28
|
static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->disconnectFromDevice(
|
|
@@ -93,6 +92,20 @@ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_getDiskSpace(jsi::R
|
|
|
93
92
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
94
93
|
);
|
|
95
94
|
}
|
|
95
|
+
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_startOfflineRecording(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
96
|
+
return static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->startOfflineRecording(
|
|
97
|
+
rt,
|
|
98
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
99
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_stopOfflineRecording(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
103
|
+
return static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->stopOfflineRecording(
|
|
104
|
+
rt,
|
|
105
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
106
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
96
109
|
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_setPolarRecordingTrigger(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
97
110
|
static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->setPolarRecordingTrigger(
|
|
98
111
|
rt,
|
|
@@ -167,6 +180,8 @@ NativePolarBridgeCxxSpecJSI::NativePolarBridgeCxxSpecJSI(std::shared_ptr<CallInv
|
|
|
167
180
|
methodMap_["getDeviceTime"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_getDeviceTime};
|
|
168
181
|
methodMap_["setDeviceTime"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_setDeviceTime};
|
|
169
182
|
methodMap_["getDiskSpace"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_getDiskSpace};
|
|
183
|
+
methodMap_["startOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeCxxSpecJSI_startOfflineRecording};
|
|
184
|
+
methodMap_["stopOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeCxxSpecJSI_stopOfflineRecording};
|
|
170
185
|
methodMap_["setPolarRecordingTrigger"] = MethodMetadata {3, __hostFunction_NativePolarBridgeCxxSpecJSI_setPolarRecordingTrigger};
|
|
171
186
|
methodMap_["fetchOfflineRecordings"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_fetchOfflineRecordings};
|
|
172
187
|
methodMap_["downloadOfflineRecordings"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_downloadOfflineRecordings};
|
package/android/generated/jni/react/renderer/components/RNPolarBridgeSpec/RNPolarBridgeSpecJSI.h
CHANGED
|
@@ -21,7 +21,7 @@ protected:
|
|
|
21
21
|
|
|
22
22
|
public:
|
|
23
23
|
virtual double multiply(jsi::Runtime &rt, double a, double b) = 0;
|
|
24
|
-
virtual
|
|
24
|
+
virtual jsi::Value connectToDevice(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
25
25
|
virtual void disconnectFromDevice(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
26
26
|
virtual void fetchHrData(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
27
27
|
virtual void fetchAccData(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
@@ -32,6 +32,8 @@ public:
|
|
|
32
32
|
virtual jsi::Value getDeviceTime(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
33
33
|
virtual void setDeviceTime(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
34
34
|
virtual jsi::Value getDiskSpace(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
35
|
+
virtual jsi::Value startOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) = 0;
|
|
36
|
+
virtual jsi::Value stopOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) = 0;
|
|
35
37
|
virtual void setPolarRecordingTrigger(jsi::Runtime &rt, jsi::String deviceId, double recordingMode, jsi::Array features) = 0;
|
|
36
38
|
virtual jsi::Value fetchOfflineRecordings(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
37
39
|
virtual void downloadOfflineRecordings(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
@@ -79,12 +81,12 @@ private:
|
|
|
79
81
|
return bridging::callFromJs<double>(
|
|
80
82
|
rt, &T::multiply, jsInvoker_, instance_, std::move(a), std::move(b));
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
jsi::Value connectToDevice(jsi::Runtime &rt, jsi::String deviceId) override {
|
|
83
85
|
static_assert(
|
|
84
86
|
bridging::getParameterCount(&T::connectToDevice) == 2,
|
|
85
87
|
"Expected connectToDevice(...) to have 2 parameters");
|
|
86
88
|
|
|
87
|
-
return bridging::callFromJs<
|
|
89
|
+
return bridging::callFromJs<jsi::Value>(
|
|
88
90
|
rt, &T::connectToDevice, jsInvoker_, instance_, std::move(deviceId));
|
|
89
91
|
}
|
|
90
92
|
void disconnectFromDevice(jsi::Runtime &rt, jsi::String deviceId) override {
|
|
@@ -167,6 +169,22 @@ private:
|
|
|
167
169
|
return bridging::callFromJs<jsi::Value>(
|
|
168
170
|
rt, &T::getDiskSpace, jsInvoker_, instance_, std::move(deviceId));
|
|
169
171
|
}
|
|
172
|
+
jsi::Value startOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) override {
|
|
173
|
+
static_assert(
|
|
174
|
+
bridging::getParameterCount(&T::startOfflineRecording) == 3,
|
|
175
|
+
"Expected startOfflineRecording(...) to have 3 parameters");
|
|
176
|
+
|
|
177
|
+
return bridging::callFromJs<jsi::Value>(
|
|
178
|
+
rt, &T::startOfflineRecording, jsInvoker_, instance_, std::move(deviceId), std::move(features));
|
|
179
|
+
}
|
|
180
|
+
jsi::Value stopOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) override {
|
|
181
|
+
static_assert(
|
|
182
|
+
bridging::getParameterCount(&T::stopOfflineRecording) == 3,
|
|
183
|
+
"Expected stopOfflineRecording(...) to have 3 parameters");
|
|
184
|
+
|
|
185
|
+
return bridging::callFromJs<jsi::Value>(
|
|
186
|
+
rt, &T::stopOfflineRecording, jsInvoker_, instance_, std::move(deviceId), std::move(features));
|
|
187
|
+
}
|
|
170
188
|
void setPolarRecordingTrigger(jsi::Runtime &rt, jsi::String deviceId, double recordingMode, jsi::Array features) override {
|
|
171
189
|
static_assert(
|
|
172
190
|
bridging::getParameterCount(&T::setPolarRecordingTrigger) == 4,
|
|
@@ -61,11 +61,16 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
61
61
|
)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
override fun connectToDevice(deviceId: String) {
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
override fun connectToDevice(deviceId: String, promise: Promise) {
|
|
65
|
+
val map: WritableMap = Arguments.createMap()
|
|
66
|
+
var deviceConnected = false
|
|
67
|
+
var batteryReceived = false
|
|
68
|
+
api.setApiCallback(object : PolarBleApiCallback() {
|
|
67
69
|
override fun deviceConnected(polarDeviceInfo: PolarDeviceInfo) {
|
|
68
70
|
Log.d("Polar", "Connected: ${polarDeviceInfo.deviceId}")
|
|
71
|
+
map.putString("connectedDeviceId", polarDeviceInfo.deviceId)
|
|
72
|
+
deviceConnected = true
|
|
73
|
+
runResolve()
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
override fun disInformationReceived(identifier: String, disInfo: DisInfo) {
|
|
@@ -81,13 +86,23 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
81
86
|
|
|
82
87
|
override fun batteryLevelReceived(identifier: String, level: Int) {
|
|
83
88
|
Log.d("Polar", "Battery for $identifier: $level%")
|
|
89
|
+
map.putInt("batteryLevel", level)
|
|
90
|
+
batteryReceived = true
|
|
91
|
+
runResolve()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private fun runResolve() {
|
|
95
|
+
if (deviceConnected && batteryReceived) {
|
|
96
|
+
promise.resolve(map)
|
|
97
|
+
}
|
|
84
98
|
}
|
|
85
99
|
})
|
|
86
100
|
Log.e(TAG, "Connect device: $deviceId ")
|
|
87
101
|
try {
|
|
88
102
|
api.connectToDevice(deviceId)
|
|
89
|
-
} catch(polarInvalidArgument: PolarInvalidArgument){
|
|
103
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
90
104
|
Log.e(TAG, "Failed to connect to device. Reason $polarInvalidArgument ")
|
|
105
|
+
promise.reject("INVALID_ARGUMENT", "Invalid device ID", polarInvalidArgument)
|
|
91
106
|
}
|
|
92
107
|
}
|
|
93
108
|
|
|
@@ -95,7 +110,7 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
95
110
|
Log.e(TAG, "Disconnect device: $deviceId ")
|
|
96
111
|
try {
|
|
97
112
|
api.disconnectFromDevice(deviceId)
|
|
98
|
-
} catch(polarInvalidArgument: PolarInvalidArgument){
|
|
113
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
99
114
|
Log.e(TAG, "Failed to disconnect from device. Reason $polarInvalidArgument ")
|
|
100
115
|
}
|
|
101
116
|
}
|
|
@@ -107,7 +122,7 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
107
122
|
// but client is not informed. This is workaround for the bug.
|
|
108
123
|
disposeAllStreams()
|
|
109
124
|
api.enableSDKMode(deviceId)
|
|
110
|
-
} catch(polarInvalidArgument: PolarInvalidArgument){
|
|
125
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
111
126
|
Log.e(TAG, "Failed to enable SDK mode on device. Reason $polarInvalidArgument ")
|
|
112
127
|
}
|
|
113
128
|
}
|
|
@@ -116,7 +131,7 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
116
131
|
Log.e(TAG, "Disable SDK Mode device: $deviceId ")
|
|
117
132
|
try {
|
|
118
133
|
api.disableSDKMode(deviceId)
|
|
119
|
-
} catch(polarInvalidArgument: PolarInvalidArgument){
|
|
134
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
120
135
|
Log.e(TAG, "Failed to disable SDK mode on device. Reason $polarInvalidArgument ")
|
|
121
136
|
}
|
|
122
137
|
}
|
|
@@ -142,76 +157,10 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
142
157
|
else -> PolarOfflineRecordingTriggerMode.TRIGGER_DISABLED
|
|
143
158
|
}
|
|
144
159
|
|
|
145
|
-
val featureList = features.let {
|
|
146
|
-
List(it.size()) { index -> it.getString(index).orEmpty() }
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Check for Offline Recording features configured featureList and
|
|
150
|
-
// add the config for OfflineRecordingTrigger when present in featureList
|
|
151
|
-
val triggerFeatures = mutableMapOf<PolarBleApi.PolarDeviceDataType, PolarSensorSetting?>()
|
|
152
|
-
for (feature in featureList) {
|
|
153
|
-
when(feature) {
|
|
154
|
-
"OfflineHR" -> {
|
|
155
|
-
Log.d(TAG, "Configuring OfflineHR settings")
|
|
156
|
-
triggerFeatures[PolarBleApi.PolarDeviceDataType.HR] = null // Default Heart Rate settings on Polar Sense
|
|
157
|
-
}
|
|
158
|
-
"OfflineACC" -> {
|
|
159
|
-
Log.d(TAG, "Configuring OfflineACC settings")
|
|
160
|
-
triggerFeatures[PolarBleApi.PolarDeviceDataType.ACC] = PolarSensorSetting( // Default Accelerometer settings on Polar Sense
|
|
161
|
-
mapOf(
|
|
162
|
-
PolarSensorSetting.SettingType.SAMPLE_RATE to 52,
|
|
163
|
-
PolarSensorSetting.SettingType.RESOLUTION to 16,
|
|
164
|
-
PolarSensorSetting.SettingType.RANGE to 8,
|
|
165
|
-
PolarSensorSetting.SettingType.CHANNELS to 3
|
|
166
|
-
)
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
|
-
"OfflineGYR" -> {
|
|
170
|
-
Log.d(TAG, "Configuring OfflineGYR settings")
|
|
171
|
-
triggerFeatures[PolarBleApi.PolarDeviceDataType.GYRO] = PolarSensorSetting( // Default Gyro settings on Polar Sense
|
|
172
|
-
mapOf(
|
|
173
|
-
PolarSensorSetting.SettingType.SAMPLE_RATE to 52,
|
|
174
|
-
PolarSensorSetting.SettingType.RESOLUTION to 16,
|
|
175
|
-
PolarSensorSetting.SettingType.RANGE to 2000,
|
|
176
|
-
PolarSensorSetting.SettingType.CHANNELS to 3
|
|
177
|
-
)
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
"OfflinePPG" -> {
|
|
181
|
-
Log.d(TAG, "Configuring OfflinePPG settings")
|
|
182
|
-
triggerFeatures[PolarBleApi.PolarDeviceDataType.PPG] = PolarSensorSetting( // Default PPG settings on Polar Sense
|
|
183
|
-
mapOf(
|
|
184
|
-
PolarSensorSetting.SettingType.SAMPLE_RATE to 55,
|
|
185
|
-
PolarSensorSetting.SettingType.RESOLUTION to 22,
|
|
186
|
-
PolarSensorSetting.SettingType.CHANNELS to 4
|
|
187
|
-
)
|
|
188
|
-
)
|
|
189
|
-
}
|
|
190
|
-
"OfflineMAG" -> {
|
|
191
|
-
Log.d(TAG, "Configuring OfflineMAG settings")
|
|
192
|
-
triggerFeatures[PolarBleApi.PolarDeviceDataType.MAGNETOMETER] = PolarSensorSetting( // Default MAGNETOMETER settings on Polar Sense
|
|
193
|
-
mapOf(
|
|
194
|
-
PolarSensorSetting.SettingType.SAMPLE_RATE to 10,
|
|
195
|
-
PolarSensorSetting.SettingType.RESOLUTION to 16,
|
|
196
|
-
PolarSensorSetting.SettingType.RANGE to 50,
|
|
197
|
-
PolarSensorSetting.SettingType.CHANNELS to 3
|
|
198
|
-
)
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
"OfflinePPI" -> {
|
|
202
|
-
Log.d(TAG, "Configuring OfflinePPI settings")
|
|
203
|
-
triggerFeatures[PolarBleApi.PolarDeviceDataType.PPI] = null
|
|
204
|
-
}
|
|
205
|
-
else -> {
|
|
206
|
-
Log.d(TAG, "No matching offline features found in featureList: $featureList")
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
160
|
try {
|
|
212
161
|
val triggerSettings = PolarOfflineRecordingTrigger(
|
|
213
162
|
triggerMode = recordingTrigger,
|
|
214
|
-
triggerFeatures =
|
|
163
|
+
triggerFeatures = buildTriggerFeatures(features),
|
|
215
164
|
)
|
|
216
165
|
|
|
217
166
|
// Secret Key is optional, can be implemented if needed, currently set to null
|
|
@@ -241,19 +190,22 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
241
190
|
Log.e("PolarTrigger", "Error fetching trigger: ${error.localizedMessage}", error)
|
|
242
191
|
}
|
|
243
192
|
)
|
|
244
|
-
} catch(polarInvalidArgument: PolarInvalidArgument){
|
|
193
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
245
194
|
Log.e(TAG, "Failed to set Offline Recording Trigger on device. Reason $polarInvalidArgument ")
|
|
246
195
|
}
|
|
247
196
|
}
|
|
248
197
|
|
|
249
|
-
override fun fetchOfflineRecordings(deviceId: String, promise: Promise){
|
|
198
|
+
override fun fetchOfflineRecordings(deviceId: String, promise: Promise) {
|
|
250
199
|
try {
|
|
251
200
|
val array: WritableArray = Arguments.createArray()
|
|
252
201
|
api.listOfflineRecordings(deviceId)
|
|
253
202
|
.observeOn(AndroidSchedulers.mainThread())
|
|
254
203
|
.subscribe(
|
|
255
204
|
{ polarOfflineRecordingEntry: PolarOfflineRecordingEntry ->
|
|
256
|
-
Log.d(
|
|
205
|
+
Log.d(
|
|
206
|
+
TAG,
|
|
207
|
+
"next: ${polarOfflineRecordingEntry.date} path: ${polarOfflineRecordingEntry.path}, size: ${polarOfflineRecordingEntry.size}"
|
|
208
|
+
)
|
|
257
209
|
|
|
258
210
|
val map: WritableMap = Arguments.createMap()
|
|
259
211
|
map.putDouble("recTimestamp", polarOfflineRecordingEntry.date.time.toDouble())
|
|
@@ -270,12 +222,139 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
270
222
|
promise.resolve(array)
|
|
271
223
|
}
|
|
272
224
|
)
|
|
273
|
-
} catch(polarInvalidArgument: PolarInvalidArgument){
|
|
225
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
274
226
|
Log.e(TAG, "Failed to fetch offline recordings. Reason $polarInvalidArgument ")
|
|
275
227
|
promise.reject("INVALID_ARGUMENT", "Invalid device ID", polarInvalidArgument)
|
|
276
228
|
}
|
|
277
229
|
}
|
|
278
230
|
|
|
231
|
+
override fun startOfflineRecording(deviceId: String, features: ReadableArray, promise: Promise) {
|
|
232
|
+
// Convert ReadableArray to List<String>
|
|
233
|
+
val featureList = List(features.size()) { index -> features.getString(index).orEmpty() }
|
|
234
|
+
val polarSensorSettings = buildTriggerFeatures(features);
|
|
235
|
+
try {
|
|
236
|
+
for (feature in featureList) {
|
|
237
|
+
when (feature) {
|
|
238
|
+
"OfflineHR" -> {
|
|
239
|
+
Log.d(TAG, "Start OfflineHR Recording")
|
|
240
|
+
startPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.HR,
|
|
241
|
+
polarSensorSettings[PolarBleApi.PolarDeviceDataType.HR], promise)
|
|
242
|
+
}
|
|
243
|
+
"OfflineACC" -> {
|
|
244
|
+
Log.d(TAG, "Start OfflineACC Recording")
|
|
245
|
+
startPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.ACC,
|
|
246
|
+
polarSensorSettings[PolarBleApi.PolarDeviceDataType.ACC], promise)
|
|
247
|
+
}
|
|
248
|
+
"OfflineGYR" -> {
|
|
249
|
+
Log.d(TAG, "Start OfflineGYR Recording")
|
|
250
|
+
startPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.GYRO,
|
|
251
|
+
polarSensorSettings[PolarBleApi.PolarDeviceDataType.GYRO], promise)
|
|
252
|
+
}
|
|
253
|
+
"OfflinePPG" -> {
|
|
254
|
+
Log.d(TAG, "Start OfflinePPG Recording")
|
|
255
|
+
startPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.PPG,
|
|
256
|
+
polarSensorSettings[PolarBleApi.PolarDeviceDataType.PPG], promise)
|
|
257
|
+
}
|
|
258
|
+
"OfflineMAG" -> {
|
|
259
|
+
Log.d(TAG, "Start OfflineMAG Recording")
|
|
260
|
+
startPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.MAGNETOMETER,
|
|
261
|
+
polarSensorSettings[PolarBleApi.PolarDeviceDataType.MAGNETOMETER], promise)
|
|
262
|
+
}
|
|
263
|
+
"OfflinePPI" -> {
|
|
264
|
+
Log.d(TAG, "Start OfflinePPI Recording")
|
|
265
|
+
startPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.PPI,
|
|
266
|
+
polarSensorSettings[PolarBleApi.PolarDeviceDataType.PPI], promise)
|
|
267
|
+
}
|
|
268
|
+
else -> {
|
|
269
|
+
Log.d(TAG, "Unknown feature: $feature")
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
274
|
+
Log.e(TAG, "Failed to start offline recording. Reason $polarInvalidArgument ")
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
override fun stopOfflineRecording(deviceId: String, features: ReadableArray, promise: Promise) {
|
|
279
|
+
// Convert ReadableArray to List<String>
|
|
280
|
+
val featureList = List(features.size()) { index -> features.getString(index).orEmpty() }
|
|
281
|
+
try {
|
|
282
|
+
for (feature in featureList) {
|
|
283
|
+
when (feature) {
|
|
284
|
+
"OfflineHR" -> {
|
|
285
|
+
Log.d(TAG, "STOP OfflineHR Recording")
|
|
286
|
+
stopPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.HR, promise)
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
"OfflineACC" -> {
|
|
290
|
+
Log.d(TAG, "STOP OfflineACC Recording")
|
|
291
|
+
stopPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.ACC, promise)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
"OfflineGYR" -> {
|
|
295
|
+
Log.d(TAG, "STOP OfflineGYR Recording")
|
|
296
|
+
stopPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.GYRO, promise)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
"OfflinePPG" -> {
|
|
300
|
+
Log.d(TAG, "STOP OfflineGYR Recording")
|
|
301
|
+
stopPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.PPG, promise)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
"OfflineMAG" -> {
|
|
305
|
+
Log.d(TAG, "STOP OfflineMAG Recording")
|
|
306
|
+
stopPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.MAGNETOMETER, promise)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
"OfflinePPI" -> {
|
|
310
|
+
Log.d(TAG, "STOP OfflinePPI Recording")
|
|
311
|
+
stopPolarOfflineRecording(deviceId, PolarBleApi.PolarDeviceDataType.PPI, promise)
|
|
312
|
+
}
|
|
313
|
+
else -> {
|
|
314
|
+
Log.d(TAG, "Unknown feature: $feature")
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
} catch (polarInvalidArgument: PolarInvalidArgument) {
|
|
319
|
+
Log.e(TAG, "Failed to stop offline recording. Reason $polarInvalidArgument ")
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private fun startPolarOfflineRecording(deviceId: String, recordingDataType: PolarBleApi.PolarDeviceDataType,
|
|
324
|
+
sensorSetting: PolarSensorSetting?,
|
|
325
|
+
promise: Promise){
|
|
326
|
+
val map: WritableMap = Arguments.createMap()
|
|
327
|
+
api.startOfflineRecording(deviceId, recordingDataType, sensorSetting, recordingKey)
|
|
328
|
+
.subscribe(
|
|
329
|
+
{
|
|
330
|
+
Log.d(TAG, "START offline ${recordingDataType} recording completed")
|
|
331
|
+
map.putString("result", "completed");
|
|
332
|
+
promise.resolve(map)
|
|
333
|
+
},
|
|
334
|
+
{ throwable: Throwable ->
|
|
335
|
+
Log.e(TAG, "" + throwable.toString())
|
|
336
|
+
promise.reject("error", "Failed to start offline ${recordingDataType} recording", throwable)
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private fun stopPolarOfflineRecording(deviceId: String, recordingDataType: PolarBleApi.PolarDeviceDataType,
|
|
342
|
+
promise: Promise){
|
|
343
|
+
val map: WritableMap = Arguments.createMap()
|
|
344
|
+
api.stopOfflineRecording(deviceId, recordingDataType)
|
|
345
|
+
.subscribe(
|
|
346
|
+
{
|
|
347
|
+
Log.d(TAG, "STOP offline ${recordingDataType} recording completed")
|
|
348
|
+
map.putString("result", "completed");
|
|
349
|
+
promise.resolve(map)
|
|
350
|
+
},
|
|
351
|
+
{ throwable: Throwable ->
|
|
352
|
+
Log.e(TAG, "" + throwable.toString())
|
|
353
|
+
promise.reject("error", "Failed to stop offline ${recordingDataType} recording", throwable)
|
|
354
|
+
}
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
|
|
279
358
|
override fun downloadOfflineRecordings(deviceId: String){
|
|
280
359
|
try {
|
|
281
360
|
api.listOfflineRecordings(deviceId)
|
|
@@ -300,6 +379,15 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
300
379
|
val unixTimestamp = firstSampleDateUTC + intervalInMs * index++;
|
|
301
380
|
val timestamp = Instant.ofEpochMilli(unixTimestamp)
|
|
302
381
|
Log.d(TAG, "HR data: ${timestamp} hr: ${sample.hr} correctedHr: ${sample.correctedHr} ppgQuality: ${sample.ppgQuality} entry $index of ${it.data.samples.size}")
|
|
382
|
+
|
|
383
|
+
val event: WritableMap = Arguments.createMap()
|
|
384
|
+
event.putString("data", OfflineRecording.HR.name)
|
|
385
|
+
event.putInt("hr", sample.hr)
|
|
386
|
+
event.putInt("correctedHr", sample.correctedHr)
|
|
387
|
+
event.putInt("ppgQuality", sample.ppgQuality)
|
|
388
|
+
event.putDouble("size", it.data.samples.size.toDouble()) // Use to track data transfer progress
|
|
389
|
+
event.putDouble("timestamp", unixTimestamp.toDouble())
|
|
390
|
+
sendEvent("PolarOfflineRecording", event)
|
|
303
391
|
}
|
|
304
392
|
}
|
|
305
393
|
is PolarOfflineRecordingData.AccOfflineRecording -> {
|
|
@@ -307,6 +395,15 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
307
395
|
var index = 0;
|
|
308
396
|
for (sample in it.data.samples) {
|
|
309
397
|
Log.d(TAG, "ACC data: time: ${sample.timeStamp} X: ${sample.x} Y: ${sample.y} Z: ${sample.z} entry ${++index} of ${it.data.samples.size}")
|
|
398
|
+
|
|
399
|
+
val event: WritableMap = Arguments.createMap()
|
|
400
|
+
event.putString("data", OfflineRecording.ACC.name)
|
|
401
|
+
event.putInt("accX", sample.x)
|
|
402
|
+
event.putInt("accY", sample.y)
|
|
403
|
+
event.putInt("accZ", sample.z)
|
|
404
|
+
event.putDouble("size", it.data.samples.size.toDouble())
|
|
405
|
+
event.putDouble("timestamp", sample.timeStamp.toDouble())
|
|
406
|
+
sendEvent("PolarOfflineRecording", event)
|
|
310
407
|
}
|
|
311
408
|
}
|
|
312
409
|
is PolarOfflineRecordingData.GyroOfflineRecording -> {
|
|
@@ -314,6 +411,15 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
314
411
|
var index = 0;
|
|
315
412
|
for (sample in it.data.samples) {
|
|
316
413
|
Log.d(TAG, "GYRO data: ${sample.timeStamp} X: ${sample.x} Y: ${sample.y} Z: ${sample.z} entry ${++index} of ${it.data.samples.size}")
|
|
414
|
+
|
|
415
|
+
val event: WritableMap = Arguments.createMap()
|
|
416
|
+
event.putString("data", OfflineRecording.GYRO.name)
|
|
417
|
+
event.putString("gyrX", "${sample.x}")
|
|
418
|
+
event.putString("gyrY", "${sample.y}")
|
|
419
|
+
event.putString("gyrZ", "${sample.z}")
|
|
420
|
+
event.putDouble("size", it.data.samples.size.toDouble())
|
|
421
|
+
event.putDouble("timestamp", sample.timeStamp.toDouble())
|
|
422
|
+
sendEvent("PolarOfflineRecording", event)
|
|
317
423
|
}
|
|
318
424
|
}
|
|
319
425
|
is PolarOfflineRecordingData.PpgOfflineRecording -> {
|
|
@@ -321,6 +427,16 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
321
427
|
var index = 0;
|
|
322
428
|
for (sample in it.data.samples) {
|
|
323
429
|
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}")
|
|
430
|
+
|
|
431
|
+
val event: WritableMap = Arguments.createMap()
|
|
432
|
+
event.putString("data", OfflineRecording.PPG.name)
|
|
433
|
+
event.putString("ppg0", "${sample.channelSamples[0]}")
|
|
434
|
+
event.putString("ppg1", "${sample.channelSamples[1]}")
|
|
435
|
+
event.putString("ppg2", "${sample.channelSamples[2]}")
|
|
436
|
+
event.putString("ambient", "${sample.channelSamples[3]}")
|
|
437
|
+
event.putDouble("size", it.data.samples.size.toDouble())
|
|
438
|
+
event.putDouble("timestamp", sample.timeStamp.toDouble())
|
|
439
|
+
sendEvent("PolarOfflineRecording", event)
|
|
324
440
|
}
|
|
325
441
|
}
|
|
326
442
|
else -> {
|
|
@@ -733,6 +849,81 @@ class PolarBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
733
849
|
}
|
|
734
850
|
}
|
|
735
851
|
|
|
852
|
+
fun buildTriggerFeatures(features: ReadableArray): Map<PolarBleApi.PolarDeviceDataType, PolarSensorSetting?> {
|
|
853
|
+
// Convert ReadableArray to List<String>
|
|
854
|
+
val featureList = List(features.size()) { index -> features.getString(index).orEmpty() }
|
|
855
|
+
|
|
856
|
+
// Prepare the trigger feature map
|
|
857
|
+
val triggerFeatures = mutableMapOf<PolarBleApi.PolarDeviceDataType, PolarSensorSetting?>()
|
|
858
|
+
|
|
859
|
+
for (feature in featureList) {
|
|
860
|
+
when (feature) {
|
|
861
|
+
"OfflineHR" -> {
|
|
862
|
+
Log.d(TAG, "Configuring OfflineHR settings")
|
|
863
|
+
triggerFeatures[PolarBleApi.PolarDeviceDataType.HR] = null
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
"OfflineACC" -> {
|
|
867
|
+
Log.d(TAG, "Configuring OfflineACC settings")
|
|
868
|
+
triggerFeatures[PolarBleApi.PolarDeviceDataType.ACC] = PolarSensorSetting(
|
|
869
|
+
mapOf(
|
|
870
|
+
PolarSensorSetting.SettingType.SAMPLE_RATE to 52,
|
|
871
|
+
PolarSensorSetting.SettingType.RESOLUTION to 16,
|
|
872
|
+
PolarSensorSetting.SettingType.RANGE to 8,
|
|
873
|
+
PolarSensorSetting.SettingType.CHANNELS to 3
|
|
874
|
+
)
|
|
875
|
+
)
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
"OfflineGYR" -> {
|
|
879
|
+
Log.d(TAG, "Configuring OfflineGYR settings")
|
|
880
|
+
triggerFeatures[PolarBleApi.PolarDeviceDataType.GYRO] = PolarSensorSetting(
|
|
881
|
+
mapOf(
|
|
882
|
+
PolarSensorSetting.SettingType.SAMPLE_RATE to 52,
|
|
883
|
+
PolarSensorSetting.SettingType.RESOLUTION to 16,
|
|
884
|
+
PolarSensorSetting.SettingType.RANGE to 2000,
|
|
885
|
+
PolarSensorSetting.SettingType.CHANNELS to 3
|
|
886
|
+
)
|
|
887
|
+
)
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
"OfflinePPG" -> {
|
|
891
|
+
Log.d(TAG, "Configuring OfflinePPG settings")
|
|
892
|
+
triggerFeatures[PolarBleApi.PolarDeviceDataType.PPG] = PolarSensorSetting(
|
|
893
|
+
mapOf(
|
|
894
|
+
PolarSensorSetting.SettingType.SAMPLE_RATE to 55,
|
|
895
|
+
PolarSensorSetting.SettingType.RESOLUTION to 22,
|
|
896
|
+
PolarSensorSetting.SettingType.CHANNELS to 4
|
|
897
|
+
)
|
|
898
|
+
)
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
"OfflineMAG" -> {
|
|
902
|
+
Log.d(TAG, "Configuring OfflineMAG settings")
|
|
903
|
+
triggerFeatures[PolarBleApi.PolarDeviceDataType.MAGNETOMETER] = PolarSensorSetting(
|
|
904
|
+
mapOf(
|
|
905
|
+
PolarSensorSetting.SettingType.SAMPLE_RATE to 10,
|
|
906
|
+
PolarSensorSetting.SettingType.RESOLUTION to 16,
|
|
907
|
+
PolarSensorSetting.SettingType.RANGE to 50,
|
|
908
|
+
PolarSensorSetting.SettingType.CHANNELS to 3
|
|
909
|
+
)
|
|
910
|
+
)
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
"OfflinePPI" -> {
|
|
914
|
+
Log.d(TAG, "Configuring OfflinePPI settings")
|
|
915
|
+
triggerFeatures[PolarBleApi.PolarDeviceDataType.PPI] = null
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
else -> {
|
|
919
|
+
Log.d(TAG, "Unknown feature: $feature")
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
return triggerFeatures
|
|
925
|
+
}
|
|
926
|
+
|
|
736
927
|
override fun disposeHrStream(){
|
|
737
928
|
hrDisposable?.dispose()
|
|
738
929
|
}
|
|
@@ -31,7 +31,7 @@ namespace facebook::react {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_connectToDevice(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
34
|
-
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt,
|
|
34
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "connectToDevice", @selector(connectToDevice:resolve:reject:), args, count);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_disconnectFromDevice(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
@@ -74,6 +74,14 @@ namespace facebook::react {
|
|
|
74
74
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getDiskSpace", @selector(getDiskSpace:resolve:reject:), args, count);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_startOfflineRecording(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
78
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "startOfflineRecording", @selector(startOfflineRecording:features:resolve:reject:), args, count);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_stopOfflineRecording(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
82
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "stopOfflineRecording", @selector(stopOfflineRecording:features:resolve:reject:), args, count);
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_setPolarRecordingTrigger(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
78
86
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setPolarRecordingTrigger", @selector(setPolarRecordingTrigger:recordingMode:features:), args, count);
|
|
79
87
|
}
|
|
@@ -149,6 +157,12 @@ namespace facebook::react {
|
|
|
149
157
|
methodMap_["getDiskSpace"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_getDiskSpace};
|
|
150
158
|
|
|
151
159
|
|
|
160
|
+
methodMap_["startOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeSpecJSI_startOfflineRecording};
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
methodMap_["stopOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeSpecJSI_stopOfflineRecording};
|
|
164
|
+
|
|
165
|
+
|
|
152
166
|
methodMap_["setPolarRecordingTrigger"] = MethodMetadata {3, __hostFunction_NativePolarBridgeSpecJSI_setPolarRecordingTrigger};
|
|
153
167
|
|
|
154
168
|
|
|
@@ -37,7 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
37
37
|
|
|
38
38
|
- (NSNumber *)multiply:(double)a
|
|
39
39
|
b:(double)b;
|
|
40
|
-
- (void)connectToDevice:(NSString *)deviceId
|
|
40
|
+
- (void)connectToDevice:(NSString *)deviceId
|
|
41
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
42
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
41
43
|
- (void)disconnectFromDevice:(NSString *)deviceId;
|
|
42
44
|
- (void)fetchHrData:(NSString *)deviceId;
|
|
43
45
|
- (void)fetchAccData:(NSString *)deviceId;
|
|
@@ -52,6 +54,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
52
54
|
- (void)getDiskSpace:(NSString *)deviceId
|
|
53
55
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
54
56
|
reject:(RCTPromiseRejectBlock)reject;
|
|
57
|
+
- (void)startOfflineRecording:(NSString *)deviceId
|
|
58
|
+
features:(NSArray *)features
|
|
59
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
60
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
61
|
+
- (void)stopOfflineRecording:(NSString *)deviceId
|
|
62
|
+
features:(NSArray *)features
|
|
63
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
64
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
55
65
|
- (void)setPolarRecordingTrigger:(NSString *)deviceId
|
|
56
66
|
recordingMode:(double)recordingMode
|
|
57
67
|
features:(NSArray *)features;
|
|
@@ -19,11 +19,10 @@ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_multiply(jsi::Runti
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_connectToDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
|
-
static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->connectToDevice(
|
|
22
|
+
return static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->connectToDevice(
|
|
23
23
|
rt,
|
|
24
24
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
25
25
|
);
|
|
26
|
-
return jsi::Value::undefined();
|
|
27
26
|
}
|
|
28
27
|
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_disconnectFromDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
29
28
|
static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->disconnectFromDevice(
|
|
@@ -93,6 +92,20 @@ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_getDiskSpace(jsi::R
|
|
|
93
92
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
94
93
|
);
|
|
95
94
|
}
|
|
95
|
+
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_startOfflineRecording(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
96
|
+
return static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->startOfflineRecording(
|
|
97
|
+
rt,
|
|
98
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
99
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_stopOfflineRecording(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
103
|
+
return static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->stopOfflineRecording(
|
|
104
|
+
rt,
|
|
105
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
106
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
96
109
|
static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_setPolarRecordingTrigger(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
97
110
|
static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->setPolarRecordingTrigger(
|
|
98
111
|
rt,
|
|
@@ -167,6 +180,8 @@ NativePolarBridgeCxxSpecJSI::NativePolarBridgeCxxSpecJSI(std::shared_ptr<CallInv
|
|
|
167
180
|
methodMap_["getDeviceTime"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_getDeviceTime};
|
|
168
181
|
methodMap_["setDeviceTime"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_setDeviceTime};
|
|
169
182
|
methodMap_["getDiskSpace"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_getDiskSpace};
|
|
183
|
+
methodMap_["startOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeCxxSpecJSI_startOfflineRecording};
|
|
184
|
+
methodMap_["stopOfflineRecording"] = MethodMetadata {2, __hostFunction_NativePolarBridgeCxxSpecJSI_stopOfflineRecording};
|
|
170
185
|
methodMap_["setPolarRecordingTrigger"] = MethodMetadata {3, __hostFunction_NativePolarBridgeCxxSpecJSI_setPolarRecordingTrigger};
|
|
171
186
|
methodMap_["fetchOfflineRecordings"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_fetchOfflineRecordings};
|
|
172
187
|
methodMap_["downloadOfflineRecordings"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_downloadOfflineRecordings};
|
|
@@ -21,7 +21,7 @@ protected:
|
|
|
21
21
|
|
|
22
22
|
public:
|
|
23
23
|
virtual double multiply(jsi::Runtime &rt, double a, double b) = 0;
|
|
24
|
-
virtual
|
|
24
|
+
virtual jsi::Value connectToDevice(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
25
25
|
virtual void disconnectFromDevice(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
26
26
|
virtual void fetchHrData(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
27
27
|
virtual void fetchAccData(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
@@ -32,6 +32,8 @@ public:
|
|
|
32
32
|
virtual jsi::Value getDeviceTime(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
33
33
|
virtual void setDeviceTime(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
34
34
|
virtual jsi::Value getDiskSpace(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
35
|
+
virtual jsi::Value startOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) = 0;
|
|
36
|
+
virtual jsi::Value stopOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) = 0;
|
|
35
37
|
virtual void setPolarRecordingTrigger(jsi::Runtime &rt, jsi::String deviceId, double recordingMode, jsi::Array features) = 0;
|
|
36
38
|
virtual jsi::Value fetchOfflineRecordings(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
37
39
|
virtual void downloadOfflineRecordings(jsi::Runtime &rt, jsi::String deviceId) = 0;
|
|
@@ -79,12 +81,12 @@ private:
|
|
|
79
81
|
return bridging::callFromJs<double>(
|
|
80
82
|
rt, &T::multiply, jsInvoker_, instance_, std::move(a), std::move(b));
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
jsi::Value connectToDevice(jsi::Runtime &rt, jsi::String deviceId) override {
|
|
83
85
|
static_assert(
|
|
84
86
|
bridging::getParameterCount(&T::connectToDevice) == 2,
|
|
85
87
|
"Expected connectToDevice(...) to have 2 parameters");
|
|
86
88
|
|
|
87
|
-
return bridging::callFromJs<
|
|
89
|
+
return bridging::callFromJs<jsi::Value>(
|
|
88
90
|
rt, &T::connectToDevice, jsInvoker_, instance_, std::move(deviceId));
|
|
89
91
|
}
|
|
90
92
|
void disconnectFromDevice(jsi::Runtime &rt, jsi::String deviceId) override {
|
|
@@ -167,6 +169,22 @@ private:
|
|
|
167
169
|
return bridging::callFromJs<jsi::Value>(
|
|
168
170
|
rt, &T::getDiskSpace, jsInvoker_, instance_, std::move(deviceId));
|
|
169
171
|
}
|
|
172
|
+
jsi::Value startOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) override {
|
|
173
|
+
static_assert(
|
|
174
|
+
bridging::getParameterCount(&T::startOfflineRecording) == 3,
|
|
175
|
+
"Expected startOfflineRecording(...) to have 3 parameters");
|
|
176
|
+
|
|
177
|
+
return bridging::callFromJs<jsi::Value>(
|
|
178
|
+
rt, &T::startOfflineRecording, jsInvoker_, instance_, std::move(deviceId), std::move(features));
|
|
179
|
+
}
|
|
180
|
+
jsi::Value stopOfflineRecording(jsi::Runtime &rt, jsi::String deviceId, jsi::Array features) override {
|
|
181
|
+
static_assert(
|
|
182
|
+
bridging::getParameterCount(&T::stopOfflineRecording) == 3,
|
|
183
|
+
"Expected stopOfflineRecording(...) to have 3 parameters");
|
|
184
|
+
|
|
185
|
+
return bridging::callFromJs<jsi::Value>(
|
|
186
|
+
rt, &T::stopOfflineRecording, jsInvoker_, instance_, std::move(deviceId), std::move(features));
|
|
187
|
+
}
|
|
170
188
|
void setPolarRecordingTrigger(jsi::Runtime &rt, jsi::String deviceId, double recordingMode, jsi::Array features) override {
|
|
171
189
|
static_assert(
|
|
172
190
|
bridging::getParameterCount(&T::setPolarRecordingTrigger) == 4,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
-
import type { DeviceTime, DiskSpace, OfflineRecording } from './PolarDataModel';
|
|
3
|
+
import type { DeviceConnected, DeviceTime, DiskSpace, OfflineRecording } from './PolarDataModel';
|
|
4
4
|
|
|
5
5
|
export interface Spec extends TurboModule {
|
|
6
6
|
multiply(a: number, b: number): number;
|
|
7
|
-
connectToDevice(deviceId: string):
|
|
7
|
+
connectToDevice(deviceId: string): Promise<DeviceConnected>;
|
|
8
8
|
disconnectFromDevice(deviceId: string): void;
|
|
9
9
|
fetchHrData(deviceId: string): void;
|
|
10
10
|
fetchAccData(deviceId: string): void;
|
|
@@ -15,6 +15,8 @@ export interface Spec extends TurboModule {
|
|
|
15
15
|
getDeviceTime(deviceId: string): Promise<DeviceTime>;
|
|
16
16
|
setDeviceTime(deviceId: string): void;
|
|
17
17
|
getDiskSpace(deviceId: string): Promise<DiskSpace>;
|
|
18
|
+
startOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
19
|
+
stopOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
18
20
|
setPolarRecordingTrigger(deviceId: string, recordingMode: number, features: string[]): void;
|
|
19
21
|
fetchOfflineRecordings(deviceId: string): Promise<OfflineRecording[]>;
|
|
20
22
|
downloadOfflineRecordings(deviceId: string): void;
|
package/lib/module/index.js
CHANGED
|
@@ -40,6 +40,12 @@ export function getDeviceTime(deviceId) {
|
|
|
40
40
|
export function getDiskSpace(deviceId) {
|
|
41
41
|
return PolarBridge.getDiskSpace(deviceId);
|
|
42
42
|
}
|
|
43
|
+
export function startOfflineRecording(deviceId, features) {
|
|
44
|
+
return PolarBridge.startOfflineRecording(deviceId, features);
|
|
45
|
+
}
|
|
46
|
+
export function stopOfflineRecording(deviceId, features) {
|
|
47
|
+
return PolarBridge.stopOfflineRecording(deviceId, features);
|
|
48
|
+
}
|
|
43
49
|
export function setPolarRecordingTrigger(deviceId, recordingMode, features) {
|
|
44
50
|
return PolarBridge.setPolarRecordingTrigger(deviceId, recordingMode, features);
|
|
45
51
|
}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PolarBridge","multiply","a","b","connectToDevice","deviceId","disconnectFromDevice","scanDevices","fetchHrData","fetchAccData","fetchGyrData","fetchPpgData","enableSdkMode","disableSdkMode","setDeviceTime","getDeviceTime","getDiskSpace","
|
|
1
|
+
{"version":3,"names":["PolarBridge","multiply","a","b","connectToDevice","deviceId","disconnectFromDevice","scanDevices","fetchHrData","fetchAccData","fetchGyrData","fetchPpgData","enableSdkMode","disableSdkMode","setDeviceTime","getDeviceTime","getDiskSpace","startOfflineRecording","features","stopOfflineRecording","setPolarRecordingTrigger","recordingMode","fetchOfflineRecordings","downloadOfflineRecordings","deleteAllOfflineRecordings","disposeHrStream","disposeAccStream","disposeGyrStream","disposePpgStream","emittedEventId","Object","freeze","SCAN_DEVICE_FOUND","SCAN_DEVICE_ERROR","SCAN_DEVICE_COMPLETE","POLAR_DEVICE_TIME","POLAR_HR_DATA","POLAR_HR_ERROR","POLAR_HR_COMPLETE","POLAR_ACC_DATA","POLAR_ACC_ERROR","POLAR_ACC_COMPLETE","POLAR_GYR_DATA","POLAR_GYR_ERROR","POLAR_GYR_COMPLETE","POLAR_PPG_DATA","POLAR_PPG_ERROR","POLAR_PPG_COMPLETE","POLAR_DISK_SPACE","OfflineRecordingFeature","OFFLINE_HR","OFFLINE_ACC","OFFLINE_GYR","OFFLINE_PPG","OFFLINE_MAG","OFFLINE_PPI","OfflineRecordingTriggerMode","TRIGGER_DISABLED","TRIGGER_SYSTEM_START","TRIGGER_EXERCISE_START"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,WAAW,MAAM,qBAAqB;AAE7C,OAAO,SAASC,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAU;EACrD,OAAOH,WAAW,CAACC,QAAQ,CAACC,CAAC,EAAEC,CAAC,CAAC;AACnC;AAEA,OAAO,SAASC,eAAeA,CAACC,QAAgB,EAAE;EAChD,OAAOL,WAAW,CAACI,eAAe,CAACC,QAAQ,CAAC;AAC9C;AAEA,OAAO,SAASC,oBAAoBA,CAACD,QAAgB,EAAE;EACrD,OAAOL,WAAW,CAACM,oBAAoB,CAACD,QAAQ,CAAC;AACnD;AAEA,OAAO,SAASE,WAAWA,CAAA,EAAG;EAC5B,OAAOP,WAAW,CAACO,WAAW,CAAC,CAAC;AAClC;AAEA,OAAO,SAASC,WAAWA,CAACH,QAAgB,EAAE;EAC5C,OAAOL,WAAW,CAACQ,WAAW,CAACH,QAAQ,CAAC;AAC1C;AAEA,OAAO,SAASI,YAAYA,CAACJ,QAAgB,EAAE;EAC7C,OAAOL,WAAW,CAACS,YAAY,CAACJ,QAAQ,CAAC;AAC3C;AAEA,OAAO,SAASK,YAAYA,CAACL,QAAgB,EAAE;EAC7C,OAAOL,WAAW,CAACU,YAAY,CAACL,QAAQ,CAAC;AAC3C;AAEA,OAAO,SAASM,YAAYA,CAACN,QAAgB,EAAE;EAC7C,OAAOL,WAAW,CAACW,YAAY,CAACN,QAAQ,CAAC;AAC3C;AAEA,OAAO,SAASO,aAAaA,CAACP,QAAgB,EAAE;EAC9C,OAAOL,WAAW,CAACY,aAAa,CAACP,QAAQ,CAAC;AAC5C;AAEA,OAAO,SAASQ,cAAcA,CAACR,QAAgB,EAAE;EAC/C,OAAOL,WAAW,CAACa,cAAc,CAACR,QAAQ,CAAC;AAC7C;AAEA,OAAO,SAAS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import type { DeviceTime, DiskSpace, OfflineRecording } from './PolarDataModel';
|
|
2
|
+
import type { DeviceConnected, DeviceTime, DiskSpace, OfflineRecording } from './PolarDataModel';
|
|
3
3
|
export interface Spec extends TurboModule {
|
|
4
4
|
multiply(a: number, b: number): number;
|
|
5
|
-
connectToDevice(deviceId: string):
|
|
5
|
+
connectToDevice(deviceId: string): Promise<DeviceConnected>;
|
|
6
6
|
disconnectFromDevice(deviceId: string): void;
|
|
7
7
|
fetchHrData(deviceId: string): void;
|
|
8
8
|
fetchAccData(deviceId: string): void;
|
|
@@ -13,6 +13,8 @@ export interface Spec extends TurboModule {
|
|
|
13
13
|
getDeviceTime(deviceId: string): Promise<DeviceTime>;
|
|
14
14
|
setDeviceTime(deviceId: string): void;
|
|
15
15
|
getDiskSpace(deviceId: string): Promise<DiskSpace>;
|
|
16
|
+
startOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
17
|
+
stopOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
16
18
|
setPolarRecordingTrigger(deviceId: string, recordingMode: number, features: string[]): void;
|
|
17
19
|
fetchOfflineRecordings(deviceId: string): Promise<OfflineRecording[]>;
|
|
18
20
|
downloadOfflineRecordings(deviceId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativePolarBridge.d.ts","sourceRoot":"","sources":["../../../src/NativePolarBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"NativePolarBridge.d.ts","sourceRoot":"","sources":["../../../src/NativePolarBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EA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AAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAG,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function multiply(a: number, b: number): number;
|
|
2
|
-
export declare function connectToDevice(deviceId: string):
|
|
2
|
+
export declare function connectToDevice(deviceId: string): Promise<import("./PolarDataModel").DeviceConnected>;
|
|
3
3
|
export declare function disconnectFromDevice(deviceId: string): void;
|
|
4
4
|
export declare function scanDevices(): void;
|
|
5
5
|
export declare function fetchHrData(deviceId: string): void;
|
|
@@ -11,6 +11,8 @@ export declare function disableSdkMode(deviceId: string): void;
|
|
|
11
11
|
export declare function setDeviceTime(deviceId: string): void;
|
|
12
12
|
export declare function getDeviceTime(deviceId: string): Promise<import("./PolarDataModel").DeviceTime>;
|
|
13
13
|
export declare function getDiskSpace(deviceId: string): Promise<import("./PolarDataModel").DiskSpace>;
|
|
14
|
+
export declare function startOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
15
|
+
export declare function stopOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
14
16
|
export declare function setPolarRecordingTrigger(deviceId: string, recordingMode: number, features: string[]): void;
|
|
15
17
|
export declare function fetchOfflineRecordings(deviceId: string): Promise<import("./PolarDataModel").OfflineRecording[]>;
|
|
16
18
|
export declare function downloadOfflineRecordings(deviceId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,uDAE/C;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,QAEpD;AAED,wBAAgB,WAAW,SAE1B;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,QAE3C;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,QAE5C;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,QAE5C;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,QAE5C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,QAE7C;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,QAE9C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,QAE7C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,kDAE7C;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,iDAE5C;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAEzE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAExE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAEnG;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,0DAEtD;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,QAEzD;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,QAE1D;AAED,wBAAgB,eAAe,SAE9B;AAED,wBAAgB,gBAAgB,SAE/B;AAED,wBAAgB,gBAAgB,SAE/B;AAED,wBAAgB,gBAAgB,SAE/B;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;EAkBzB,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;EAOlC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;EAItC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-polar-bridge",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Polar SDK for React Native",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
package/src/NativePolarBridge.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
-
import type { DeviceTime, DiskSpace, OfflineRecording } from './PolarDataModel';
|
|
3
|
+
import type { DeviceConnected, DeviceTime, DiskSpace, OfflineRecording } from './PolarDataModel';
|
|
4
4
|
|
|
5
5
|
export interface Spec extends TurboModule {
|
|
6
6
|
multiply(a: number, b: number): number;
|
|
7
|
-
connectToDevice(deviceId: string):
|
|
7
|
+
connectToDevice(deviceId: string): Promise<DeviceConnected>;
|
|
8
8
|
disconnectFromDevice(deviceId: string): void;
|
|
9
9
|
fetchHrData(deviceId: string): void;
|
|
10
10
|
fetchAccData(deviceId: string): void;
|
|
@@ -15,6 +15,8 @@ export interface Spec extends TurboModule {
|
|
|
15
15
|
getDeviceTime(deviceId: string): Promise<DeviceTime>;
|
|
16
16
|
setDeviceTime(deviceId: string): void;
|
|
17
17
|
getDiskSpace(deviceId: string): Promise<DiskSpace>;
|
|
18
|
+
startOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
19
|
+
stopOfflineRecording(deviceId: string, features: string[]): Promise<any>;
|
|
18
20
|
setPolarRecordingTrigger(deviceId: string, recordingMode: number, features: string[]): void;
|
|
19
21
|
fetchOfflineRecordings(deviceId: string): Promise<OfflineRecording[]>;
|
|
20
22
|
downloadOfflineRecordings(deviceId: string): void;
|
package/src/PolarDataModel.tsx
CHANGED
package/src/index.tsx
CHANGED
|
@@ -52,6 +52,14 @@ export function getDiskSpace(deviceId: string) {
|
|
|
52
52
|
return PolarBridge.getDiskSpace(deviceId);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export function startOfflineRecording(deviceId: string, features: string[]) {
|
|
56
|
+
return PolarBridge.startOfflineRecording(deviceId, features);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function stopOfflineRecording(deviceId: string, features: string[]) {
|
|
60
|
+
return PolarBridge.stopOfflineRecording(deviceId, features);
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
export function setPolarRecordingTrigger(deviceId: string, recordingMode: number, features: string[]) {
|
|
56
64
|
return PolarBridge.setPolarRecordingTrigger(deviceId, recordingMode, features);
|
|
57
65
|
}
|