react-native-polar-bridge 0.1.1

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.
Files changed (40) hide show
  1. package/LICENSE +20 -0
  2. package/PolarBridge.podspec +26 -0
  3. package/README.md +115 -0
  4. package/android/build.gradle +103 -0
  5. package/android/generated/java/com/polarbridge/NativePolarBridgeSpec.java +57 -0
  6. package/android/generated/jni/CMakeLists.txt +36 -0
  7. package/android/generated/jni/RNPolarBridgeSpec-generated.cpp +62 -0
  8. package/android/generated/jni/RNPolarBridgeSpec.h +31 -0
  9. package/android/generated/jni/react/renderer/components/RNPolarBridgeSpec/RNPolarBridgeSpecJSI-generated.cpp +66 -0
  10. package/android/generated/jni/react/renderer/components/RNPolarBridgeSpec/RNPolarBridgeSpecJSI.h +116 -0
  11. package/android/gradle.properties +5 -0
  12. package/android/src/main/AndroidManifest.xml +3 -0
  13. package/android/src/main/AndroidManifestNew.xml +2 -0
  14. package/android/src/main/java/com/polarbridge/PolarBridgeModule.kt +182 -0
  15. package/android/src/main/java/com/polarbridge/PolarBridgePackage.kt +33 -0
  16. package/ios/PolarBridge.h +6 -0
  17. package/ios/PolarBridge.mm +18 -0
  18. package/ios/generated/RNPolarBridgeSpec/RNPolarBridgeSpec-generated.mm +74 -0
  19. package/ios/generated/RNPolarBridgeSpec/RNPolarBridgeSpec.h +68 -0
  20. package/ios/generated/RNPolarBridgeSpecJSI-generated.cpp +66 -0
  21. package/ios/generated/RNPolarBridgeSpecJSI.h +116 -0
  22. package/lib/module/NativePolarBridge.ts +13 -0
  23. package/lib/module/index.js +30 -0
  24. package/lib/module/index.js.map +1 -0
  25. package/lib/module/package.json +1 -0
  26. package/lib/typescript/babel.config.d.ts +2 -0
  27. package/lib/typescript/babel.config.d.ts.map +1 -0
  28. package/lib/typescript/eslint.config.d.mts +3 -0
  29. package/lib/typescript/eslint.config.d.mts.map +1 -0
  30. package/lib/typescript/package.json +1 -0
  31. package/lib/typescript/react-native.config.d.ts +3 -0
  32. package/lib/typescript/react-native.config.d.ts.map +1 -0
  33. package/lib/typescript/src/NativePolarBridge.d.ts +12 -0
  34. package/lib/typescript/src/NativePolarBridge.d.ts.map +1 -0
  35. package/lib/typescript/src/index.d.ts +15 -0
  36. package/lib/typescript/src/index.d.ts.map +1 -0
  37. package/package.json +169 -0
  38. package/react-native.config.js +12 -0
  39. package/src/NativePolarBridge.ts +13 -0
  40. package/src/index.tsx +34 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Omar Matthew
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "PolarBridge"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported }
14
+ s.source = { :git => "https://github.com/omatt/react-native-polar-bridge.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,cpp}"
17
+ s.private_header_files = "ios/**/*.h"
18
+
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+ end
26
+ end
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # react-native-polar-bridge
2
+
3
+ Testing Polar SDK on React Native
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-polar-bridge
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ This React Native library uses the [polar-ble-sdk](https://github.com/polarofficial/polar-ble-sdk).
14
+
15
+ ⚠️ The library only has support for Android devices.
16
+
17
+ ### Connecting to Device
18
+
19
+ ```js
20
+ import { connectToDevice } from 'react-native-polar-bridge';
21
+
22
+ const deviceId = 'D8765432';
23
+
24
+ export default function App(){
25
+
26
+ // ...
27
+
28
+ oDevice(deviceId);
29
+ }
30
+
31
+ ```
32
+
33
+ ### Disconnecting from Device
34
+
35
+ ```js
36
+ disconnectFromDevice(deviceId);
37
+ ```
38
+
39
+ ### Scan Devices
40
+
41
+ Use `scanDevices()` to scan for nearby Polar devices
42
+
43
+ ```js
44
+ scanDevices();
45
+ ```
46
+
47
+ and listen for emitted events for the result.
48
+
49
+ ```js
50
+ const [devices, setDevices] = useState<Device[]>([]);
51
+
52
+ useEffect(() => {
53
+ const onDeviceFound = polarEmitter.addListener(emittedEventId.SCAN_DEVICE_FOUND, device => {
54
+ console.log('Device found:', device);
55
+ });
56
+
57
+ const onScanError = polarEmitter.addListener(emittedEventId.SCAN_DEVICE_ERROR, err => {
58
+ console.error('Scan error:', err.message);
59
+ });
60
+
61
+ const onScanComplete = polarEmitter.addListener(emittedEventId.SCAN_DEVICE_COMPLETE, () => {
62
+ console.log('Scan complete');
63
+ });
64
+
65
+ return () => {
66
+ onDeviceFound.remove();
67
+ onScanError.remove();
68
+ onScanComplete.remove();
69
+ };
70
+ }, []);
71
+ ```
72
+
73
+ ### Heart Rate Stream
74
+
75
+ Ensure that the `deviceId` of the Polar device is connected before calling the function.
76
+
77
+ ```js
78
+ fetchHrData(deviceId);
79
+ ```
80
+
81
+ Listen for emitted events of the HR data.
82
+
83
+ ```js
84
+ useEffect(() => {
85
+ const hrListener = polarEmitter.addListener(emittedEventId.POLAR_HR_DATA, (data) => {
86
+ console.log('Heart Rate:', `${data.hr} bpm ${formatDateYYYYMMDDHHMMSS(new Date())}`);
87
+ });
88
+
89
+ const errorListener = polarEmitter.addListener(emittedEventId.POLAR_HR_ERROR, (error) => {
90
+ console.log('HR stream error:', error);
91
+ });
92
+
93
+ const completeListener = polarEmitter.addListener(emittedEventId.POLAR_HR_COMPLETE, (msg) => {
94
+ console.log('HR stream complete:', msg);
95
+ });
96
+
97
+ return () => {
98
+ hrListener.remove();
99
+ errorListener.remove();
100
+ completeListener.remove();
101
+ };
102
+ }, []);
103
+ ```
104
+
105
+ ## Contributing
106
+
107
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
108
+
109
+ ## License
110
+
111
+ MIT
112
+
113
+ ---
114
+
115
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,103 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['PolarBridge_' + name]
4
+ }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
16
+ }
17
+
18
+
19
+ apply plugin: "com.android.library"
20
+ apply plugin: "kotlin-android"
21
+
22
+ apply plugin: "com.facebook.react"
23
+
24
+ def getExtOrIntegerDefault(name) {
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PolarBridge_" + name]).toInteger()
26
+ }
27
+
28
+ def supportsNamespace() {
29
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
30
+ def major = parsed[0].toInteger()
31
+ def minor = parsed[1].toInteger()
32
+
33
+ // Namespace support was added in 7.3.0
34
+ return (major == 7 && minor >= 3) || major >= 8
35
+ }
36
+
37
+ android {
38
+ if (supportsNamespace()) {
39
+ namespace "com.polarbridge"
40
+
41
+ sourceSets {
42
+ main {
43
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
44
+ }
45
+ }
46
+ }
47
+
48
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
49
+
50
+ defaultConfig {
51
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
52
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
53
+ }
54
+
55
+ buildFeatures {
56
+ buildConfig true
57
+ }
58
+
59
+ buildTypes {
60
+ release {
61
+ minifyEnabled false
62
+ }
63
+ }
64
+
65
+ lintOptions {
66
+ disable "GradleCompatible"
67
+ }
68
+
69
+ compileOptions {
70
+ sourceCompatibility JavaVersion.VERSION_1_8
71
+ targetCompatibility JavaVersion.VERSION_1_8
72
+ }
73
+
74
+ sourceSets {
75
+ main {
76
+ java.srcDirs += [
77
+ "generated/java",
78
+ "generated/jni"
79
+ ]
80
+ }
81
+ }
82
+ }
83
+
84
+ repositories {
85
+ mavenCentral()
86
+ google()
87
+ }
88
+
89
+ def kotlin_version = getExtOrDefault("kotlinVersion")
90
+
91
+ dependencies {
92
+ implementation "com.facebook.react:react-android"
93
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
94
+ implementation 'io.reactivex.rxjava3:rxjava:3.1.10'
95
+ implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
96
+ implementation 'com.github.polarofficial:polar-ble-sdk:6.4.0'
97
+ }
98
+
99
+ react {
100
+ jsRootDir = file("../src/")
101
+ libraryName = "PolarBridge"
102
+ codegenJavaPackageName = "com.polarbridge"
103
+ }
@@ -0,0 +1,57 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJavaSpec.js
9
+ *
10
+ * @nolint
11
+ */
12
+
13
+ package com.polarbridge;
14
+
15
+ import com.facebook.proguard.annotations.DoNotStrip;
16
+ import com.facebook.react.bridge.ReactApplicationContext;
17
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
18
+ import com.facebook.react.bridge.ReactMethod;
19
+ import com.facebook.react.turbomodule.core.interfaces.TurboModule;
20
+ import javax.annotation.Nonnull;
21
+
22
+ public abstract class NativePolarBridgeSpec extends ReactContextBaseJavaModule implements TurboModule {
23
+ public static final String NAME = "PolarBridge";
24
+
25
+ public NativePolarBridgeSpec(ReactApplicationContext reactContext) {
26
+ super(reactContext);
27
+ }
28
+
29
+ @Override
30
+ public @Nonnull String getName() {
31
+ return NAME;
32
+ }
33
+
34
+ @ReactMethod(isBlockingSynchronousMethod = true)
35
+ @DoNotStrip
36
+ public abstract double multiply(double a, double b);
37
+
38
+ @ReactMethod
39
+ @DoNotStrip
40
+ public abstract void connectToDevice(String deviceId);
41
+
42
+ @ReactMethod
43
+ @DoNotStrip
44
+ public abstract void disconnectFromDevice(String deviceId);
45
+
46
+ @ReactMethod
47
+ @DoNotStrip
48
+ public abstract void fetchHrData(String deviceId);
49
+
50
+ @ReactMethod
51
+ @DoNotStrip
52
+ public abstract void scanDevices();
53
+
54
+ @ReactMethod
55
+ @DoNotStrip
56
+ public abstract void disposeHrStream();
57
+ }
@@ -0,0 +1,36 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNPolarBridgeSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_RNPolarBridgeSpec
13
+ OBJECT
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_RNPolarBridgeSpec PUBLIC . react/renderer/components/RNPolarBridgeSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_RNPolarBridgeSpec
21
+ fbjni
22
+ jsi
23
+ # We need to link different libraries based on whether we are building rncore or not, that's necessary
24
+ # because we want to break a circular dependency between react_codegen_rncore and reactnative
25
+ reactnative
26
+ )
27
+
28
+ target_compile_options(
29
+ react_codegen_RNPolarBridgeSpec
30
+ PRIVATE
31
+ -DLOG_TAG=\"ReactNative\"
32
+ -fexceptions
33
+ -frtti
34
+ -std=c++20
35
+ -Wall
36
+ )
@@ -0,0 +1,62 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNPolarBridgeSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_multiply(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
+ static jmethodID cachedMethodId = nullptr;
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, NumberKind, "multiply", "(DD)D", args, count, cachedMethodId);
18
+ }
19
+
20
+ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_connectToDevice(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
21
+ static jmethodID cachedMethodId = nullptr;
22
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "connectToDevice", "(Ljava/lang/String;)V", args, count, cachedMethodId);
23
+ }
24
+
25
+ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_disconnectFromDevice(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
26
+ static jmethodID cachedMethodId = nullptr;
27
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "disconnectFromDevice", "(Ljava/lang/String;)V", args, count, cachedMethodId);
28
+ }
29
+
30
+ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_fetchHrData(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
31
+ static jmethodID cachedMethodId = nullptr;
32
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "fetchHrData", "(Ljava/lang/String;)V", args, count, cachedMethodId);
33
+ }
34
+
35
+ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_scanDevices(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
36
+ static jmethodID cachedMethodId = nullptr;
37
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "scanDevices", "()V", args, count, cachedMethodId);
38
+ }
39
+
40
+ static facebook::jsi::Value __hostFunction_NativePolarBridgeSpecJSI_disposeHrStream(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
41
+ static jmethodID cachedMethodId = nullptr;
42
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "disposeHrStream", "()V", args, count, cachedMethodId);
43
+ }
44
+
45
+ NativePolarBridgeSpecJSI::NativePolarBridgeSpecJSI(const JavaTurboModule::InitParams &params)
46
+ : JavaTurboModule(params) {
47
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativePolarBridgeSpecJSI_multiply};
48
+ methodMap_["connectToDevice"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_connectToDevice};
49
+ methodMap_["disconnectFromDevice"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_disconnectFromDevice};
50
+ methodMap_["fetchHrData"] = MethodMetadata {1, __hostFunction_NativePolarBridgeSpecJSI_fetchHrData};
51
+ methodMap_["scanDevices"] = MethodMetadata {0, __hostFunction_NativePolarBridgeSpecJSI_scanDevices};
52
+ methodMap_["disposeHrStream"] = MethodMetadata {0, __hostFunction_NativePolarBridgeSpecJSI_disposeHrStream};
53
+ }
54
+
55
+ std::shared_ptr<TurboModule> RNPolarBridgeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
56
+ if (moduleName == "PolarBridge") {
57
+ return std::make_shared<NativePolarBridgeSpecJSI>(params);
58
+ }
59
+ return nullptr;
60
+ }
61
+
62
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ /**
20
+ * JNI C++ class for module 'NativePolarBridge'
21
+ */
22
+ class JSI_EXPORT NativePolarBridgeSpecJSI : public JavaTurboModule {
23
+ public:
24
+ NativePolarBridgeSpecJSI(const JavaTurboModule::InitParams &params);
25
+ };
26
+
27
+
28
+ JSI_EXPORT
29
+ std::shared_ptr<TurboModule> RNPolarBridgeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
+
31
+ } // namespace facebook::react
@@ -0,0 +1,66 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNPolarBridgeSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_multiply(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->multiply(
16
+ rt,
17
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber(),
18
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asNumber()
19
+ );
20
+ }
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(
23
+ rt,
24
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
25
+ );
26
+ return jsi::Value::undefined();
27
+ }
28
+ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_disconnectFromDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
29
+ static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->disconnectFromDevice(
30
+ rt,
31
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
32
+ );
33
+ return jsi::Value::undefined();
34
+ }
35
+ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_fetchHrData(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
36
+ static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->fetchHrData(
37
+ rt,
38
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
39
+ );
40
+ return jsi::Value::undefined();
41
+ }
42
+ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_scanDevices(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
43
+ static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->scanDevices(
44
+ rt
45
+ );
46
+ return jsi::Value::undefined();
47
+ }
48
+ static jsi::Value __hostFunction_NativePolarBridgeCxxSpecJSI_disposeHrStream(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
49
+ static_cast<NativePolarBridgeCxxSpecJSI *>(&turboModule)->disposeHrStream(
50
+ rt
51
+ );
52
+ return jsi::Value::undefined();
53
+ }
54
+
55
+ NativePolarBridgeCxxSpecJSI::NativePolarBridgeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
56
+ : TurboModule("PolarBridge", jsInvoker) {
57
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativePolarBridgeCxxSpecJSI_multiply};
58
+ methodMap_["connectToDevice"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_connectToDevice};
59
+ methodMap_["disconnectFromDevice"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_disconnectFromDevice};
60
+ methodMap_["fetchHrData"] = MethodMetadata {1, __hostFunction_NativePolarBridgeCxxSpecJSI_fetchHrData};
61
+ methodMap_["scanDevices"] = MethodMetadata {0, __hostFunction_NativePolarBridgeCxxSpecJSI_scanDevices};
62
+ methodMap_["disposeHrStream"] = MethodMetadata {0, __hostFunction_NativePolarBridgeCxxSpecJSI_disposeHrStream};
63
+ }
64
+
65
+
66
+ } // namespace facebook::react
@@ -0,0 +1,116 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+ class JSI_EXPORT NativePolarBridgeCxxSpecJSI : public TurboModule {
19
+ protected:
20
+ NativePolarBridgeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
+
22
+ public:
23
+ virtual double multiply(jsi::Runtime &rt, double a, double b) = 0;
24
+ virtual void connectToDevice(jsi::Runtime &rt, jsi::String deviceId) = 0;
25
+ virtual void disconnectFromDevice(jsi::Runtime &rt, jsi::String deviceId) = 0;
26
+ virtual void fetchHrData(jsi::Runtime &rt, jsi::String deviceId) = 0;
27
+ virtual void scanDevices(jsi::Runtime &rt) = 0;
28
+ virtual void disposeHrStream(jsi::Runtime &rt) = 0;
29
+
30
+ };
31
+
32
+ template <typename T>
33
+ class JSI_EXPORT NativePolarBridgeCxxSpec : public TurboModule {
34
+ public:
35
+ jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
36
+ return delegate_.create(rt, propName);
37
+ }
38
+
39
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
40
+ return delegate_.getPropertyNames(runtime);
41
+ }
42
+
43
+ static constexpr std::string_view kModuleName = "PolarBridge";
44
+
45
+ protected:
46
+ NativePolarBridgeCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
47
+ : TurboModule(std::string{NativePolarBridgeCxxSpec::kModuleName}, jsInvoker),
48
+ delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
49
+
50
+
51
+ private:
52
+ class Delegate : public NativePolarBridgeCxxSpecJSI {
53
+ public:
54
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
55
+ NativePolarBridgeCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
56
+
57
+ }
58
+
59
+ double multiply(jsi::Runtime &rt, double a, double b) override {
60
+ static_assert(
61
+ bridging::getParameterCount(&T::multiply) == 3,
62
+ "Expected multiply(...) to have 3 parameters");
63
+
64
+ return bridging::callFromJs<double>(
65
+ rt, &T::multiply, jsInvoker_, instance_, std::move(a), std::move(b));
66
+ }
67
+ void connectToDevice(jsi::Runtime &rt, jsi::String deviceId) override {
68
+ static_assert(
69
+ bridging::getParameterCount(&T::connectToDevice) == 2,
70
+ "Expected connectToDevice(...) to have 2 parameters");
71
+
72
+ return bridging::callFromJs<void>(
73
+ rt, &T::connectToDevice, jsInvoker_, instance_, std::move(deviceId));
74
+ }
75
+ void disconnectFromDevice(jsi::Runtime &rt, jsi::String deviceId) override {
76
+ static_assert(
77
+ bridging::getParameterCount(&T::disconnectFromDevice) == 2,
78
+ "Expected disconnectFromDevice(...) to have 2 parameters");
79
+
80
+ return bridging::callFromJs<void>(
81
+ rt, &T::disconnectFromDevice, jsInvoker_, instance_, std::move(deviceId));
82
+ }
83
+ void fetchHrData(jsi::Runtime &rt, jsi::String deviceId) override {
84
+ static_assert(
85
+ bridging::getParameterCount(&T::fetchHrData) == 2,
86
+ "Expected fetchHrData(...) to have 2 parameters");
87
+
88
+ return bridging::callFromJs<void>(
89
+ rt, &T::fetchHrData, jsInvoker_, instance_, std::move(deviceId));
90
+ }
91
+ void scanDevices(jsi::Runtime &rt) override {
92
+ static_assert(
93
+ bridging::getParameterCount(&T::scanDevices) == 1,
94
+ "Expected scanDevices(...) to have 1 parameters");
95
+
96
+ return bridging::callFromJs<void>(
97
+ rt, &T::scanDevices, jsInvoker_, instance_);
98
+ }
99
+ void disposeHrStream(jsi::Runtime &rt) override {
100
+ static_assert(
101
+ bridging::getParameterCount(&T::disposeHrStream) == 1,
102
+ "Expected disposeHrStream(...) to have 1 parameters");
103
+
104
+ return bridging::callFromJs<void>(
105
+ rt, &T::disposeHrStream, jsInvoker_, instance_);
106
+ }
107
+
108
+ private:
109
+ friend class NativePolarBridgeCxxSpec;
110
+ T *instance_;
111
+ };
112
+
113
+ Delegate delegate_;
114
+ };
115
+
116
+ } // namespace facebook::react
@@ -0,0 +1,5 @@
1
+ PolarBridge_kotlinVersion=2.0.21
2
+ PolarBridge_minSdkVersion=24
3
+ PolarBridge_targetSdkVersion=34
4
+ PolarBridge_compileSdkVersion=35
5
+ PolarBridge_ndkVersion=27.1.12297006
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.polarbridge">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>