summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/android
diff options
context:
space:
mode:
authorhc <haocheng.xie@respiree.com>2026-04-13 15:17:52 +0800
committerhc <haocheng.xie@respiree.com>2026-04-13 15:17:52 +0800
commitd6d9a09d505d11148599a95a5be3e1351edbe0ac (patch)
treea5f5891983d1ff207e99f683a5e151519cef4980 /libs/ihealth-sdk/android
parente4fb9966e762852bf17f21c8406501d42fae0b61 (diff)
Local iHealth SDK, device detail screen, iOS event fixes
Diffstat (limited to 'libs/ihealth-sdk/android')
-rw-r--r--libs/ihealth-sdk/android/.project28
-rw-r--r--libs/ihealth-sdk/android/.settings/org.eclipse.buildship.core.prefs13
-rwxr-xr-xlibs/ihealth-sdk/android/build.gradle46
-rw-r--r--libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.jarbin0 -> 54329 bytes
-rw-r--r--libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.properties6
-rw-r--r--libs/ihealth-sdk/android/gradlew172
-rw-r--r--libs/ihealth-sdk/android/gradlew.bat84
-rwxr-xr-xlibs/ihealth-sdk/android/libs/arm64-v8a/libBodyfat_SDK.sobin0 -> 18944 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/arm64-v8a/libECGOffline.sobin0 -> 83984 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/arm64-v8a/libECGOnline.sobin0 -> 47776 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/arm64-v8a/libVeryFitMulti.sobin0 -> 1907416 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/arm64-v8a/libiHealth.sobin0 -> 14976 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/armeabi-v7a/libBodyfat_SDK.sobin0 -> 26908 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/armeabi-v7a/libECGOffline.sobin0 -> 79596 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/armeabi-v7a/libECGOnline.sobin0 -> 47440 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/armeabi-v7a/libVeryFitMulti.sobin0 -> 1243220 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/armeabi-v7a/libiHealth.sobin0 -> 18792 bytes
-rw-r--r--libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jarbin0 -> 2222561 bytes
-rw-r--r--libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jar.bakbin0 -> 2169923 bytes
-rw-r--r--libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8_original.jarbin0 -> 2169923 bytes
-rw-r--r--libs/ihealth-sdk/android/libs/smartlinklib3.6.4_product.jarbin0 -> 17608 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86/libBodyfat_SDK.sobin0 -> 18604 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86/libECGOffline.sobin0 -> 91820 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86/libECGOnline.sobin0 -> 51520 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86/libVeryFitMulti.sobin0 -> 2041980 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86/libiHealth.sobin0 -> 18732 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86_64/libBodyfat_SDK.sobin0 -> 19216 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86_64/libECGOffline.sobin0 -> 104760 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86_64/libECGOnline.sobin0 -> 60360 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86_64/libVeryFitMulti.sobin0 -> 1936488 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/libs/x86_64/libiHealth.sobin0 -> 19352 bytes
-rwxr-xr-xlibs/ihealth-sdk/android/proguard-rules.pro17
-rwxr-xr-xlibs/ihealth-sdk/android/src/androidTest/java/com/example/jing/ihealthlibrary/ExampleInstrumentedTest.java26
-rwxr-xr-xlibs/ihealth-sdk/android/src/androidTest/java/com/ihealth/ihealthlibrary/ExampleInstrumentedTest.java26
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/AndroidManifest.xml7
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM3SModule.java339
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM4Module.java339
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5Module.java378
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5ProfileModule.java161
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AMProfileModule.java312
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1Module.java116
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1ProfileModule.java176
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SModule.java106
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SProfileModule.java225
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5Module.java323
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SModule.java185
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SProfileModule.java113
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BGProfileModule.java146
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP3LModule.java133
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP550BTModule.java159
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5Module.java193
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5SModule.java155
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7Module.java148
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7SModule.java176
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BPProfileModule.java168
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMModule.java145
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMProfileModule.java74
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGModule.java157
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGProfileModule.java385
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGUSBModule.java290
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2Module.java115
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SModule.java322
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SProfileModule.java209
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS4SModule.java129
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6Module.java134
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6ProfileModule.java93
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HSProfileModule.java92
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BModule.java98
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BProfileModule.java52
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1Module.java99
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1ProfileModule.java73
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO3Module.java115
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/POProfileModule.java78
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTModule.java152
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTProfileModule.java73
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BModule.java98
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BProfileModule.java52
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/Utils.java123
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthBaseModule.java40
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerModule.java734
-rw-r--r--libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerPackage.java70
-rwxr-xr-xlibs/ihealth-sdk/android/src/main/res/values/strings.xml3
-rwxr-xr-xlibs/ihealth-sdk/android/src/test/java/com/example/jing/ihealthlibrary/ExampleUnitTest.java17
-rwxr-xr-xlibs/ihealth-sdk/android/src/test/java/com/ihealth/ihealthlibrary/ExampleUnitTest.java17
84 files changed, 8515 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/android/.project b/libs/ihealth-sdk/android/.project
new file mode 100644
index 0000000..df0d1c9
--- /dev/null
+++ b/libs/ihealth-sdk/android/.project
@@ -0,0 +1,28 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>android</name>
4 <comment>Project android created by Buildship.</comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 </buildSpec>
14 <natures>
15 <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16 </natures>
17 <filteredResources>
18 <filter>
19 <id>1623719603491</id>
20 <name></name>
21 <type>30</type>
22 <matcher>
23 <id>org.eclipse.core.resources.regexFilterMatcher</id>
24 <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25 </matcher>
26 </filter>
27 </filteredResources>
28</projectDescription>
diff --git a/libs/ihealth-sdk/android/.settings/org.eclipse.buildship.core.prefs b/libs/ihealth-sdk/android/.settings/org.eclipse.buildship.core.prefs
new file mode 100644
index 0000000..dc1d8e8
--- /dev/null
+++ b/libs/ihealth-sdk/android/.settings/org.eclipse.buildship.core.prefs
@@ -0,0 +1,13 @@
1arguments=
2auto.sync=false
3build.scans.enabled=false
4connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5connection.project.dir=
6eclipse.preferences.version=1
7gradle.user.home=
8java.home=/Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home
9jvm.arguments=
10offline.mode=false
11override.workspace.settings=true
12show.console.view=true
13show.executions.view=true
diff --git a/libs/ihealth-sdk/android/build.gradle b/libs/ihealth-sdk/android/build.gradle
new file mode 100755
index 0000000..8f07183
--- /dev/null
+++ b/libs/ihealth-sdk/android/build.gradle
@@ -0,0 +1,46 @@
1apply plugin: 'com.android.library'
2
3android {
4 compileSdkVersion 35
5 buildToolsVersion '35.0.0'
6
7 defaultConfig {
8 minSdkVersion 24
9 targetSdkVersion 35
10 versionCode 1
11 versionName "1.0"
12
13 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14
15 }
16 buildTypes {
17 release {
18 minifyEnabled false
19 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 }
21 }
22
23 sourceSets {
24 main {
25 jniLibs.srcDirs = ['libs']
26 }
27 }
28}
29
30dependencies {
31 testImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
32 exclude group: 'com.android.support', module: 'support-annotations'
33 })
34 api 'androidx.appcompat:appcompat:1.2.0'
35 api 'androidx.core:core:1.6.0'
36 api 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
37 api 'androidx.annotation:annotation:1.3.0'
38 testImplementation 'junit:junit:4.12'
39 api 'com.facebook.react:react-native:+'
40 api 'com.squareup.okhttp3:okhttp:4.8.0'
41 api 'com.google.code.gson:gson:2.8.6'
42 implementation files('libs/iHealthSDK_2.9.8.jar')
43 implementation 'org.greenrobot:greendao:3.2.2'
44 // implementation 'no.nordicsemi.android:dfu:1.6.1' // removed — not needed for scanning, and repo not available
45 implementation 'com.alibaba:fastjson:1.2.48'
46}
diff --git a/libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.jar b/libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..f6b961f
--- /dev/null
+++ b/libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.properties b/libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..0f14bff
--- /dev/null
+++ b/libs/ihealth-sdk/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
1#Sat May 09 13:27:51 CST 2020
2distributionBase=GRADLE_USER_HOME
3distributionPath=wrapper/dists
4zipStoreBase=GRADLE_USER_HOME
5zipStorePath=wrapper/dists
6distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
diff --git a/libs/ihealth-sdk/android/gradlew b/libs/ihealth-sdk/android/gradlew
new file mode 100644
index 0000000..cccdd3d
--- /dev/null
+++ b/libs/ihealth-sdk/android/gradlew
@@ -0,0 +1,172 @@
1#!/usr/bin/env sh
2
3##############################################################################
4##
5## Gradle start up script for UN*X
6##
7##############################################################################
8
9# Attempt to set APP_HOME
10# Resolve links: $0 may be a link
11PRG="$0"
12# Need this for relative symlinks.
13while [ -h "$PRG" ] ; do
14 ls=`ls -ld "$PRG"`
15 link=`expr "$ls" : '.*-> \(.*\)$'`
16 if expr "$link" : '/.*' > /dev/null; then
17 PRG="$link"
18 else
19 PRG=`dirname "$PRG"`"/$link"
20 fi
21done
22SAVED="`pwd`"
23cd "`dirname \"$PRG\"`/" >/dev/null
24APP_HOME="`pwd -P`"
25cd "$SAVED" >/dev/null
26
27APP_NAME="Gradle"
28APP_BASE_NAME=`basename "$0"`
29
30# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31DEFAULT_JVM_OPTS=""
32
33# Use the maximum available, or set MAX_FD != -1 to use that value.
34MAX_FD="maximum"
35
36warn () {
37 echo "$*"
38}
39
40die () {
41 echo
42 echo "$*"
43 echo
44 exit 1
45}
46
47# OS specific support (must be 'true' or 'false').
48cygwin=false
49msys=false
50darwin=false
51nonstop=false
52case "`uname`" in
53 CYGWIN* )
54 cygwin=true
55 ;;
56 Darwin* )
57 darwin=true
58 ;;
59 MINGW* )
60 msys=true
61 ;;
62 NONSTOP* )
63 nonstop=true
64 ;;
65esac
66
67CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68
69# Determine the Java command to use to start the JVM.
70if [ -n "$JAVA_HOME" ] ; then
71 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 # IBM's JDK on AIX uses strange locations for the executables
73 JAVACMD="$JAVA_HOME/jre/sh/java"
74 else
75 JAVACMD="$JAVA_HOME/bin/java"
76 fi
77 if [ ! -x "$JAVACMD" ] ; then
78 die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79
80Please set the JAVA_HOME variable in your environment to match the
81location of your Java installation."
82 fi
83else
84 JAVACMD="java"
85 which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86
87Please set the JAVA_HOME variable in your environment to match the
88location of your Java installation."
89fi
90
91# Increase the maximum file descriptors if we can.
92if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 MAX_FD_LIMIT=`ulimit -H -n`
94 if [ $? -eq 0 ] ; then
95 if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 MAX_FD="$MAX_FD_LIMIT"
97 fi
98 ulimit -n $MAX_FD
99 if [ $? -ne 0 ] ; then
100 warn "Could not set maximum file descriptor limit: $MAX_FD"
101 fi
102 else
103 warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 fi
105fi
106
107# For Darwin, add options to specify how the application appears in the dock
108if $darwin; then
109 GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110fi
111
112# For Cygwin, switch paths to Windows format before running java
113if $cygwin ; then
114 APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 JAVACMD=`cygpath --unix "$JAVACMD"`
117
118 # We build the pattern for arguments to be converted via cygpath
119 ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 SEP=""
121 for dir in $ROOTDIRSRAW ; do
122 ROOTDIRS="$ROOTDIRS$SEP$dir"
123 SEP="|"
124 done
125 OURCYGPATTERN="(^($ROOTDIRS))"
126 # Add a user-defined pattern to the cygpath arguments
127 if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 fi
130 # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 i=0
132 for arg in "$@" ; do
133 CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135
136 if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 else
139 eval `echo args$i`="\"$arg\""
140 fi
141 i=$((i+1))
142 done
143 case $i in
144 (0) set -- ;;
145 (1) set -- "$args0" ;;
146 (2) set -- "$args0" "$args1" ;;
147 (3) set -- "$args0" "$args1" "$args2" ;;
148 (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 esac
155fi
156
157# Escape application args
158save () {
159 for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 echo " "
161}
162APP_ARGS=$(save "$@")
163
164# Collect all arguments for the java command, following the shell quoting and substitution rules
165eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166
167# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 cd "$(dirname "$0")"
170fi
171
172exec "$JAVACMD" "$@"
diff --git a/libs/ihealth-sdk/android/gradlew.bat b/libs/ihealth-sdk/android/gradlew.bat
new file mode 100644
index 0000000..e95643d
--- /dev/null
+++ b/libs/ihealth-sdk/android/gradlew.bat
@@ -0,0 +1,84 @@
1@if "%DEBUG%" == "" @echo off
2@rem ##########################################################################
3@rem
4@rem Gradle startup script for Windows
5@rem
6@rem ##########################################################################
7
8@rem Set local scope for the variables with windows NT shell
9if "%OS%"=="Windows_NT" setlocal
10
11set DIRNAME=%~dp0
12if "%DIRNAME%" == "" set DIRNAME=.
13set APP_BASE_NAME=%~n0
14set APP_HOME=%DIRNAME%
15
16@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17set DEFAULT_JVM_OPTS=
18
19@rem Find java.exe
20if defined JAVA_HOME goto findJavaFromJavaHome
21
22set JAVA_EXE=java.exe
23%JAVA_EXE% -version >NUL 2>&1
24if "%ERRORLEVEL%" == "0" goto init
25
26echo.
27echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28echo.
29echo Please set the JAVA_HOME variable in your environment to match the
30echo location of your Java installation.
31
32goto fail
33
34:findJavaFromJavaHome
35set JAVA_HOME=%JAVA_HOME:"=%
36set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
38if exist "%JAVA_EXE%" goto init
39
40echo.
41echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42echo.
43echo Please set the JAVA_HOME variable in your environment to match the
44echo location of your Java installation.
45
46goto fail
47
48:init
49@rem Get command-line arguments, handling Windows variants
50
51if not "%OS%" == "Windows_NT" goto win9xME_args
52
53:win9xME_args
54@rem Slurp the command line arguments.
55set CMD_LINE_ARGS=
56set _SKIP=2
57
58:win9xME_args_slurp
59if "x%~1" == "x" goto execute
60
61set CMD_LINE_ARGS=%*
62
63:execute
64@rem Setup the command line
65
66set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67
68@rem Execute Gradle
69"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70
71:end
72@rem End local scope for the variables with windows NT shell
73if "%ERRORLEVEL%"=="0" goto mainEnd
74
75:fail
76rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77rem the _cmd.exe /c_ return code!
78if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79exit /b 1
80
81:mainEnd
82if "%OS%"=="Windows_NT" endlocal
83
84:omega
diff --git a/libs/ihealth-sdk/android/libs/arm64-v8a/libBodyfat_SDK.so b/libs/ihealth-sdk/android/libs/arm64-v8a/libBodyfat_SDK.so
new file mode 100755
index 0000000..4fc680d
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/arm64-v8a/libBodyfat_SDK.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/arm64-v8a/libECGOffline.so b/libs/ihealth-sdk/android/libs/arm64-v8a/libECGOffline.so
new file mode 100755
index 0000000..60a9d84
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/arm64-v8a/libECGOffline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/arm64-v8a/libECGOnline.so b/libs/ihealth-sdk/android/libs/arm64-v8a/libECGOnline.so
new file mode 100755
index 0000000..edffde2
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/arm64-v8a/libECGOnline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/arm64-v8a/libVeryFitMulti.so b/libs/ihealth-sdk/android/libs/arm64-v8a/libVeryFitMulti.so
new file mode 100755
index 0000000..c58f6e8
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/arm64-v8a/libVeryFitMulti.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/arm64-v8a/libiHealth.so b/libs/ihealth-sdk/android/libs/arm64-v8a/libiHealth.so
new file mode 100755
index 0000000..5d7659c
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/arm64-v8a/libiHealth.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/armeabi-v7a/libBodyfat_SDK.so b/libs/ihealth-sdk/android/libs/armeabi-v7a/libBodyfat_SDK.so
new file mode 100755
index 0000000..4d3374f
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/armeabi-v7a/libBodyfat_SDK.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/armeabi-v7a/libECGOffline.so b/libs/ihealth-sdk/android/libs/armeabi-v7a/libECGOffline.so
new file mode 100755
index 0000000..3fa9085
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/armeabi-v7a/libECGOffline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/armeabi-v7a/libECGOnline.so b/libs/ihealth-sdk/android/libs/armeabi-v7a/libECGOnline.so
new file mode 100755
index 0000000..792b7ac
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/armeabi-v7a/libECGOnline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/armeabi-v7a/libVeryFitMulti.so b/libs/ihealth-sdk/android/libs/armeabi-v7a/libVeryFitMulti.so
new file mode 100755
index 0000000..e254b6f
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/armeabi-v7a/libVeryFitMulti.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/armeabi-v7a/libiHealth.so b/libs/ihealth-sdk/android/libs/armeabi-v7a/libiHealth.so
new file mode 100755
index 0000000..5def22d
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/armeabi-v7a/libiHealth.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jar b/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jar
new file mode 100644
index 0000000..db31d0b
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jar
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jar.bak b/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jar.bak
new file mode 100644
index 0000000..7d8aa90
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8.jar.bak
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8_original.jar b/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8_original.jar
new file mode 100644
index 0000000..7d8aa90
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/iHealthSDK_2.9.8_original.jar
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/smartlinklib3.6.4_product.jar b/libs/ihealth-sdk/android/libs/smartlinklib3.6.4_product.jar
new file mode 100644
index 0000000..7152e5f
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/smartlinklib3.6.4_product.jar
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86/libBodyfat_SDK.so b/libs/ihealth-sdk/android/libs/x86/libBodyfat_SDK.so
new file mode 100755
index 0000000..2cff220
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86/libBodyfat_SDK.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86/libECGOffline.so b/libs/ihealth-sdk/android/libs/x86/libECGOffline.so
new file mode 100755
index 0000000..96001b5
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86/libECGOffline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86/libECGOnline.so b/libs/ihealth-sdk/android/libs/x86/libECGOnline.so
new file mode 100755
index 0000000..23621f3
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86/libECGOnline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86/libVeryFitMulti.so b/libs/ihealth-sdk/android/libs/x86/libVeryFitMulti.so
new file mode 100755
index 0000000..79c513f
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86/libVeryFitMulti.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86/libiHealth.so b/libs/ihealth-sdk/android/libs/x86/libiHealth.so
new file mode 100755
index 0000000..355d1ae
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86/libiHealth.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86_64/libBodyfat_SDK.so b/libs/ihealth-sdk/android/libs/x86_64/libBodyfat_SDK.so
new file mode 100755
index 0000000..c76e666
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86_64/libBodyfat_SDK.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86_64/libECGOffline.so b/libs/ihealth-sdk/android/libs/x86_64/libECGOffline.so
new file mode 100755
index 0000000..c2bb960
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86_64/libECGOffline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86_64/libECGOnline.so b/libs/ihealth-sdk/android/libs/x86_64/libECGOnline.so
new file mode 100755
index 0000000..8871982
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86_64/libECGOnline.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86_64/libVeryFitMulti.so b/libs/ihealth-sdk/android/libs/x86_64/libVeryFitMulti.so
new file mode 100755
index 0000000..4af84a5
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86_64/libVeryFitMulti.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/libs/x86_64/libiHealth.so b/libs/ihealth-sdk/android/libs/x86_64/libiHealth.so
new file mode 100755
index 0000000..a4c6f9d
--- /dev/null
+++ b/libs/ihealth-sdk/android/libs/x86_64/libiHealth.so
Binary files differ
diff --git a/libs/ihealth-sdk/android/proguard-rules.pro b/libs/ihealth-sdk/android/proguard-rules.pro
new file mode 100755
index 0000000..dff1cf5
--- /dev/null
+++ b/libs/ihealth-sdk/android/proguard-rules.pro
@@ -0,0 +1,17 @@
1# Add project specific ProGuard rules here.
2# By default, the flags in this file are appended to flags specified
3# in /Users/jing/Library/Android/sdk/tools/proguard/proguard-android.txt
4# You can edit the include path and order by changing the proguardFiles
5# directive in build.gradle.
6#
7# For more details, see
8# http://developer.android.com/guide/developing/tools/proguard.html
9
10# Add any project specific keep options here:
11
12# If your project uses WebView with JS, uncomment the following
13# and specify the fully qualified class name to the JavaScript interface
14# class:
15#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16# public *;
17#}
diff --git a/libs/ihealth-sdk/android/src/androidTest/java/com/example/jing/ihealthlibrary/ExampleInstrumentedTest.java b/libs/ihealth-sdk/android/src/androidTest/java/com/example/jing/ihealthlibrary/ExampleInstrumentedTest.java
new file mode 100755
index 0000000..5417626
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/androidTest/java/com/example/jing/ihealthlibrary/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
1package com.example.jing.ihealthlibrary;
2
3import android.content.Context;
4import androidx.test.InstrumentationRegistry;
5import androidx.test.runner.AndroidJUnit4;
6
7import org.junit.Test;
8import org.junit.runner.RunWith;
9
10import static org.junit.Assert.*;
11
12/**
13 * Instrumentation test, which will execute on an Android device.
14 *
15 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16 */
17@RunWith(AndroidJUnit4.class)
18public class ExampleInstrumentedTest {
19 @Test
20 public void useAppContext() throws Exception {
21 // Context of the app under test.
22 Context appContext = InstrumentationRegistry.getTargetContext();
23
24 assertEquals("com.example.jing.ihealthlibrary.test", appContext.getPackageName());
25 }
26}
diff --git a/libs/ihealth-sdk/android/src/androidTest/java/com/ihealth/ihealthlibrary/ExampleInstrumentedTest.java b/libs/ihealth-sdk/android/src/androidTest/java/com/ihealth/ihealthlibrary/ExampleInstrumentedTest.java
new file mode 100755
index 0000000..600e0ef
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/androidTest/java/com/ihealth/ihealthlibrary/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
1package com.ihealth.ihealthlibrary;
2
3import android.content.Context;
4import androidx.test.InstrumentationRegistry;
5import androidx.test.runner.AndroidJUnit4;
6
7import org.junit.Test;
8import org.junit.runner.RunWith;
9
10import static org.junit.Assert.*;
11
12/**
13 * Instrumentation test, which will execute on an Android device.
14 *
15 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16 */
17@RunWith(AndroidJUnit4.class)
18public class ExampleInstrumentedTest {
19 @Test
20 public void useAppContext() throws Exception {
21 // Context of the app under test.
22 Context appContext = InstrumentationRegistry.getTargetContext();
23
24 assertEquals("com.ihealth.ihealthlibrary.test", appContext.getPackageName());
25 }
26}
diff --git a/libs/ihealth-sdk/android/src/main/AndroidManifest.xml b/libs/ihealth-sdk/android/src/main/AndroidManifest.xml
new file mode 100755
index 0000000..82fcbe2
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/AndroidManifest.xml
@@ -0,0 +1,7 @@
1<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2 package="com.ihealth.ihealthlibrary">
3 <application
4 android:label="@string/app_name"
5 android:supportsRtl="true">
6 </application>
7</manifest>
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM3SModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM3SModule.java
new file mode 100755
index 0000000..77276fe
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM3SModule.java
@@ -0,0 +1,339 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.ReadableArray;
10import com.facebook.react.bridge.WritableArray;
11import com.facebook.react.bridge.WritableMap;
12import com.facebook.react.module.annotations.ReactModule;
13import com.ihealth.communication.control.Am3sControl;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.util.HashMap;
17import java.util.List;
18import java.util.Map;
19
20/**
21 * Created by Jeepend on 22/11/2016.
22 */
23@ReactModule(name = "AM3SModule")
24public class AM3SModule extends iHealthBaseModule {
25 private static final String modelName = "AM3SModule";
26 private static final String TAG = "AM3SModule";
27
28 private static final String EVENT_NOTIFY = "event_notify_am3s";
29
30 public AM3SModule(ReactApplicationContext reactContext) {
31 super(TAG, reactContext);
32 }
33
34 @Override
35 public String getName() {
36 return modelName;
37 }
38
39 @Override
40 public Map<String, Object> getConstants() {
41 Map<String, Object> map = new HashMap<>();
42 map.put("Event_Notify", EVENT_NOTIFY);
43 return map;
44 }
45
46 @Override
47 public void handleNotify(String mac, String deviceType, String action, String message) {
48 WritableMap params = Arguments.createMap();
49 params.putString("action", action);
50 params.putString("mac", mac);
51 params.putString("type", deviceType);
52 if (!TextUtils.isEmpty(message)) {
53 Utils.jsonToMap(message, params);
54 }
55 sendEvent(EVENT_NOTIFY, params);
56 }
57
58 private static Am3sControl getControl(String mac) {
59 return iHealthDevicesManager.getInstance().getAm3sControl(mac);
60 }
61
62 @ReactMethod
63 public void getIdps(String mac) {
64 Am3sControl control = getControl(mac);
65 if (control != null) {
66 String idps = control.getIdps();
67 WritableMap params = Arguments.createMap();
68 if (!TextUtils.isEmpty(idps)) {
69 Utils.jsonToMap(idps, params);
70 }
71 sendEvent(EVENT_NOTIFY, params);
72 } else {
73 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
74 }
75 }
76
77 @ReactMethod
78 public void reset(String mac) {
79 Am3sControl control = getControl(mac);
80 if (control != null) {
81 control.reset(1);
82 } else {
83 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
84 }
85 }
86
87 @ReactMethod
88 public void getUserId(String mac) {
89 Am3sControl control = getControl(mac);
90 if (control != null) {
91 control.getUserId();
92 } else {
93 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
94 }
95 }
96
97 @ReactMethod
98 public void getAlarmClockNum(String mac) {
99 Am3sControl control = getControl(mac);
100 if (control != null) {
101 control.getAlarmClockNum();
102 } else {
103 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
104 }
105 }
106
107 @ReactMethod
108 public void getAlarmClockDetail(String mac, ReadableArray alarmIDArray) {
109 Am3sControl control = getControl(mac);
110 if (control != null) {
111 int[] alarmIDs = new int[alarmIDArray.size()];
112 for (int i = 0; i < alarmIDArray.size(); i++) {
113 alarmIDs[i] = alarmIDArray.getInt(i);
114 }
115 control.getAlarmClockDetail(alarmIDs);
116 } else {
117 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
118 }
119 }
120
121 @ReactMethod
122 public void setAlarmClock(String mac, int id, int hour, int min, boolean isRepeat, ReadableArray weekArray, boolean isOn) {
123 Am3sControl control = getControl(mac);
124 if (control != null) {
125 int[] weeks = new int[weekArray.size()];
126 for (int i = 0; i < weekArray.size(); i++) {
127 weeks[i] = weekArray.getInt(i);
128 }
129 control.setAlarmClock(id, hour, min, isRepeat, weeks, isOn);
130 } else {
131 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
132 }
133 }
134
135 @ReactMethod
136 public void deleteAlarmClock(String mac, int id) {
137 Am3sControl control = getControl(mac);
138 if (control != null) {
139 control.deleteAlarmClock(id);
140 } else {
141 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
142 }
143 }
144
145 @ReactMethod
146 public void getActivityRemind(String mac) {
147 Am3sControl control = getControl(mac);
148 if (control != null) {
149 control.getActivityRemind();
150 } else {
151 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
152 }
153 }
154
155 @ReactMethod
156 public void setActivityRemind(String mac, int hour, int min, boolean isOn) {
157 Am3sControl control = getControl(mac);
158 if (control != null) {
159 control.setActivityRemind(hour, min, isOn);
160 } else {
161 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
162 }
163 }
164
165 @ReactMethod
166 public void queryAMState(String mac) {
167 Am3sControl control = getControl(mac);
168 if (control != null) {
169 control.queryAMState();
170 } else {
171 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
172 }
173 }
174
175 @ReactMethod
176 public void setUserId(String mac, int id) {
177 Am3sControl control = getControl(mac);
178 if (control != null) {
179 control.setUserId(id);
180 } else {
181 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
182 }
183 }
184
185 @ReactMethod
186 public void getUserInfo(String mac) {
187 Am3sControl control = getControl(mac);
188 if (control != null) {
189 control.getUserInfo();
190 } else {
191 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
192 }
193 }
194
195 @ReactMethod
196 public void setUserBmr(String mac, int bmr) {
197 Am3sControl control = getControl(mac);
198 if (control != null) {
199 control.setUserBmr(bmr);
200 } else {
201 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
202 }
203 }
204
205 @ReactMethod
206 public void syncActivityData(String mac) {
207 Am3sControl control = getControl(mac);
208 if (control != null) {
209 control.syncActivityData();
210 } else {
211 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
212 }
213 }
214
215 @ReactMethod
216 public void syncSleepData(String mac) {
217 Am3sControl control = getControl(mac);
218 if (control != null) {
219 control.syncSleepData();
220 } else {
221 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
222 }
223 }
224
225 @ReactMethod
226 public void syncRealData(String mac) {
227 Am3sControl control = getControl(mac);
228 if (control != null) {
229 control.syncRealData();
230 } else {
231 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
232 }
233 }
234
235 @ReactMethod
236 public void syncRealTime(String mac) {
237 Am3sControl control = getControl(mac);
238 if (control != null) {
239 control.syncRealTime();
240 } else {
241 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
242 }
243 }
244
245 @ReactMethod
246 public void setHourMode(String mac, int hourMode) {
247 Am3sControl control = getControl(mac);
248 if (control != null) {
249 control.setHourMode(hourMode);
250 } else {
251 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
252 }
253 }
254
255 @ReactMethod
256 public void getHourMode(String mac) {
257 Am3sControl control = getControl(mac);
258 if (control != null) {
259 control.getHourMode();
260 } else {
261 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
262 }
263 }
264
265 @ReactMethod
266 public void disconnect(String mac) {
267 Am3sControl control = getControl(mac);
268 if (control != null) {
269 control.disconnect();
270 } else {
271 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
272 }
273 }
274
275 @ReactMethod
276 public void setUserInfo(String mac, int age, int height, float weight, int gender, int unit, int target, int activityLevel) {
277 Am3sControl control = getControl(mac);
278 if (control != null) {
279 control.setUserInfo(age, height, weight, gender, unit, target, activityLevel);
280 } else {
281 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
282 }
283 }
284
285 @ReactMethod
286 public void syncStageReportData(String mac) {
287 Am3sControl control = getControl(mac);
288 if (control != null) {
289 control.syncStageReprotData();
290 } else {
291 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
292 }
293 }
294
295 @ReactMethod
296 public void sendRandom(String mac) {
297 Am3sControl control = getControl(mac);
298 if (control != null) {
299 control.sendRandom();
300 } else {
301 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
302 }
303 }
304
305 @ReactMethod
306 public void getPicture(String mac) {
307 Am3sControl control = getControl(mac);
308 if (control != null) {
309 control.getPicture();
310 } else {
311 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
312 }
313 }
314
315 @ReactMethod
316 public void setPicture(String mac, int index) {
317 Am3sControl control = getControl(mac);
318 if (control != null) {
319 control.setPicture(index);
320 } else {
321 Log.e(TAG, "Can not find AM3S Control mac:" + mac);
322 }
323 }
324
325 @ReactMethod
326 public void getAllConnectedDevices() {
327 List<String> devices = iHealthDevicesManager.getInstance().getAm3sDevices();
328 WritableMap params = Arguments.createMap();
329 if (devices.size() > 0) {
330 WritableArray array = Arguments.createArray();
331 for (String device : devices) {
332 array.pushString(device);
333 }
334 params.putArray("devices", array);
335 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
336 }
337 sendEvent(EVENT_NOTIFY, params);
338 }
339}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM4Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM4Module.java
new file mode 100755
index 0000000..ca02e4c
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM4Module.java
@@ -0,0 +1,339 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.ReadableArray;
10import com.facebook.react.bridge.WritableArray;
11import com.facebook.react.bridge.WritableMap;
12import com.facebook.react.module.annotations.ReactModule;
13import com.ihealth.communication.control.Am4Control;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.util.HashMap;
17import java.util.List;
18import java.util.Map;
19
20/**
21 * Created by jing on 16/10/20.
22 */
23@ReactModule(name = "AM4Module")
24public class AM4Module extends iHealthBaseModule {
25 private static final String modelName = "AM4Module";
26 private static final String TAG = "AM4Module";
27
28 private static final String EVENT_NOTIFY = "event_notify_am4";
29
30 public AM4Module(ReactApplicationContext reactContext) {
31 super(TAG, reactContext);
32 }
33
34 @Override
35 public String getName() {
36 return modelName;
37 }
38
39 @Override
40 public Map<String, Object> getConstants() {
41 Map<String, Object> map = new HashMap<>();
42 map.put("Event_Notify", EVENT_NOTIFY);
43 return map;
44 }
45
46 @Override
47 public void handleNotify(String mac, String deviceType, String action, String message) {
48 WritableMap params = Arguments.createMap();
49 params.putString("action", action);
50 params.putString("mac", mac);
51 params.putString("type", deviceType);
52 if (!TextUtils.isEmpty(message)) {
53 Utils.jsonToMap(message, params);
54 }
55 sendEvent(EVENT_NOTIFY, params);
56 }
57
58 private static Am4Control getControl(String mac) {
59 return iHealthDevicesManager.getInstance().getAm4Control(mac);
60 }
61
62 @ReactMethod
63 public void getIdps(String mac) {
64 Am4Control control = getControl(mac);
65 if (control != null) {
66 String idps = control.getIdps();
67 WritableMap params = Arguments.createMap();
68 if (!TextUtils.isEmpty(idps)) {
69 Utils.jsonToMap(idps, params);
70 }
71 sendEvent(EVENT_NOTIFY, params);
72 } else {
73 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
74 }
75 }
76
77 @ReactMethod
78 public void reset(String mac) {
79 Am4Control control = getControl(mac);
80 if (control != null) {
81 control.reset(1);
82 } else {
83 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
84 }
85 }
86
87 @ReactMethod
88 public void getUserId(String mac) {
89 Am4Control control = getControl(mac);
90 if (control != null) {
91 control.getUserId();
92 } else {
93 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
94 }
95 }
96
97 @ReactMethod
98 public void getAlarmClockNum(String mac) {
99 Am4Control control = getControl(mac);
100 if (control != null) {
101 control.getAlarmClockNum();
102 } else {
103 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
104 }
105 }
106
107 @ReactMethod
108 public void getAlarmClockDetail(String mac, ReadableArray alarmIDArray) {
109 Am4Control control = getControl(mac);
110 if (control != null) {
111 int[] alarmIDs = new int[alarmIDArray.size()];
112 for (int i = 0; i< alarmIDArray.size(); i++) {
113 alarmIDs[i] = alarmIDArray.getInt(i);
114 }
115 control.getAlarmClockDetail(alarmIDs);
116 } else {
117 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
118 }
119 }
120
121 @ReactMethod
122 public void setAlarmClock(String mac, int id, int hour, int min, boolean isRepeat, ReadableArray weekArray, boolean isOn) {
123 Am4Control control = getControl(mac);
124 if (control != null) {
125 int[] weeks = new int[weekArray.size()];
126 for (int i = 0; i < weekArray.size(); i++) {
127 weeks[i] = weekArray.getInt(i);
128 }
129 control.setAlarmClock(id, hour, min, isRepeat, weeks, isOn);
130 } else {
131 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
132 }
133 }
134
135 @ReactMethod
136 public void deleteAlarmClock(String mac, int id) {
137 Am4Control control = getControl(mac);
138 if (control != null) {
139 control.deleteAlarmClock(id);
140 } else {
141 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
142 }
143 }
144
145 @ReactMethod
146 public void getActivityRemind(String mac) {
147 Am4Control control = getControl(mac);
148 if (control != null) {
149 control.getActivityRemind();
150 } else {
151 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
152 }
153 }
154
155 @ReactMethod
156 public void setActivityRemind(String mac, int hour, int min, boolean isOn) {
157 Am4Control control = getControl(mac);
158 if (control != null) {
159 control.setActivityRemind(hour, min, isOn);
160 } else {
161 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
162 }
163 }
164
165 @ReactMethod
166 public void queryAMState(String mac) {
167 Am4Control control = getControl(mac);
168 if (control != null) {
169 control.queryAMState();
170 } else {
171 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
172 }
173 }
174
175 @ReactMethod
176 public void setUserId(String mac, int id) {
177 Am4Control control = getControl(mac);
178 if (control != null) {
179 control.setUserId(id);
180 } else {
181 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
182 }
183 }
184
185 @ReactMethod
186 public void getUserInfo(String mac) {
187 Am4Control control = getControl(mac);
188 if (control != null) {
189 control.getUserInfo();
190 } else {
191 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
192 }
193 }
194
195 @ReactMethod
196 public void setUserBmr(String mac, int bmr){
197 Am4Control control = getControl(mac);
198 if (control != null) {
199 control.setUserBmr(bmr);
200 } else {
201 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
202 }
203 }
204
205 @ReactMethod
206 public void syncActivityData(String mac) {
207 Am4Control control = getControl(mac);
208 if (control != null) {
209 control.syncActivityData();
210 } else {
211 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
212 }
213 }
214
215 @ReactMethod
216 public void syncSleepData(String mac) {
217 Am4Control control = getControl(mac);
218 if (control != null) {
219 control.syncSleepData();
220 } else {
221 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
222 }
223 }
224
225 @ReactMethod
226 public void syncRealData(String mac) {
227 Am4Control control = getControl(mac);
228 if (control != null) {
229 control.syncRealData();
230 } else {
231 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
232 }
233 }
234
235 @ReactMethod
236 public void syncRealTime(String mac) {
237 Am4Control control = getControl(mac);
238 if (control != null) {
239 control.syncRealTime();
240 } else {
241 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
242 }
243 }
244
245 @ReactMethod
246 public void setHourMode(String mac, int hourMode) {
247 Am4Control control = getControl(mac);
248 if (control != null) {
249 control.setHourMode(hourMode);
250 } else {
251 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
252 }
253 }
254
255 @ReactMethod
256 public void getHourMode(String mac) {
257 Am4Control control = getControl(mac);
258 if (control != null) {
259 control.getHourMode();
260 } else {
261 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
262 }
263 }
264
265 @ReactMethod
266 public void disconnect(String mac) {
267 Am4Control control = getControl(mac);
268 if (control != null) {
269 control.disconnect();
270 } else {
271 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
272 }
273 }
274
275 @ReactMethod
276 public void setUserInfo(String mac, int age, int height, float weight, int gender, int unit, int target, int activityLevel, int min) {
277 Am4Control control = getControl(mac);
278 if (control != null) {
279 control.setUserInfo(age, height, weight, gender, unit, target, activityLevel, min);
280 } else {
281 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
282 }
283 }
284
285 @ReactMethod
286 public void syncStageReportData(String mac) {
287 Am4Control control = getControl(mac);
288 if (control != null) {
289 control.syncStageReprotData();
290 } else {
291 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
292 }
293 }
294
295 @ReactMethod
296 public void sendRandom(String mac) {
297 Am4Control control = getControl(mac);
298 if (control != null) {
299 control.sendRandom();
300 } else {
301 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
302 }
303 }
304
305 @ReactMethod
306 public void checkSwimPara(String mac) {
307 Am4Control control = getControl(mac);
308 if (control != null) {
309 control.checkSwimPara();
310 } else {
311 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
312 }
313 }
314
315 @ReactMethod
316 public void setSwimPara(String mac, boolean isOpen, int poolLength, int hours, int minutes, int unit) {
317 Am4Control control = getControl(mac);
318 if (control != null) {
319 control.setSwimPara(isOpen, poolLength, hours, minutes, unit);
320 } else {
321 Log.e(TAG, "Can not find AM4 Control mac:" + mac);
322 }
323 }
324
325 @ReactMethod
326 public void getAllConnectedDevices() {
327 List<String> devices = iHealthDevicesManager.getInstance().getAm4Devices();
328 WritableMap params = Arguments.createMap();
329 if (devices.size() > 0) {
330 WritableArray array = Arguments.createArray();
331 for (String device : devices) {
332 array.pushString(device);
333 }
334 params.putArray("devices", array);
335 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
336 }
337 sendEvent(EVENT_NOTIFY, params);
338 }
339}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5Module.java
new file mode 100755
index 0000000..570a2fd
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5Module.java
@@ -0,0 +1,378 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.ReadableArray;
10import com.facebook.react.bridge.WritableArray;
11import com.facebook.react.bridge.WritableMap;
12import com.facebook.react.module.annotations.ReactModule;
13import com.ido.ble.protocol.model.QuickSportMode;
14import com.ihealth.communication.control.Am5Control;
15import com.ihealth.communication.manager.iHealthDevicesManager;
16import com.ihealth.communication.model.AM5Alarm;
17
18import java.util.HashMap;
19import java.util.List;
20import java.util.Map;
21
22@ReactModule(name = "AM5Module")
23public class AM5Module extends iHealthBaseModule {
24 private static final String modelName = "AM5Module";
25 private static final String TAG = AM5Module.modelName;
26
27 private static final String EVENT_NOTIFY = "event_notify_am5";
28
29 public AM5Module(ReactApplicationContext reactContext) {
30 super(TAG, reactContext);
31 }
32
33 @Override
34 public String getName() {
35 return modelName;
36 }
37
38 @Override
39 public Map<String, Object> getConstants() {
40 Map<String, Object> map = new HashMap<>();
41 map.put("Event_Notify", EVENT_NOTIFY);
42 return map;
43 }
44
45 @Override
46 public void handleNotify(String mac, String deviceType, String action, String message) {
47 WritableMap params = Arguments.createMap();
48 params.putString("action", action);
49 params.putString("mac", mac);
50 params.putString("type", deviceType);
51 if (!TextUtils.isEmpty(message)) {
52 Utils.jsonToMap(message, params);
53 }
54 sendEvent(EVENT_NOTIFY, params);
55 }
56
57 private static Am5Control getControl(String mac) {
58 return iHealthDevicesManager.getInstance().getAm5Control(mac);
59 }
60
61 @ReactMethod
62 public void bindDevice(String mac) {
63 Am5Control control = getControl(mac);
64 if (control != null) {
65 control.bindDevice();
66 } else {
67 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
68 }
69 }
70
71 @ReactMethod
72 public void unBindDevice(String mac) {
73 Am5Control control = getControl(mac);
74 if (control != null) {
75 control.unBindDevice();
76 } else {
77 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
78 }
79 }
80
81 @ReactMethod
82 public void isBind(String mac) {
83 Am5Control control = getControl(mac);
84 if (control != null) {
85 control.isBind();
86 } else {
87 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
88 }
89 }
90
91 @ReactMethod
92 public void getBasicInfo(String mac) {
93 Am5Control control = getControl(mac);
94 if (control != null) {
95 control.getBasicInfo();
96 } else {
97 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
98 }
99 }
100
101 @ReactMethod
102 public void getMacAddress(String mac) {
103 Am5Control control = getControl(mac);
104 if (control != null) {
105 control.getMacAddress();
106 } else {
107 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
108 }
109 }
110
111 @ReactMethod
112 public void getLiveData(String mac) {
113 Am5Control control = getControl(mac);
114 if (control != null) {
115 control.getLiveData();
116 } else {
117 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
118 }
119 }
120
121 @ReactMethod
122 public void getActivityCount(String mac) {
123 Am5Control control = getControl(mac);
124 if (control != null) {
125 control.getActivityCount();
126 } else {
127 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
128 }
129 }
130
131 @ReactMethod
132 public void setTime(String mac) {
133 Am5Control control = getControl(mac);
134 if (control != null) {
135 control.setTime();
136 } else {
137 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
138 }
139 }
140
141 // @ReactMethod
142 // public void setTime(String mac, int year, int month, int day, int hour, int minute, int second, int week) {
143 // Am5Control control = getControl(mac);
144 // if (control != null) {
145 // control.setTime(year, month, day, hour, minute, second, week);
146 // } else {
147 // Log.e(TAG, "Can not find AM5 Control mac:" + mac);
148 // }
149 // }
150
151 @ReactMethod
152 public void setAlarm(String mac, List<AM5Alarm> alarmList) {
153 Am5Control control = getControl(mac);
154 if (control != null) {
155 control.setAlarm(alarmList);
156 } else {
157 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
158 }
159 }
160
161 @ReactMethod
162 public void setGoal(String mac, String goal) {
163 Am5Control control = getControl(mac);
164 if (control != null) {
165 control.setGoal(goal);
166 } else {
167 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
168 }
169 }
170
171 @ReactMethod
172 public void setLongSit(String mac, int startHour, int startMinute,
173 int endHour,int endMinute, int interval,
174 boolean isOn, boolean[] repeat){
175 Am5Control control = getControl(mac);
176 if (control != null) {
177 control.setLongSit(startHour, startMinute, endHour,
178 endMinute, interval, isOn, repeat);
179 } else {
180 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
181 }
182 }
183
184 @ReactMethod
185 public void setUserInfo(String mac, int birthYear, int birthMonth, int birthDay, int weight, int height, int sex) {
186 Am5Control control = getControl(mac);
187 if (control != null) {
188 control.setUserInfo(birthYear, birthMonth, birthDay, weight, height, sex);
189 } else {
190 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
191 }
192 }
193
194 @ReactMethod
195 public void setUnit(String mac, int type, int unit) {
196 Am5Control control = getControl(mac);
197 if (control != null) {
198 control.setUnit(type, unit);
199 } else {
200 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
201 }
202 }
203
204 @ReactMethod
205 public void reboot(String mac) {
206 Am5Control control = getControl(mac);
207 if (control != null) {
208 control.reboot();
209 } else {
210 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
211 }
212 }
213
214 @ReactMethod
215 public void setHandWearMode(String mac, int mode) {
216 Am5Control control = getControl(mac);
217 if (control != null) {
218 control.setHandWearMode(mode);
219 } else {
220 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
221 }
222 }
223
224 @ReactMethod
225 public void setHeartRateInterval(String mac, int burn, int aerobic, int limit, int userMaxHR) {
226 Am5Control control = getControl(mac);
227 if (control != null) {
228 control.setHeartRateInterval(burn, aerobic, limit, userMaxHR);
229 } else {
230 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
231 }
232 }
233
234 @ReactMethod
235 public void setHeartRateMeasureMode(String mac, int hasTimeRange, int measureMode, int startHour, int startMin, int endHour, int endMin) {
236 Am5Control control = getControl(mac);
237 if (control != null) {
238 control.setHeartRateMeasureMode(hasTimeRange, measureMode, startHour, startMin, endHour, endMin);
239 } else {
240 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
241 }
242 }
243
244 @ReactMethod
245 public void setNotDisturb(String mac, boolean isOpen, int startHour, int startMin, int endHour, int endMin) {
246 Am5Control control = getControl(mac);
247 if (control != null) {
248 control.setNotDisturb(isOpen, startHour, startMin, endHour, endMin);
249 } else {
250 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
251 }
252 }
253
254 @ReactMethod
255 public void setSportMode(String mac, QuickSportMode quickSportMode) {
256 Am5Control control = getControl(mac);
257 if (control != null) {
258 control.setSportMode(quickSportMode);
259 } else {
260 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
261 }
262 }
263
264 @ReactMethod
265 public void setIncomingCallInfo(String mac, String name, String phoneNumber) {
266 Am5Control control = getControl(mac);
267 if (control != null) {
268 control.setIncomingCallInfo(name, phoneNumber);
269 } else {
270 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
271 }
272 }
273
274 @ReactMethod
275 public void setStopInComingCall(String mac) {
276 Am5Control control = getControl(mac);
277 if (control != null) {
278 control.setStopInComingCall();
279 } else {
280 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
281 }
282 }
283
284 @ReactMethod
285 public void setNewMessageDetailInfo(String mac, int type, String name, String number, String content) {
286 Am5Control control = getControl(mac);
287 if (control != null) {
288 control.setNewMessageDetailInfo(type, name, number, content);
289 } else {
290 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
291 }
292 }
293
294 @ReactMethod
295 public void syncConfigData(String mac) {
296 Am5Control control = getControl(mac);
297 if (control != null) {
298 control.syncConfigData();
299 } else {
300 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
301 }
302 }
303
304 @ReactMethod
305 public void stopSyncConfigData(String mac) {
306 Am5Control control = getControl(mac);
307 if (control != null) {
308 control.stopSyncConfigData();
309 } else {
310 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
311 }
312 }
313
314 @ReactMethod
315 public void syncHealthData(String mac) {
316 Am5Control control = getControl(mac);
317 if (control != null) {
318 control.syncHealthData();
319 } else {
320 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
321 }
322 }
323
324 @ReactMethod
325 public void stopSyncHealthData(String mac) {
326 Am5Control control = getControl(mac);
327 if (control != null) {
328 control.stopSyncHealthData();
329 } else {
330 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
331 }
332 }
333
334 @ReactMethod
335 public void syncActivityData(String mac) {
336 Am5Control control = getControl(mac);
337 if (control != null) {
338 control.syncActivityData();
339 } else {
340 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
341 }
342 }
343
344 @ReactMethod
345 public void stopSyncActivityData(String mac) {
346 Am5Control control = getControl(mac);
347 if (control != null) {
348 control.stopSyncActivityData();
349 } else {
350 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
351 }
352 }
353
354 @ReactMethod
355 public void disconnect(String mac) {
356 Am5Control control = getControl(mac);
357 if (control != null) {
358 control.disconnect();
359 } else {
360 Log.e(TAG, "Can not find AM5 Control mac:" + mac);
361 }
362 }
363
364 @ReactMethod
365 public void getAllConnectedDevices() {
366 List<String> devices = iHealthDevicesManager.getInstance().getAm5Devices();
367 WritableMap params = Arguments.createMap();
368 if (devices.size() > 0) {
369 WritableArray array = Arguments.createArray();
370 for (String device : devices) {
371 array.pushString(device);
372 }
373 params.putArray("devices", array);
374 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
375 }
376 sendEvent(EVENT_NOTIFY, params);
377 }
378}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5ProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5ProfileModule.java
new file mode 100755
index 0000000..18c585e
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AM5ProfileModule.java
@@ -0,0 +1,161 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.AmProfile;
7import com.ihealth.communication.control.OtherDeviceProfile;
8
9import java.util.HashMap;
10import java.util.Map;
11
12import javax.annotation.Nullable;
13
14@ReactModule(name = "AM5ProfileModule")
15public class AM5ProfileModule extends ReactContextBaseJavaModule {
16
17 private static final String modelName = "AM5ProfileModule";
18 private static final String TAG = "AM5ProfileModule";
19
20 private static final String ACTION_ERROR = "ACTION_ERROR";
21 private static final String ERROR_NUM = "ERROR_NUM";
22 private static final String ERROR_DESCRIPTION = "ERROR_DESCRIPTION";
23
24 private static final String ACTION_USER_BIND = "ACTION_USER_BIND";
25 private static final String ACTION_USER_UNBIND = "ACTION_USER_UNBIND";
26 private static final String ACTION_FUNCTION_SUPPORT = "ACTION_FUNCTION_SUPPORT";
27 private static final String ACTION_BASIC_INFO = "ACTION_BASIC_INFO";
28 private static final String ACTION_MAC_ADDRESS = "ACTION_MAC_ADDRESS";
29
30 private static final String MAC_ADDRESS = "MAC_ADDRESS";
31 private static final String BASIC_BATTSTATUS = "BASIC_BATTSTATUS";
32 private static final String BASIC_DEIVCEID = "BASIC_DEIVCEID";
33 private static final String BASIC_ENERGE = "BASIC_ENERGE";
34 private static final String BASIC_FIRMWAREVERSION = "BASIC_FIRMWAREVERSION";
35 private static final String BASIC_MODE = "BASIC_MODE";
36 private static final String BASIC_PAIRFLAG = "BASIC_PAIRFLAG";
37 private static final String BASIC_REBOOT = "BASIC_REBOOT";
38
39 private static final String ACTION_LIVE_DATA = "ACTION_LIVE_DATA";
40 private static final String ACTION_ACTIVITY_COUNT = "ACTION_ACTIVITY_COUNT";
41 private static final String ACTION_SET_TIME = "ACTION_SET_TIME";
42 private static final String ACTION_SET_ALARM = "ACTION_SET_ALARM";
43 private static final String ACTION_SET_GOAL = "ACTION_SET_GOAL";
44 private static final String ACTION_SET_LONG_SIT = "ACTION_SET_LONG_SIT";
45 private static final String ACTION_SET_USER_INFO = "ACTION_SET_USER_INFO";
46 private static final String ACTION_SET_UNIT = "ACTION_SET_UNIT";
47 private static final String ACTION_SET_HAND_WEAR_MODE = "ACTION_SET_HAND_WEAR_MODE";
48 private static final String ACTION_SET_UP_HAND_GESTURE = "ACTION_SET_UP_HAND_GESTURE";
49 private static final String ACTION_SET_HEART_RATE_INTERVAL = "ACTION_SET_HEART_RATE_INTERVAL";
50 private static final String ACTION_SET_HEART_RATE_MEASURE_MODE = "ACTION_SET_HEART_RATE_MEASURE_MODE";
51 private static final String ACTION_SET_ONE_KEY_RESET = "ACTION_SET_ONE_KEY_RESET";
52 private static final String ACTION_SET_NOT_DISTURB = "ACTION_SET_NOT_DISTURB";
53 private static final String ACTION_SET_SPORT_MODE = "ACTION_SET_SPORT_MODE";
54
55 private static final String OPERATION_RESULT = "OPERATION_RESULT";
56 private static final String OPERATION_ACTION = "OPERATION_ACTION";
57
58 private static final String ACTION_NOTICE_COMMING_CALL = "ACTION_NOTICE_COMMING_CALL";
59 private static final String ACTION_NOTICE_COMMING_CALL_STOP = "ACTION_NOTICE_COMMING_CALL_STOP";
60 private static final String ACTION_NOTICE_NEW_MESSAGE = "ACTION_NOTICE_NEW_MESSAGE";
61
62 private static final String ACTION_SYNC_ACTIVITY = "ACTION_SYNC_ACTIVITY";
63 private static final String ACTION_SYNC_ACTIVITY_DATA = "ACTION_SYNC_ACTIVITY_DATA";
64 private static final String ACTION_SYNC_CONFIG = "ACTION_SYNC_CONFIG";
65 private static final String ACTION_SYNC_HEALTH_DATA = "ACTION_SYNC_HEALTH_DATA";
66 private static final String ACTION_SYNC_HEALTH_DATA_SPORT = "ACTION_SYNC_HEALTH_DATA_SPORT";
67 private static final String ACTION_SYNC_HEALTH_DATA_SLEEP = "ACTION_SYNC_HEALTH_DATA_SLEEP";
68 private static final String ACTION_SYNC_HEALTH_DATA_HEART_RATE = "ACTION_SYNC_HEALTH_DATA_HEART_RATE";
69 private static final String ACTION_SYNC_HEALTH_DATA_BLOOD_PRESSURE = "ACTION_SYNC_HEALTH_DATA_BLOOD_PRESSURE";
70
71 private static final String OPERATION_STATUS = "OPERATION_STATUS";
72 private static final String PROGRESS = "PROGRESS";
73 private static final int STATUS_START = 0;
74 private static final int STATUS_STOP = 1;
75 private static final int STATUS_DOING = 2;
76 private static final int STATUS_SUCCESS = 3;
77 private static final int STATUS_FAIL = 4;
78 private static final int STATUS_CANCEL = 5;
79
80 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
81
82
83 public AM5ProfileModule(ReactApplicationContext reactContext) {
84 super(reactContext);
85 }
86
87 @Override
88 public String getName() {
89 return modelName;
90 }
91
92 @Nullable
93 @Override
94 public Map<String, Object> getConstants() {
95 Map<String, Object> constants = new HashMap<>();
96 constants.put(ACTION_ERROR, OtherDeviceProfile.ACTION_ERROR);
97 constants.put(ERROR_NUM, OtherDeviceProfile.ERROR_NUM);
98 constants.put(ERROR_DESCRIPTION, OtherDeviceProfile.ERROR_DESCRIPTION);
99
100 constants.put(ACTION_USER_BIND, OtherDeviceProfile.ACTION_USER_BIND);
101 constants.put(ACTION_USER_UNBIND, OtherDeviceProfile.ACTION_USER_UNBIND);
102 constants.put(ACTION_FUNCTION_SUPPORT, OtherDeviceProfile.ACTION_FUNCTION_SUPPORT);
103 constants.put(ACTION_BASIC_INFO, OtherDeviceProfile.ACTION_BASIC_INFO);
104 constants.put(ACTION_MAC_ADDRESS, OtherDeviceProfile.ACTION_MAC_ADDRESS);
105
106 constants.put(MAC_ADDRESS, OtherDeviceProfile.MAC_ADDRESS);
107 constants.put(BASIC_BATTSTATUS, OtherDeviceProfile.BASIC_BATTSTATUS);
108 constants.put(BASIC_DEIVCEID, OtherDeviceProfile.BASIC_DEIVCEID);
109 constants.put(BASIC_ENERGE, OtherDeviceProfile.BASIC_ENERGE);
110 constants.put(BASIC_FIRMWAREVERSION, OtherDeviceProfile.BASIC_FIRMWAREVERSION);
111 constants.put(BASIC_MODE, OtherDeviceProfile.BASIC_MODE);
112 constants.put(BASIC_PAIRFLAG, OtherDeviceProfile.BASIC_PAIRFLAG);
113 constants.put(BASIC_REBOOT, OtherDeviceProfile.BASIC_REBOOT);
114
115 constants.put(ACTION_LIVE_DATA, OtherDeviceProfile.ACTION_LIVE_DATA);
116 constants.put(ACTION_ACTIVITY_COUNT, OtherDeviceProfile.ACTION_ACTIVITY_COUNT);
117 constants.put(ACTION_SET_TIME, OtherDeviceProfile.ACTION_SET_TIME);
118
119 constants.put(ACTION_SET_ALARM, OtherDeviceProfile.ACTION_SET_ALARM);
120 constants.put(ACTION_SET_GOAL, OtherDeviceProfile.ACTION_SET_GOAL);
121 constants.put(ACTION_SET_LONG_SIT, OtherDeviceProfile.ACTION_SET_LONG_SIT);
122 constants.put(ACTION_SET_USER_INFO, OtherDeviceProfile.ACTION_SET_USER_INFO);
123 constants.put(ACTION_SET_UNIT, OtherDeviceProfile.ACTION_SET_UNIT);
124 constants.put(ACTION_SET_HAND_WEAR_MODE, OtherDeviceProfile.ACTION_SET_HAND_WEAR_MODE);
125 constants.put(ACTION_SET_UP_HAND_GESTURE, OtherDeviceProfile.ACTION_SET_UP_HAND_GESTURE);
126 constants.put(ACTION_SET_HEART_RATE_INTERVAL, OtherDeviceProfile.ACTION_SET_HEART_RATE_INTERVAL);
127 constants.put(ACTION_SET_HEART_RATE_MEASURE_MODE, OtherDeviceProfile.ACTION_SET_HEART_RATE_MEASURE_MODE);
128 constants.put(ACTION_SET_ONE_KEY_RESET, OtherDeviceProfile.ACTION_SET_ONE_KEY_RESET);
129 constants.put(ACTION_SET_NOT_DISTURB, OtherDeviceProfile.ACTION_SET_NOT_DISTURB);
130 constants.put(ACTION_SET_SPORT_MODE, OtherDeviceProfile.ACTION_SET_SPORT_MODE);
131
132 constants.put(OPERATION_RESULT, OtherDeviceProfile.OPERATION_RESULT);
133 constants.put(OPERATION_ACTION, OtherDeviceProfile.OPERATION_ACTION);
134
135 constants.put(ACTION_NOTICE_COMMING_CALL, OtherDeviceProfile.ACTION_NOTICE_COMMING_CALL);
136 constants.put(ACTION_NOTICE_COMMING_CALL_STOP, OtherDeviceProfile.ACTION_NOTICE_COMMING_CALL_STOP);
137 constants.put(ACTION_NOTICE_NEW_MESSAGE, OtherDeviceProfile.ACTION_NOTICE_NEW_MESSAGE);
138
139 constants.put(ACTION_SYNC_ACTIVITY, OtherDeviceProfile.ACTION_SYNC_ACTIVITY);
140 constants.put(ACTION_SYNC_ACTIVITY_DATA, OtherDeviceProfile.ACTION_SYNC_ACTIVITY_DATA);
141 constants.put(ACTION_SYNC_CONFIG, OtherDeviceProfile.ACTION_SYNC_CONFIG);
142 constants.put(ACTION_SYNC_HEALTH_DATA, OtherDeviceProfile.ACTION_SYNC_HEALTH_DATA);
143 constants.put(ACTION_SYNC_HEALTH_DATA_SPORT, OtherDeviceProfile.ACTION_SYNC_HEALTH_DATA_SPORT);
144 constants.put(ACTION_SYNC_HEALTH_DATA_SLEEP, OtherDeviceProfile.ACTION_SYNC_HEALTH_DATA_SLEEP);
145 constants.put(ACTION_SYNC_HEALTH_DATA_HEART_RATE, OtherDeviceProfile.ACTION_SYNC_HEALTH_DATA_HEART_RATE);
146 constants.put(ACTION_SYNC_HEALTH_DATA_BLOOD_PRESSURE, OtherDeviceProfile.ACTION_SYNC_HEALTH_DATA_BLOOD_PRESSURE);
147
148 constants.put(OPERATION_STATUS, OtherDeviceProfile.OPERATION_STATUS);
149 constants.put(PROGRESS, OtherDeviceProfile.PROGRESS);
150
151 constants.put("STATUS_START", 0);
152 constants.put("STATUS_STOP", 1);
153 constants.put("STATUS_DOING", 2);
154 constants.put("STATUS_SUCCESS", 3);
155 constants.put("STATUS_FAIL", 4);
156 constants.put("STATUS_CANCEL", 5);
157
158 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
159 return constants;
160 }
161}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AMProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AMProfileModule.java
new file mode 100755
index 0000000..344ac85
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/AMProfileModule.java
@@ -0,0 +1,312 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.AmProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by Jeepend on 15/11/2016.
15 */
16@ReactModule(name = "AMProfileModule")
17public class AMProfileModule extends ReactContextBaseJavaModule {
18 private static final String modelName = "AMProfileModule";
19 private static final String TAG = "AMProfileModule";
20
21 private static final String ACTION_ERROR_AM = "ACTION_ERROR_AM";
22 private static final String ACTION_RESET_AM = "ACTION_RESET_AM";
23 private static final String ACTION_USERID_AM = "ACTION_USERID_AM";
24 private static final String ACTION_SET_USERID_SUCCESS_AM = "ACTION_SET_USERID_SUCCESS_AM";
25 private static final String ACTION_SYNC_TIME_SUCCESS_AM = "ACTION_SYNC_TIME_SUCCESS_AM";
26 private static final String ACTION_SET_USERINFO_SUCCESS_AM = "ACTION_SET_USERINFO_SUCCESS_AM";
27 private static final String ACTION_GET_USERINFO_AM = "ACTION_GET_USERINFO_AM";
28 private static final String ACTION_GET_ALARMNUM_AM = "ACTION_GET_ALARMNUM_AM";
29 private static final String ACTION_GET_ALARMINFO_AM = "ACTION_GET_ALARMINFO_AM";
30 private static final String ACTION_SET_ALARMINFO_SUCCESS_AM = "ACTION_SET_ALARMINFO_SUCCESS_AM";
31 private static final String ACTION_DELETE_ALARM_SUCCESS_AM = "ACTION_DELETE_ALARM_SUCCESS_AM";
32 private static final String ACTION_GET_ACTIVITY_REMIND_AM = "ACTION_GET_ACTIVITY_REMIND_AM";
33 private static final String ACTION_SET_ACTIVITYREMIND_SUCCESS_AM = "ACTION_SET_ACTIVITYREMIND_SUCCESS_AM";
34 private static final String ACTION_SYNC_ACTIVITY_DATA_AM = "ACTION_SYNC_ACTIVITY_DATA_AM";
35 private static final String ACTION_SYNC_SLEEP_DATA_AM = "ACTION_SYNC_SLEEP_DATA_AM";
36 private static final String ACTION_SYNC_STAGE_DATA_AM = "ACTION_SYNC_STAGE_DATA_AM";
37 private static final String ACTION_QUERY_STATE_AM = "ACTION_QUERY_STATE_AM";
38 private static final String ACTION_SYNC_REAL_DATA_AM = "ACTION_SYNC_REAL_DATA_AM";
39 private static final String ACTION_SET_BMR_SUCCESS_AM = "ACTION_SET_BMR_SUCCESS_AM";
40 private static final String ACTION_GET_SWIMINFO_AM = "ACTION_GET_SWIMINFO_AM";
41 private static final String ACTION_SET_SWIMINFO_AM = "ACTION_SET_SWIMINFO_AM";
42 private static final String ACTION_GET_RANDOM_AM = "ACTION_GET_RANDOM_AM";
43 private static final String ACTION_SET_HOUR_MODE_SUCCESS_AM = "ACTION_SET_HOUR_MODE_SUCCESS_AM";
44 private static final String ACTION_GET_HOUR_MODE_AM = "ACTION_GET_HOUR_MODE_AM";
45 private static final String ACTION_SET_DEVICE_MODE_AM = "ACTION_SET_DEVICE_MODE_AM";
46 private static final String ACTION_CLOUD_BINDING_AM_SUCCESS = "ACTION_CLOUD_BINDING_AM_SUCCESS";
47 private static final String ACTION_CLOUD_BINDING_AM_FAIL = "ACTION_CLOUD_BINDING_AM_FAIL";
48 private static final String ACTION_CLOUD_UNBINDING_AM_SUCCESS = "ACTION_CLOUD_UNBINDING_AM_SUCCESS";
49 private static final String ACTION_CLOUD_UNBINDING_AM_FAIL = "ACTION_CLOUD_UNBINDING_AM_FAIL";
50 private static final String ACTION_CLOUD_SEARCH_AM = "ACTION_CLOUD_SEARCH_AM";
51 private static final String ACTION_CLOUD_SEARCH_FAIL_AM = "ACTION_CLOUD_SEARCH_FAIL_AM";
52 private static final String ACTION_SET_PICTURE_SUCCESS_AM = "ACTION_SET_PICTURE_SUCCESS_AM";
53 private static final String ACTION_GET_PICTURE_AM = "ACTION_GET_PICTURE_AM";
54
55 private static final String ERROR_NUM_AM = "ERROR_NUM_AM";
56 private static final String ERROR_ID_ILLEGAL_ARGUMENT = "ERROR_ID_ILLEGAL_ARGUMENT";
57 private static final String ERROR_ID_VERSION_NOT_SUPPORT = "ERROR_ID_VERSION_NOT_SUPPORT";
58 private static final String ERROR_DESCRIPTION_AM = "ERROR_DESCRIPTION_AM";
59 private static final String RESET_AM = "RESET_AM";
60 private static final String USERID_AM = "USERID_AM";
61 private static final String GET_USER_AGE_AM = "GET_USER_AGE_AM";
62 private static final String GET_USER_STEP_AM = "GET_USER_STEP_AM";
63 private static final String GET_USER_HEIGHT_AM = "GET_USER_HEIGHT_AM";
64 private static final String GET_USER_SEX_AM = "GET_USER_SEX_AM";
65 private static final String GET_USER_WEIGHT_AM = "GET_USER_WEIGHT_AM";
66 private static final String GET_USER_UNIT_AM = "GET_USER_UNIT_AM";
67 private static final String GET_USER_TARGET1_AM = "GET_USER_TARGET1_AM";
68 private static final String GET_USER_TARGET2_AM = "GET_USER_TARGET2_AM";
69 private static final String GET_USER_TARGET3_AM = "GET_USER_TARGET3_AM";
70 private static final String GET_USER_SWIMTARGET_AM = "GET_USER_SWIMTARGET_AM";
71 private static final String GET_ALARMNUM_AM = "GET_ALARMNUM_AM";
72 private static final String GET_ALARMNUM_ID_AM = "GET_ALARMNUM_ID_AM";
73 private static final String GET_ALARM_CLOCK_DETAIL = "GET_ALARM_CLOCK_DETAIL";
74 private static final String GET_ALARM_ID_AM = "GET_ALARM_ID_AM";
75 private static final String GET_ALARM_TIME_AM = "GET_ALARM_TIME_AM";
76 private static final String GET_ALARM_ISREPEAT_AM = "GET_ALARM_ISREPEAT_AM";
77 private static final String GET_ALARM_WEEK_AM = "GET_ALARM_WEEK_AM";
78 private static final String GET_ALARM_WEEK_SUNDAY_AM = "GET_ALARM_WEEK_SUNDAY_AM";
79 private static final String GET_ALARM_WEEK_MONDAY_AM = "GET_ALARM_WEEK_MONDAY_AM";
80 private static final String GET_ALARM_WEEK_TUESDAY_AM = "GET_ALARM_WEEK_TUESDAY_AM";
81 private static final String GET_ALARM_WEEK_WEDNESDAY_AM = "GET_ALARM_WEEK_WEDNESDAY_AM";
82 private static final String GET_ALARM_WEEK_THURSDAY_AM = "GET_ALARM_WEEK_THURSDAY_AM";
83 private static final String GET_ALARM_WEEK_FRIDAY_AM = "GET_ALARM_WEEK_FRIDAY_AM";
84 private static final String GET_ALARM_WEEK_SATURDAY_AM = "GET_ALARM_WEEK_SATURDAY_AM";
85 private static final String GET_ALARM_ISON_AM = "GET_ALARM_ISON_AM";
86 private static final String GET_ACTIVITY_REMIND_TIME_AM = "GET_ACTIVITY_REMIND_TIME_AM";
87 private static final String GET_ACTIVITY_REMIND_ISON_AM = "GET_ACTIVITY_REMIND_ISON_AM";
88 private static final String SYNC_ACTIVITY_DATA_AM = "SYNC_ACTIVITY_DATA_AM";
89 private static final String SYNC_ACTIVITY_DATA_TIME_AM = "SYNC_ACTIVITY_DATA_TIME_AM";
90 private static final String SYNC_ACTIVITY_DATA_STEP_AM = "SYNC_ACTIVITY_DATA_STEP_AM";
91 private static final String SYNC_ACTIVITY_DATA_STEP_LENGTH_AM = "SYNC_ACTIVITY_DATA_STEP_LENGTH_AM";
92 private static final String SYNC_ACTIVITY_DATA_CALORIE_AM = "SYNC_ACTIVITY_DATA_CALORIE_AM";
93 private static final String SYNC_ACTIVITY_EACH_DATA_AM = "SYNC_ACTIVITY_EACH_DATA_AM";
94 private static final String SYNC_SLEEP_DATA_AM = "SYNC_SLEEP_DATA_AM";
95 private static final String SYNC_SLEEP_DATA_TIME_AM = "SYNC_SLEEP_DATA_TIME_AM";
96 private static final String SYNC_SLEEP_DATA_LEVEL_AM = "SYNC_SLEEP_DATA_LEVEL_AM";
97 private static final String SYNC_SLEEP_EACH_DATA_AM = "SYNC_SLEEP_EACH_DATA_AM";
98 private static final String SYNC_STAGE_DATA_AM = "SYNC_STAGE_DATA_AM";
99 private static final String SYNC_STAGE_DATA_TYPE_AM = "SYNC_STAGE_DATA_TYPE_AM";
100 private static final String SYNC_STAGE_DATA_TYPE_WORKOUT_AM = "SYNC_STAGE_DATA_TYPE_WORKOUT_AM";
101 private static final String SYNC_STAGE_DATA_TYPE_SLEEP_AM = "SYNC_STAGE_DATA_TYPE_SLEEP_AM";
102 private static final String SYNC_STAGE_DATA_TYPE_SWIM_AM = "SYNC_STAGE_DATA_TYPE_SWIM_AM";
103 private static final String SYNC_STAGE_DATA_TYPE_PAGE_VIEW_SUMMARY = "SYNC_STAGE_DATA_TYPE_PAGE_VIEW_SUMMARY";
104 private static final String SYNC_STAGE_DATA_STOP_TIME_AM = "SYNC_STAGE_DATA_STOP_TIME_AM";
105 private static final String SYNC_STAGE_DATA_USED_TIME_AM = "SYNC_STAGE_DATA_USED_TIME_AM";
106 private static final String SYNC_STAGE_DATA_WORKOUT_STEP_AM = "SYNC_STAGE_DATA_WORKOUT_STEP_AM";
107 private static final String SYNC_STAGE_DATA_DISTANCE_AM = "SYNC_STAGE_DATA_DISTANCE_AM";
108 private static final String SYNC_STAGE_DATA_CALORIE_AM = "SYNC_STAGE_DATA_CALORIE_AM";
109 private static final String SYNC_STAGE_DATA_SLEEP_EFFICIENCY_AM = "SYNC_STAGE_DATA_SLEEP_EFFICIENCY_AM";
110 private static final String SYNC_STAGE_DATA_SLEEP_IS50MIN_AM = "SYNC_STAGE_DATA_SLEEP_IS50MIN_AM";
111 private static final String SYNC_STAGE_DATA_SWIM_STROKE_AM = "SYNC_STAGE_DATA_SWIM_STROKE_AM";
112 private static final String SYNC_STAGE_DATA_SWIM_PULL_TIMES_AM = "SYNC_STAGE_DATA_SWIM_PULL_TIMES_AM";
113 private static final String SYNC_STAGE_DATA_SWIM_TURNS_AM = "SYNC_STAGE_DATA_SWIM_TURNS_AM";
114 private static final String SYNC_STAGE_DATA_SWIMPOOL_LENGTH_AM = "SYNC_STAGE_DATA_SWIMPOOL_LENGTH_AM";
115 private static final String SYNC_STAGE_DATA_SWIM_CUTINDIF_AM = "SYNC_STAGE_DATA_SWIM_CUTINDIF_AM";
116 private static final String SYNC_STAGE_DATA_SWIM_CUTOUTDIF_AM = "SYNC_STAGE_DATA_SWIM_CUTOUTDIF_AM";
117 private static final String SYNC_STAGE_DATA_SWIM_PROCESSFLAG_AM = "SYNC_STAGE_DATA_SWIM_PROCESSFLAG_AM";
118 private static final String SYNC_STAGE_DATA_VIEW_SUMMARY_DATE_AM = "SYNC_STAGE_DATA_VIEW_SUMMARY_DATE_AM";
119 private static final String SYNC_STAGE_DATA_VIEW_SUMMARY_STEP_AM = "SYNC_STAGE_DATA_VIEW_SUMMARY_STEP_AM";
120 private static final String SYNC_STAGE_DATA_VIEW_SUMMARY_DISTANCE_AM = "SYNC_STAGE_DATA_VIEW_SUMMARY_DISTANCE_AM";
121 private static final String SYNC_STAGE_DATA_VIEW_SUMMARY_CALORIE_AM = "SYNC_STAGE_DATA_VIEW_SUMMARY_CALORIE_AM";
122 private static final String SYNC_STAGE_DATA_VIEW_SUMMARY_TARGET_AM = "SYNC_STAGE_DATA_VIEW_SUMMARY_TARGET_AM";
123 private static final String SYNC_STAGE_DATA_VIEW_SUMMARY_SWIM_AM = "SYNC_STAGE_DATA_VIEW_SUMMARY_SWIM_AM";
124 private static final String QUERY_STATE_AM = "QUERY_STATE_AM";
125 private static final String QUERY_BATTERY_AM = "QUERY_BATTERY_AM";
126 private static final String SYNC_REAL_STEP_AM = "SYNC_REAL_STEP_AM";
127 private static final String SYNC_REAL_CALORIE_AM = "SYNC_REAL_CALORIE_AM";
128 private static final String SYNC_REAL_TOTALCALORIE_AM = "SYNC_REAL_TOTALCALORIE_AM";
129 private static final String GET_SWIMLANE_LENGTH_AM = "GET_SWIMLANE_LENGTH_AM";
130 private static final String GET_SWIM_SWITCH_AM = "GET_SWIM_SWITCH_AM";
131 private static final String GET_SWIM_CUTOUT_HOUR_AM = "GET_SWIM_CUTOUT_HOUR_AM";
132 private static final String GET_SWIM_CUTOUT_MINUTE_AM = "GET_SWIM_CUTOUT_MINUTE_AM";
133 private static final String GET_SWIM_UNIT_AM = "GET_SWIM_UNIT_AM";
134 private static final String GET_RANDOM_AM = "GET_RANDOM_AM";
135 private static final String AM_SWITCH_OPEN = "AM_SWITCH_OPEN";
136 private static final String AM_SWITCH_CLOSE = "AM_SWITCH_CLOSE";
137 private static final String AM_SWITCH_REPEAT = "AM_SWITCH_REPEAT";
138 private static final String AM_SEITCH_NOT_REPEAT = "AM_SEITCH_NOT_REPEAT";
139 private static final String AM_SET_MALE = "AM_SET_MALE";
140 private static final String AM_SET_FEMALE = "AM_SET_FEMALE";
141 private static final String AM_SET_UNIT_METRIC = "AM_SET_UNIT_METRIC";
142 private static final String AM_SET_UNIT_IMPERIAL_STANDARD = "AM_SET_UNIT_IMPERIAL_STANDARD";
143 private static final String AM_SET_12_HOUR_MODE = "AM_SET_12_HOUR_MODE";
144 private static final String AM_SET_24_HOUR_MODE = "AM_SET_24_HOUR_MODE";
145 private static final String AM_SET_EUROPE_12_HOUR_MODE = "AM_SET_EUROPE_12_HOUR_MODE";
146 private static final String AM_SET_EUROPE_24_HOUR_MODE = "AM_SET_EUROPE_24_HOUR_MODE";
147 private static final String AM_SET_EXCEPT_EUROPE_12_HOUR_MODE = "AM_SET_EXCEPT_EUROPE_12_HOUR_MODE";
148 private static final String AM_SET_EXCEPT_EUROPE_24_HOUR_MODE = "AM_SET_EXCEPT_EUROPE_24_HOUR_MODE";
149 private static final String GET_HOUR_MODE_AM = "GET_HOUR_MODE_AM";
150 private static final String AM_DEVICE_MODE_SLEEP = "AM_DEVICE_MODE_SLEEP";
151 private static final String AM_DEVICE_MODE_ACTIVITY = "AM_DEVICE_MODE_ACTIVITY";
152 private static final String AM_DEVICE_MODE_FLIGHT = "AM_DEVICE_MODE_FLIGHT";
153 private static final String AM_DEVICE_MODE_DRIVING = "AM_DEVICE_MODE_DRIVING";
154 private static final String CLOUD_SEARCH_AM = "CLOUD_SEARCH_AM";
155 private static final String DATAID = "DATAID";
156 private static final String GET_PICTURE_AM = "GET_PICTURE_AM";
157 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
158
159
160 public AMProfileModule(ReactApplicationContext reactContext) {
161 super(reactContext);
162 }
163
164 @Override
165 public String getName() {
166 return modelName;
167 }
168
169 @Nullable
170 @Override
171 public Map<String, Object> getConstants() {
172 Map<String, Object> constants = new HashMap<>();
173 constants.put(ACTION_ERROR_AM, AmProfile.ACTION_ERROR_AM);
174 constants.put(ACTION_RESET_AM, AmProfile.ACTION_RESET_AM);
175 constants.put(ACTION_USERID_AM, AmProfile.ACTION_USERID_AM);
176 constants.put(ACTION_SET_USERID_SUCCESS_AM, AmProfile.ACTION_SET_USERID_SUCCESS_AM);
177 constants.put(ACTION_SYNC_TIME_SUCCESS_AM, AmProfile.ACTION_SYNC_TIME_SUCCESS_AM);
178 constants.put(ACTION_SET_USERINFO_SUCCESS_AM, AmProfile.ACTION_SET_USERINFO_SUCCESS_AM);
179 constants.put(ACTION_GET_USERINFO_AM, AmProfile.ACTION_GET_USERINFO_AM);
180 constants.put(ACTION_GET_ALARMNUM_AM, AmProfile.ACTION_GET_ALARMNUM_AM);
181 constants.put(ACTION_GET_ALARMINFO_AM, AmProfile.ACTION_GET_ALARMINFO_AM);
182 constants.put(ACTION_SET_ALARMINFO_SUCCESS_AM, AmProfile.ACTION_SET_ALARMINFO_SUCCESS_AM);
183 constants.put(ACTION_DELETE_ALARM_SUCCESS_AM, AmProfile.ACTION_DELETE_ALARM_SUCCESS_AM);
184 constants.put(ACTION_GET_ACTIVITY_REMIND_AM, AmProfile.ACTION_GET_ACTIVITY_REMIND_AM);
185 constants.put(ACTION_SET_ACTIVITYREMIND_SUCCESS_AM, AmProfile.ACTION_SET_ACTIVITYREMIND_SUCCESS_AM);
186 constants.put(ACTION_SYNC_ACTIVITY_DATA_AM, AmProfile.ACTION_SYNC_ACTIVITY_DATA_AM);
187 constants.put(ACTION_SYNC_SLEEP_DATA_AM, AmProfile.ACTION_SYNC_SLEEP_DATA_AM);
188 constants.put(ACTION_SYNC_STAGE_DATA_AM, AmProfile.ACTION_SYNC_STAGE_DATA_AM);
189 constants.put(ACTION_QUERY_STATE_AM, AmProfile.ACTION_QUERY_STATE_AM);
190 constants.put(ACTION_SYNC_REAL_DATA_AM, AmProfile.ACTION_SYNC_REAL_DATA_AM);
191 constants.put(ACTION_SET_BMR_SUCCESS_AM, AmProfile.ACTION_SET_BMR_SUCCESS_AM);
192 constants.put(ACTION_GET_SWIMINFO_AM, AmProfile.ACTION_GET_SWIMINFO_AM);
193 constants.put(ACTION_SET_SWIMINFO_AM, AmProfile.ACTION_SET_SWIMINFO_AM);
194 constants.put(ACTION_GET_RANDOM_AM, AmProfile.ACTION_GET_RANDOM_AM);
195 constants.put(ACTION_SET_HOUR_MODE_SUCCESS_AM, AmProfile.ACTION_SET_HOUR_MODE_SUCCESS_AM);
196 constants.put(ACTION_GET_HOUR_MODE_AM, AmProfile.ACTION_GET_HOUR_MODE_AM);
197 constants.put(ACTION_SET_DEVICE_MODE_AM, AmProfile.ACTION_SET_DEVICE_MODE_AM);
198 constants.put(ACTION_CLOUD_BINDING_AM_SUCCESS, AmProfile.ACTION_CLOUD_BINDING_AM_SUCCESS);
199 constants.put(ACTION_CLOUD_BINDING_AM_FAIL, AmProfile.ACTION_CLOUD_BINDING_AM_FAIL);
200 constants.put(ACTION_CLOUD_UNBINDING_AM_SUCCESS, AmProfile.ACTION_CLOUD_UNBINDING_AM_SUCCESS);
201 constants.put(ACTION_CLOUD_UNBINDING_AM_FAIL, AmProfile.ACTION_CLOUD_UNBINDING_AM_FAIL);
202 constants.put(ACTION_CLOUD_SEARCH_AM, AmProfile.ACTION_CLOUD_SEARCH_AM);
203 constants.put(ACTION_CLOUD_SEARCH_FAIL_AM, AmProfile.ACTION_CLOUD_SEARCH_FAIL_AM);
204 constants.put(ACTION_SET_PICTURE_SUCCESS_AM, AmProfile.ACTION_SET_PICTURE_SUCCESS_AM);
205 constants.put(ACTION_GET_PICTURE_AM, AmProfile.ACTION_GET_PICTURE_AM);
206
207 constants.put(ERROR_NUM_AM, AmProfile.ERROR_NUM_AM);
208 constants.put(ERROR_ID_ILLEGAL_ARGUMENT, AmProfile.ERROR_ID_ILLEGAL_ARGUMENT);
209 constants.put(ERROR_ID_VERSION_NOT_SUPPORT, AmProfile.ERROR_ID_VERSION_NOT_SUPPORT);
210 constants.put(ERROR_DESCRIPTION_AM, AmProfile.ERROR_DESCRIPTION_AM);
211 constants.put(RESET_AM, AmProfile.RESET_AM);
212 constants.put(USERID_AM, AmProfile.USERID_AM);
213 constants.put(GET_USER_AGE_AM, AmProfile.GET_USER_AGE_AM);
214 constants.put(GET_USER_STEP_AM, AmProfile.GET_USER_STEP_AM);
215 constants.put(GET_USER_HEIGHT_AM, AmProfile.GET_USER_HEIGHT_AM);
216 constants.put(GET_USER_SEX_AM, AmProfile.GET_USER_SEX_AM);
217 constants.put(GET_USER_WEIGHT_AM, AmProfile.GET_USER_WEIGHT_AM);
218 constants.put(GET_USER_UNIT_AM, AmProfile.GET_USER_UNIT_AM);
219 constants.put(GET_USER_TARGET1_AM, AmProfile.GET_USER_TARGET1_AM);
220 constants.put(GET_USER_TARGET2_AM, AmProfile.GET_USER_TARGET2_AM);
221 constants.put(GET_USER_TARGET3_AM, AmProfile.GET_USER_TARGET3_AM);
222 constants.put(GET_USER_SWIMTARGET_AM, AmProfile.GET_USER_SWIMTARGET_AM);
223 constants.put(GET_ALARMNUM_AM, AmProfile.GET_ALARMNUM_AM);
224 constants.put(GET_ALARMNUM_ID_AM, AmProfile.GET_ALARMNUM_ID_AM);
225 constants.put(GET_ALARM_CLOCK_DETAIL, AmProfile.GET_ALARM_CLOCK_DETAIL);
226 constants.put(GET_ALARM_ID_AM, AmProfile.GET_ALARM_ID_AM);
227 constants.put(GET_ALARM_TIME_AM, AmProfile.GET_ALARM_TIME_AM);
228 constants.put(GET_ALARM_ISREPEAT_AM, AmProfile.GET_ALARM_ISREPEAT_AM);
229 constants.put(GET_ALARM_WEEK_AM, AmProfile.GET_ALARM_WEEK_AM);
230 constants.put(GET_ALARM_WEEK_SUNDAY_AM, AmProfile.GET_ALARM_WEEK_SUNDAY_AM);
231 constants.put(GET_ALARM_WEEK_MONDAY_AM, AmProfile.GET_ALARM_WEEK_MONDAY_AM);
232 constants.put(GET_ALARM_WEEK_TUESDAY_AM, AmProfile.GET_ALARM_WEEK_TUESDAY_AM);
233 constants.put(GET_ALARM_WEEK_WEDNESDAY_AM, AmProfile.GET_ALARM_WEEK_WEDNESDAY_AM);
234 constants.put(GET_ALARM_WEEK_THURSDAY_AM, AmProfile.GET_ALARM_WEEK_THURSDAY_AM);
235 constants.put(GET_ALARM_WEEK_FRIDAY_AM, AmProfile.GET_ALARM_WEEK_FRIDAY_AM);
236 constants.put(GET_ALARM_WEEK_SATURDAY_AM, AmProfile.GET_ALARM_WEEK_SATURDAY_AM);
237 constants.put(GET_ALARM_ISON_AM, AmProfile.GET_ALARM_ISON_AM);
238 constants.put(GET_ACTIVITY_REMIND_TIME_AM, AmProfile.GET_ACTIVITY_REMIND_TIME_AM);
239 constants.put(GET_ACTIVITY_REMIND_ISON_AM, AmProfile.GET_ACTIVITY_REMIND_ISON_AM);
240 constants.put(SYNC_ACTIVITY_DATA_AM, AmProfile.SYNC_ACTIVITY_DATA_AM);
241 constants.put(SYNC_ACTIVITY_DATA_TIME_AM, AmProfile.SYNC_ACTIVITY_DATA_TIME_AM);
242 constants.put(SYNC_ACTIVITY_DATA_STEP_AM, AmProfile.SYNC_ACTIVITY_DATA_STEP_AM);
243 constants.put(SYNC_ACTIVITY_DATA_STEP_LENGTH_AM, AmProfile.SYNC_ACTIVITY_DATA_STEP_LENGTH_AM);
244 constants.put(SYNC_ACTIVITY_DATA_CALORIE_AM, AmProfile.SYNC_ACTIVITY_DATA_CALORIE_AM);
245 constants.put(SYNC_ACTIVITY_EACH_DATA_AM, AmProfile.SYNC_ACTIVITY_EACH_DATA_AM);
246 constants.put(SYNC_SLEEP_DATA_AM, AmProfile.SYNC_SLEEP_DATA_AM);
247 constants.put(SYNC_SLEEP_DATA_TIME_AM, AmProfile.SYNC_SLEEP_DATA_TIME_AM);
248 constants.put(SYNC_SLEEP_DATA_LEVEL_AM, AmProfile.SYNC_SLEEP_DATA_LEVEL_AM);
249 constants.put(SYNC_SLEEP_EACH_DATA_AM, AmProfile.SYNC_SLEEP_EACH_DATA_AM);
250 constants.put(SYNC_STAGE_DATA_AM, AmProfile.SYNC_STAGE_DATA_AM);
251 constants.put(SYNC_STAGE_DATA_TYPE_AM, AmProfile.SYNC_STAGE_DATA_TYPE_AM);
252 constants.put(SYNC_STAGE_DATA_TYPE_WORKOUT_AM, AmProfile.SYNC_STAGE_DATA_TYPE_WORKOUT_AM);
253 constants.put(SYNC_STAGE_DATA_TYPE_SLEEP_AM, AmProfile.SYNC_STAGE_DATA_TYPE_SLEEP_AM);
254 constants.put(SYNC_STAGE_DATA_TYPE_SWIM_AM, AmProfile.SYNC_STAGE_DATA_TYPE_SWIM_AM);
255 constants.put(SYNC_STAGE_DATA_TYPE_PAGE_VIEW_SUMMARY, AmProfile.SYNC_STAGE_DATA_TYPE_PAGE_VIEW_SUMMARY);
256 constants.put(SYNC_STAGE_DATA_STOP_TIME_AM, AmProfile.SYNC_STAGE_DATA_STOP_TIME_AM);
257 constants.put(SYNC_STAGE_DATA_USED_TIME_AM, AmProfile.SYNC_STAGE_DATA_USED_TIME_AM);
258 constants.put(SYNC_STAGE_DATA_WORKOUT_STEP_AM, AmProfile.SYNC_STAGE_DATA_WORKOUT_STEP_AM);
259 constants.put(SYNC_STAGE_DATA_DISTANCE_AM, AmProfile.SYNC_STAGE_DATA_DISTANCE_AM);
260 constants.put(SYNC_STAGE_DATA_CALORIE_AM, AmProfile.SYNC_STAGE_DATA_CALORIE_AM);
261 constants.put(SYNC_STAGE_DATA_SLEEP_EFFICIENCY_AM, AmProfile.SYNC_STAGE_DATA_SLEEP_EFFICIENCY_AM);
262 constants.put(SYNC_STAGE_DATA_SLEEP_IS50MIN_AM, AmProfile.SYNC_STAGE_DATA_SLEEP_IS50MIN_AM);
263 constants.put(SYNC_STAGE_DATA_SWIM_STROKE_AM, AmProfile.SYNC_STAGE_DATA_SWIM_STROKE_AM);
264 constants.put(SYNC_STAGE_DATA_SWIM_PULL_TIMES_AM, AmProfile.SYNC_STAGE_DATA_SWIM_PULL_TIMES_AM);
265 constants.put(SYNC_STAGE_DATA_SWIM_TURNS_AM, AmProfile.SYNC_STAGE_DATA_SWIM_TURNS_AM);
266 constants.put(SYNC_STAGE_DATA_SWIMPOOL_LENGTH_AM, AmProfile.SYNC_STAGE_DATA_SWIMPOOL_LENGTH_AM);
267 constants.put(SYNC_STAGE_DATA_SWIM_CUTINDIF_AM, AmProfile.SYNC_STAGE_DATA_SWIM_CUTINDIF_AM);
268 constants.put(SYNC_STAGE_DATA_SWIM_CUTOUTDIF_AM, AmProfile.SYNC_STAGE_DATA_SWIM_CUTOUTDIF_AM);
269 constants.put(SYNC_STAGE_DATA_SWIM_PROCESSFLAG_AM, AmProfile.SYNC_STAGE_DATA_SWIM_PROCESSFLAG_AM);
270 constants.put(SYNC_STAGE_DATA_VIEW_SUMMARY_DATE_AM, AmProfile.SYNC_STAGE_DATA_VIEW_SUMMARY_DATE_AM);
271 constants.put(SYNC_STAGE_DATA_VIEW_SUMMARY_STEP_AM, AmProfile.SYNC_STAGE_DATA_VIEW_SUMMARY_STEP_AM);
272 constants.put(SYNC_STAGE_DATA_VIEW_SUMMARY_DISTANCE_AM, AmProfile.SYNC_STAGE_DATA_VIEW_SUMMARY_DISTANCE_AM);
273 constants.put(SYNC_STAGE_DATA_VIEW_SUMMARY_CALORIE_AM, AmProfile.SYNC_STAGE_DATA_VIEW_SUMMARY_CALORIE_AM);
274 constants.put(SYNC_STAGE_DATA_VIEW_SUMMARY_TARGET_AM, AmProfile.SYNC_STAGE_DATA_VIEW_SUMMARY_TARGET_AM);
275 constants.put(SYNC_STAGE_DATA_VIEW_SUMMARY_SWIM_AM, AmProfile.SYNC_STAGE_DATA_VIEW_SUMMARY_SWIM_AM);
276 constants.put(QUERY_STATE_AM, AmProfile.QUERY_STATE_AM);
277 constants.put(QUERY_BATTERY_AM, AmProfile.QUERY_BATTERY_AM);
278 constants.put(SYNC_REAL_STEP_AM, AmProfile.SYNC_REAL_STEP_AM);
279 constants.put(SYNC_REAL_CALORIE_AM, AmProfile.SYNC_REAL_CALORIE_AM);
280 constants.put(SYNC_REAL_TOTALCALORIE_AM, AmProfile.SYNC_REAL_TOTALCALORIE_AM);
281 constants.put(GET_SWIMLANE_LENGTH_AM, AmProfile.GET_SWIMLANE_LENGTH_AM);
282 constants.put(GET_SWIM_SWITCH_AM, AmProfile.GET_SWIM_SWITCH_AM);
283 constants.put(GET_SWIM_CUTOUT_HOUR_AM, AmProfile.GET_SWIM_CUTOUT_HOUR_AM);
284 constants.put(GET_SWIM_CUTOUT_MINUTE_AM, AmProfile.GET_SWIM_CUTOUT_MINUTE_AM);
285 constants.put(GET_SWIM_UNIT_AM, AmProfile.GET_SWIM_UNIT_AM);
286 constants.put(GET_RANDOM_AM, AmProfile.GET_RANDOM_AM);
287 constants.put(AM_SWITCH_OPEN, AmProfile.AM_SWITCH_OPEN);
288 constants.put(AM_SWITCH_CLOSE, AmProfile.AM_SWITCH_CLOSE);
289 constants.put(AM_SWITCH_REPEAT, AmProfile.AM_SWITCH_REPEAT);
290 constants.put(AM_SEITCH_NOT_REPEAT, AmProfile.AM_SEITCH_NOT_REPEAT);
291 constants.put(AM_SET_MALE, AmProfile.AM_SET_MALE);
292 constants.put(AM_SET_FEMALE, AmProfile.AM_SET_FEMALE);
293 constants.put(AM_SET_UNIT_METRIC, AmProfile.AM_SET_UNIT_METRIC);
294 constants.put(AM_SET_UNIT_IMPERIAL_STANDARD, AmProfile.AM_SET_UNIT_IMPERIAL_STANDARD);
295 constants.put(AM_SET_12_HOUR_MODE, AmProfile.AM_SET_12_HOUR_MODE);
296 constants.put(AM_SET_24_HOUR_MODE, AmProfile.AM_SET_24_HOUR_MODE);
297 constants.put(AM_SET_EUROPE_12_HOUR_MODE, AmProfile.AM_SET_EUROPE_12_HOUR_MODE);
298 constants.put(AM_SET_EUROPE_24_HOUR_MODE, AmProfile.AM_SET_EUROPE_24_HOUR_MODE);
299 constants.put(AM_SET_EXCEPT_EUROPE_12_HOUR_MODE, AmProfile.AM_SET_EXCEPT_EUROPE_12_HOUR_MODE);
300 constants.put(AM_SET_EXCEPT_EUROPE_24_HOUR_MODE, AmProfile.AM_SET_EXCEPT_EUROPE_24_HOUR_MODE);
301 constants.put(GET_HOUR_MODE_AM, AmProfile.GET_HOUR_MODE_AM);
302 constants.put(AM_DEVICE_MODE_SLEEP, AmProfile.AM_DEVICE_MODE_SLEEP);
303 constants.put(AM_DEVICE_MODE_ACTIVITY, AmProfile.AM_DEVICE_MODE_ACTIVITY);
304 constants.put(AM_DEVICE_MODE_FLIGHT, AmProfile.AM_DEVICE_MODE_FLIGHT);
305 constants.put(AM_DEVICE_MODE_DRIVING, AmProfile.AM_DEVICE_MODE_DRIVING);
306 constants.put(CLOUD_SEARCH_AM, AmProfile.CLOUD_SEARCH_AM);
307 constants.put(DATAID, AmProfile.DATAID);
308 constants.put(GET_PICTURE_AM, AmProfile.GET_PICTURE_AM);
309 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
310 return constants;
311 }
312}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1Module.java
new file mode 100755
index 0000000..6b19583
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1Module.java
@@ -0,0 +1,116 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableMap;
9import com.facebook.react.module.annotations.ReactModule;
10import com.ihealth.communication.control.Bg1Control;
11import com.ihealth.communication.control.Bg1Profile;
12import com.ihealth.communication.utils.Log;
13
14import org.json.JSONArray;
15import org.json.JSONException;
16import org.json.JSONObject;
17
18import java.util.HashMap;
19import java.util.Map;
20
21import javax.annotation.Nullable;
22
23/**
24 * Created by zhaoyongguang on 29/11/2016.
25 */
26@ReactModule(name = "BG1Module")
27public class BG1Module extends iHealthBaseModule {
28 private static final String TAG = BG1Module.class.getSimpleName();
29 private static final String moduleName = BG1Module.class.getSimpleName();
30 private static final String EVENT_NOTIFY = "event_notify_bg1";
31
32 public BG1Module(ReactApplicationContext reactContext) {
33 super(TAG, reactContext);
34 }
35
36 @Override
37 public String getName() {
38 return moduleName;
39 }
40
41// @ReactMethod
42// public void init(String userName, int filter, boolean showUI) {
43// //Bg1Control.getInstance().init(getReactApplicationContext(), userName, filter, showUI);
44// }
45//
46// @ReactMethod
47// public void connect() {
48// //Bg1Control.getInstance().connect();
49// }
50//
51// @ReactMethod
52// public void disconnect() {
53// //Bg1Control.getInstance().disconnect();
54// }
55
56 @ReactMethod
57 public void sendCode(String QRCode, int stripType, int measureType) {
58 Bg1Control.getInstance().sendCode(QRCode, stripType, measureType);
59 }
60
61 @ReactMethod
62 public void getBottleInfoFromQR(String QRCode) {
63 String result = Bg1Control.getBottleInfoFromQR(QRCode);
64 Log.v(TAG, "code info = " + result);
65
66 JSONObject resultJsonStr = new JSONObject();
67
68 try {
69 JSONArray jsonArray = new JSONObject(result).getJSONArray("bottleInfo");
70 resultJsonStr.put("strip_num", ((JSONObject) jsonArray.get(0)).getString("stripNum"));
71 resultJsonStr.put("expire_time", ((JSONObject) jsonArray.get(0)).getString("overDate"));
72 resultJsonStr.put("bottle_id", ((JSONObject) jsonArray.get(0)).getString("bottleId"));
73
74 } catch (JSONException e) {
75 try {
76 resultJsonStr.put("description","QRCode format error");
77 } catch (JSONException e1) {
78 e1.printStackTrace();
79 }
80 }
81
82
83 WritableMap params = Arguments.createMap();
84 params.putString("action", "action_code_analysis");
85 if (!TextUtils.isEmpty(resultJsonStr.toString())) {
86 Utils.jsonToMap(resultJsonStr.toString(), params);
87 }
88 sendEvent(EVENT_NOTIFY, params);
89 }
90
91 @Override
92 public void handleNotify(String mac, String deviceType, String action, String message) {
93 WritableMap params = Arguments.createMap();
94 params.putString("action", action);
95 params.putString("mac", mac);
96 params.putString("type", deviceType);
97 if (!TextUtils.isEmpty(message)) {
98 Utils.jsonToMap(message, params);
99 }
100 sendEvent(EVENT_NOTIFY, params);
101 Log.v(TAG, "action ----> " + action );
102 Log.v(TAG, "message ----> " + message );
103 }
104
105 /**
106 * @return a map of constants this module exports to JS. Supports JSON types.
107 */
108 @Nullable
109 @Override
110 public Map<String, Object> getConstants() {
111 final Map<String, Object> constants = new HashMap<>();
112 constants.put("Event_Notify", EVENT_NOTIFY);
113
114 return constants;
115 }
116}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1ProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1ProfileModule.java
new file mode 100755
index 0000000..f715dc4
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1ProfileModule.java
@@ -0,0 +1,176 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.Bg1Profile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by zhaoyongguang on 07/12/2016.
15 */
16@ReactModule(name = "BG1ProfileModule")
17public class BG1ProfileModule extends ReactContextBaseJavaModule {
18 private static final String name = BG1ProfileModule.class.getSimpleName();
19 /**
20 * Callback indicating the send code result of bg1 device.
21 * <ul>
22 * KeyList:
23 * <ul>
24 * <li>
25 * {@link #BG1_SENDCODE_RESULT}
26 * </li>
27 */
28 private static final String ACTION_BG1_SENDCODE_RESULT = "ACTION_BG1_SENDCODE_RESULT";
29
30 /**
31 * The send code result of bg1 device.
32 * <p/>
33 * value : 0 success; other error
34 */
35 private static final String BG1_SENDCODE_RESULT = "BG1_SENDCODE_RESULT";
36
37 /**
38 * Callback indicating the error of Bg1 device.
39 * <ul>
40 * KeyList:
41 * <ul>
42 * <li>
43 * {@link #BG1_MEASURE_ERROR}
44 * </li>
45 * </ul>
46 * eg. {"error_num_for_bg1":0}
47 * </ul>
48 */
49 private static final String ACTION_BG1_MEASURE_ERROR = "ACTION_BG1_MEASURE_ERROR";
50
51 /**
52 * Flag Error number of Bg1 device.
53 * <p>Error code and Description</p>
54 * <p>0:Battery is low.</p>
55 * <p>1:Glucose test result is out of the measurement range.</p>
56 * <p>2:Unknown interference detected, please repeat the test.</p>
57 * <p>3:Strip is used or unknown moisture detected, discard the test strip and repeat the test with a new strip..</p>
58 * <p>4:Communication error,resend the code to repeat the test. {@link Bg1Control#sendCode(String)}</p>
59 * <p>5:The environmental temperature is beyond normal range, place the meter at room temperature for at least 30 minutes, then repeat the test.</p>
60 * <p>6:The environmental temperature is beyond normal range, place the meter at room temperature for at least 30 minutes, then repeat the test.</p>
61 * <p>7:Test strip coding error.</p>
62 * <p>8:Communication error,rescan the code to repeat the test.</p>
63 * <p>9:Communication error,Repeat the test with a new test strip. If the problem persists, contact iHealth customer service for assistance.</p>
64 * <p>10:Communication error,Repeat the test with a new test strip. If the problem persists, contact iHealth customer service for assistance.</p>
65 * <p>11:Communication error,Repeat the test with a new test strip. If the problem persists, contact iHealth customer service for assistance.</p>
66 * <p>12:Glucose test result is low.</p>
67 * <p>13:Glucose test result is high.</p>
68 * <p>400:Parameters out of range.</p>
69 * <p>401:Dolby is on ,please turn it off.</p>
70 */
71 private static final String BG1_MEASURE_ERROR = "BG1_MEASURE_ERROR";
72
73 /**
74 * Callback indicating the strip in action.
75 */
76 private static final String ACTION_BG1_MEASURE_STRIP_IN = "ACTION_BG1_MEASURE_STRIP_IN";
77
78 /**
79 * Callback indicating the get blood action.
80 */
81 private static final String ACTION_BG1_MEASURE_GET_BLOOD = "ACTION_BG1_MEASURE_GET_BLOOD";
82
83 /**
84 * Callback indicating the measure result.
85 * <ul>
86 * KeyList:
87 * <ul>
88 * <li>
89 * {@link #BG1_MEASURE_RESULT}
90 * </li>
91 */
92 private static final String ACTION_BG1_MEASURE_RESULT = "ACTION_BG1_MEASURE_RESULT";
93
94 /**
95 * The measure result
96 * <p/>
97 * Range : 20-600 mg/dL
98 */
99 private static final String BG1_MEASURE_RESULT = "BG1_MEASURE_RESULT";
100
101 /**
102 * Callback indicating the strip out action.
103 */
104 private static final String ACTION_BG1_MEASURE_STRIP_OUT = "ACTION_BG1_MEASURE_STRIP_OUT";
105
106 /**
107 * Callback indicating the Bg1 device get in standby mode.
108 */
109 private static final String ACTION_BG1_MEASURE_STANDBY = "ACTION_BG1_MEASURE_STANDBY";
110
111 /**
112 * the data id
113 */
114 private static final String DATA_ID = "DATA_ID";
115
116 /**
117 * Callback indicating the code analysis result.
118 */
119 private static final String ACTION_CODE_ANALYSIS = "ACTION_CODE_ANALYSIS";
120
121
122 /**
123 * the strip number
124 */
125 private static final String STRIP_NUM_BG = "STRIP_NUM_BG";
126
127
128 /**
129 * the expire time
130 */
131 private static final String STRIP_EXPIRETIME_BG = "STRIP_EXPIRETIME_BG";
132
133
134 /**
135 * the bottle id
136 */
137 private static final String BOTTLEID_BG = "BOTTLEID_BG";
138
139 /**
140 * @return the name of this module. This will be the name used to {@code require()} this module
141 * from javascript.
142 */
143 @Override
144 public String getName() {
145 return name;
146 }
147
148 public BG1ProfileModule(ReactApplicationContext reactContext) {
149 super(reactContext);
150 }
151
152 /**
153 * @return a map of constants this module exports to JS. Supports JSON types.
154 */
155 @Nullable
156 @Override
157 public Map<String, Object> getConstants() {
158 Map<String, Object> constants = new HashMap<>();
159 constants.put(ACTION_BG1_SENDCODE_RESULT, Bg1Profile.ACTION_BG1_SENDCODE_RESULT);
160 constants.put(BG1_SENDCODE_RESULT, Bg1Profile.BG1_SENDCODE_RESULT);
161 constants.put(ACTION_BG1_MEASURE_ERROR, Bg1Profile.ACTION_BG1_MEASURE_ERROR);
162 constants.put(BG1_MEASURE_ERROR, Bg1Profile.BG1_MEASURE_ERROR);
163 constants.put(ACTION_BG1_MEASURE_STRIP_IN, Bg1Profile.ACTION_BG1_MEASURE_STRIP_IN);
164 constants.put(ACTION_BG1_MEASURE_GET_BLOOD, Bg1Profile.ACTION_BG1_MEASURE_GET_BLOOD);
165 constants.put(ACTION_BG1_MEASURE_RESULT, Bg1Profile.ACTION_BG1_MEASURE_RESULT);
166 constants.put(BG1_MEASURE_RESULT, Bg1Profile.BG1_MEASURE_RESULT);
167 constants.put(ACTION_BG1_MEASURE_STRIP_OUT, Bg1Profile.ACTION_BG1_MEASURE_STRIP_OUT);
168 constants.put(ACTION_BG1_MEASURE_STANDBY, Bg1Profile.ACTION_BG1_MEASURE_STANDBY);
169 constants.put(DATA_ID, Bg1Profile.DATA_ID);
170 constants.put(ACTION_CODE_ANALYSIS, "action_code_analysis");
171 constants.put(STRIP_NUM_BG, "strip_num");
172 constants.put(STRIP_EXPIRETIME_BG, "expire_time");
173 constants.put(BOTTLEID_BG, "bottle_id");
174 return constants;
175 }
176}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SModule.java
new file mode 100644
index 0000000..7349ca6
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SModule.java
@@ -0,0 +1,106 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Bg1sControl;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19@ReactModule(name = "BG1SModule")
20public class BG1SModule extends iHealthBaseModule {
21
22 private static final String moduleName = "BG1SModule";
23 private static final String TAG = "BG1SModule";
24 private static final String EVENT_NOTIFY = "event_notify_bg1s";
25
26 public BG1SModule(ReactApplicationContext reactContext) {
27 super(TAG, reactContext);
28 }
29
30 @Override
31 public String getName() {
32 return moduleName;
33 }
34
35 @Override
36 public Map<String, Object> getConstants() {
37 Map<String, Object> map = new HashMap<>();
38 map.put("Event_Notify", EVENT_NOTIFY);
39 return map;
40 }
41
42 @ReactMethod
43 public void getFunction(String mac) {
44 Bg1sControl Bg1sControl = getBg1sControl(mac);
45 if (Bg1sControl != null) {
46 Bg1sControl.getDeviceStatus();
47 }
48 }
49
50 @ReactMethod
51 public void measure(String mac,int measureMode) {
52 Bg1sControl Bg1sControl = getBg1sControl(mac);
53 if (Bg1sControl != null) {
54 Bg1sControl.setMeasureMode(measureMode);
55 }
56 }
57
58 @ReactMethod
59 public void disconnect(String mac) {
60 Bg1sControl Bg1sControl = getBg1sControl(mac);
61 if (Bg1sControl != null) {
62 Bg1sControl.disconnect();
63 }
64 }
65
66 private void senErrMessage(int errId) {
67 WritableMap params = Arguments.createMap();
68 params.putInt("errorid", errId);
69 sendEvent(EVENT_NOTIFY, params);
70 }
71
72 private Bg1sControl getBg1sControl(String mac) {
73 Bg1sControl Bg1sControl = iHealthDevicesManager.getInstance().getBg1sControl(mac);
74 if (Bg1sControl == null) {
75 senErrMessage(400);
76 }
77 return Bg1sControl;
78 }
79
80 @Override
81 public void handleNotify(String mac, String deviceType, String action, String message) {
82 WritableMap params = Arguments.createMap();
83 params.putString("action", action);
84 params.putString("mac", mac);
85 params.putString("type", deviceType);
86 if (!TextUtils.isEmpty(message)) {
87 Utils.jsonToMap(message, params);
88 }
89 sendEvent(EVENT_NOTIFY, params);
90 }
91
92 @ReactMethod
93 public void getAllConnectedDevices() {
94 List<String> devices = iHealthDevicesManager.getInstance().getBg1sDevices();
95 WritableMap params = Arguments.createMap();
96 if (devices.size() > 0) {
97 WritableArray array = Arguments.createArray();
98 for (String device : devices) {
99 array.pushString(device);
100 }
101 params.putArray("devices", array);
102 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
103 }
104 sendEvent(EVENT_NOTIFY, params);
105 }
106}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SProfileModule.java
new file mode 100755
index 0000000..9dd00aa
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG1SProfileModule.java
@@ -0,0 +1,225 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.Bg1Profile;
7import com.ihealth.communication.control.Bg1sProfile;
8
9import java.util.HashMap;
10import java.util.Map;
11
12import javax.annotation.Nullable;
13
14/**
15 * Created by zhaoyongguang on 07/12/2016.
16 */
17@ReactModule(name = "BG1SProfileModule")
18public class BG1SProfileModule extends ReactContextBaseJavaModule {
19 private static final String name = BG1SProfileModule.class.getSimpleName();
20 /**
21 * The action type of callback indicating the error of BG1S device.<br/>
22 * <b>KeyList of the message:</b>
23 * <ul>
24 * <li>{@link #ERROR_NUM_BG1S}</li>
25 * <li>{@link #ERROR_DESCRIPTION_BG1S}</li>
26 * </ul>
27 * <b>Example message:</b><br/>
28 * {<br/>
29 * &nbsp; &nbsp; "error": 400,<br/>
30 * &nbsp; &nbsp; "description": "getOfflineData() parameter userPstCode should be in the range [0, 19]."<br/>
31 * }<br/>
32 */
33 String ACTION_ERROR_BG1S = "action_error";
34 /**
35 * error code
36 */
37 String ERROR_NUM_BG1S = "error_num";
38 /**
39 * error description
40 */
41 String ERROR_DESCRIPTION_BG1S = "error_description";
42
43 /**
44 * The action type of callback indicating get device info.
45 */
46 String ACTION_GET_DEVICE_INFO = "action_get_device_info";
47
48 /**
49 * The action type of callback indicating set mode of measure.
50 */
51 String ACTION_SET_MEASURE_MODE = "action_set_measure_mode";
52
53 /**
54 * Callback indicating power of Battery for BG1S device.
55 */
56 String ACTION_BATTERY_BG1S = "battery_bg1s";
57
58 /**
59 * The power of Battery for BG1S device.
60 */
61 String INFO_BATTERY_BG1S = "battery";
62
63 /**
64 * The version of Blood Code for BG1S device.
65 */
66 String INFO_VERSION_CODE_BLOOD_BG1S = "info_version_code_blood_bg1s";
67
68 /**
69 * The version of CTL Code for BG1S device.
70 */
71 String INFO_VERSION_CODE_CTL_BG1S = "info_version_code_ctl_bg1s";
72
73 /**
74 * The history data status
75 * <ul>
76 * <li>0: has no history data</li>
77 * <li>1: has history data</li>
78 * </ul>
79 */
80 String INFO_HISTORY_STATUS_BG1S = "info_history_status_bg1s";
81
82
83 /**
84 * The action type of callback indicating blood drop detected.
85 */
86 String ACTION_GET_BLOOD = "action_get_blood";
87
88 /**
89 * The action type of callback indicating insertion status of test strip.
90 * <ul>
91 * <li>1: strip in</li>
92 * <li>2: strip out</li>
93 * </ul>
94 */
95 String ACTION_STRIP_INSERTION_STATUS = "action_strip_insertion_status";
96
97 /**
98 * The insertion status of test strip
99 */
100 String STRIP_INSERTION_STATUS = "insertion_status";
101
102 /**
103 * The action type of callback indicating result of measure.
104 */
105 String ACTION_MEASURE_RESULT = "action_measure_result";
106 /**
107 * The mode of measure
108 */
109 String MEASURE_MODE = "measure_mode";
110 /**
111 * The result of measure
112 */
113 String MEASURE_RESULT = "measure_result";
114 /**
115 * The status of operation
116 */
117 String OPERATION_STATUS = "status";
118
119 /**
120 * The describe of operation
121 */
122 String OPERATION_DESCRIBE = "describe";
123
124 /**
125 * The action type of callback indicating check code of device.
126 */
127 String ACTION_CHECK_CODE = "action_check_code";
128
129 /**
130 * The result of check the blood code
131 * <ul>
132 * <li>0: check the blood code is success</li>
133 * <li>other: check the blood code is fail</li>
134 * </ul>
135 */
136 String BLOOD_CHECK_CODE_RESULT = "blood_check_code_result";
137
138 /**
139 * The blood code.
140 */
141 String BLOOD_CODE = "blood_code";
142
143 /**
144 * The CRC of the blood code
145 */
146 String BLOOD_CODE_CRC = "blood_code_crc";
147
148
149 /**
150 * The result of check the blood code
151 * <ul>
152 * <li>0: check the blood code is success</li>
153 * <li>other: check the blood code is fail</li>
154 * </ul>
155 */
156 String CTL_CHECK_CODE_RESULT = "ctl_check_code_result";
157
158 /**
159 * The CTL code.
160 */
161 String CTL_CODE = "ctl_code";
162
163 /**
164 * The CRC of the CTL code
165 */
166 String CTL_CODE_CRC = "ctl_code_crc";
167
168 /**
169 * The action type of callback indicating set code of device.
170 */
171 String ACTION_SET_DEVICE_CODE = "action_set_device_code";
172
173 /**
174 * @return the name of this module. This will be the name used to {@code require()} this module
175 * from javascript.
176 */
177 @Override
178 public String getName() {
179 return name;
180 }
181
182 public BG1SProfileModule(ReactApplicationContext reactContext) {
183 super(reactContext);
184 }
185
186 /**
187 * @return a map of constants this module exports to JS. Supports JSON types.
188 */
189 @Nullable
190 @Override
191 public Map<String, Object> getConstants() {
192 Map<String, Object> constants = new HashMap<>();
193 constants.put(ACTION_ERROR_BG1S, Bg1sProfile.ACTION_ERROR_BG1S);
194 constants.put(ERROR_NUM_BG1S, Bg1sProfile.ERROR_NUM_BG1S);
195 constants.put(ERROR_DESCRIPTION_BG1S, Bg1sProfile.ERROR_DESCRIPTION_BG1S);
196
197 constants.put(ACTION_GET_DEVICE_INFO, Bg1sProfile.ACTION_GET_DEVICE_INFO);
198 constants.put(ACTION_SET_MEASURE_MODE, Bg1sProfile.ACTION_SET_MEASURE_MODE);
199 constants.put(ACTION_BATTERY_BG1S, Bg1sProfile.ACTION_BATTERY_BG1S);
200 constants.put(INFO_BATTERY_BG1S, Bg1sProfile.INFO_BATTERY_BG1S);
201 constants.put(INFO_VERSION_CODE_BLOOD_BG1S, Bg1sProfile.INFO_VERSION_CODE_BLOOD_BG1S);
202 constants.put(INFO_VERSION_CODE_CTL_BG1S, Bg1sProfile.INFO_VERSION_CODE_CTL_BG1S);
203 constants.put(INFO_HISTORY_STATUS_BG1S, Bg1sProfile.INFO_HISTORY_STATUS_BG1S);
204
205 constants.put(ACTION_GET_BLOOD, Bg1sProfile.ACTION_GET_BLOOD);
206 constants.put(ACTION_STRIP_INSERTION_STATUS, Bg1sProfile.ACTION_STRIP_INSERTION_STATUS);
207 constants.put(STRIP_INSERTION_STATUS, Bg1sProfile.STRIP_INSERTION_STATUS);
208 constants.put(ACTION_MEASURE_RESULT, Bg1sProfile.ACTION_MEASURE_RESULT);
209 constants.put(MEASURE_MODE, Bg1sProfile.MEASURE_MODE);
210 constants.put(MEASURE_RESULT, Bg1sProfile.MEASURE_RESULT);
211
212 constants.put(OPERATION_STATUS, Bg1sProfile.OPERATION_STATUS);
213 constants.put(OPERATION_DESCRIBE, Bg1sProfile.OPERATION_DESCRIBE);
214
215 constants.put(ACTION_CHECK_CODE, Bg1sProfile.ACTION_CHECK_CODE);
216 constants.put(BLOOD_CHECK_CODE_RESULT, Bg1sProfile.BLOOD_CHECK_CODE_RESULT);
217 constants.put(BLOOD_CODE, Bg1sProfile.BLOOD_CODE);
218 constants.put(BLOOD_CODE_CRC, Bg1sProfile.BLOOD_CODE_CRC);
219 constants.put(CTL_CHECK_CODE_RESULT, Bg1sProfile.CTL_CHECK_CODE_RESULT);
220 constants.put(CTL_CODE, Bg1sProfile.CTL_CODE);
221 constants.put(CTL_CODE_CRC, Bg1sProfile.CTL_CODE_CRC);
222 constants.put(ACTION_SET_DEVICE_CODE, Bg1sProfile.ACTION_SET_DEVICE_CODE);
223 return constants;
224 }
225}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5Module.java
new file mode 100755
index 0000000..8932de4
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5Module.java
@@ -0,0 +1,323 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Bg5Control;
13import com.ihealth.communication.control.Bg5Profile;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import org.json.JSONArray;
17import org.json.JSONException;
18import org.json.JSONObject;
19
20import java.util.HashMap;
21import java.util.List;
22import java.util.Map;
23
24
25/**
26 * Created by gyl on 2016/11/15.
27 */
28
29@ReactModule(name = "BG5Module")
30public class BG5Module extends iHealthBaseModule {
31
32 private static final String modelName = "BG5Module";
33 private static final String TAG = modelName;
34
35 private static final String EVENT_NOTIFY = "event_notify_bg5";
36
37 public BG5Module(ReactApplicationContext reactContext) {
38 super(TAG, reactContext);
39 }
40
41 @Override
42 public String getName() {
43 return modelName;
44 }
45
46 @Override
47 public Map<String, Object> getConstants() {
48 Map<String, Object> map = new HashMap<>();
49 map.put("Event_Notify", EVENT_NOTIFY);
50 return map;
51 }
52
53 @ReactMethod
54 public void holdLink(String mac) {
55 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
56 if (bg5Control != null) {
57 Log.v("aa", "bg5Control != null ");
58 bg5Control.holdLink();
59 } else {
60 Log.v("aa", "bg5Control == null ");
61 WritableMap params = Arguments.createMap();
62 params.putInt("errorid", 400);
63 sendEvent(EVENT_NOTIFY, params);
64 }
65 }
66
67 @ReactMethod
68 public void setTime(String mac) {
69 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
70 if (bg5Control != null) {
71 bg5Control.setTime();
72 } else {
73 WritableMap params = Arguments.createMap();
74 params.putInt("errorid", 400);
75 sendEvent(EVENT_NOTIFY, params);
76 }
77 }
78
79 @ReactMethod
80 public void setUnit(String mac, double type) {
81 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
82 if (bg5Control != null) {
83 bg5Control.setUnit((int) type);
84 } else {
85 WritableMap params = Arguments.createMap();
86 params.putInt("errorid", 400);
87 sendEvent(EVENT_NOTIFY, params);
88 }
89 }
90
91 @ReactMethod
92 public void getBattery(String mac) {
93 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
94 if (bg5Control != null) {
95 bg5Control.getBattery();
96 } else {
97 WritableMap params = Arguments.createMap();
98 params.putInt("errorid", 400);
99 sendEvent(EVENT_NOTIFY, params);
100 }
101 }
102
103 @ReactMethod
104 public void startMeasure(String mac, double type) {
105 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
106 if (bg5Control != null) {
107 bg5Control.startMeasure((int) type);
108 } else {
109 WritableMap params = Arguments.createMap();
110 params.putInt("errorid", 400);
111 sendEvent(EVENT_NOTIFY, params);
112 }
113 }
114
115 @ReactMethod
116 public void getOfflineData(String mac) {
117 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
118 if (bg5Control != null) {
119 bg5Control.getOfflineData();
120 } else {
121 WritableMap params = Arguments.createMap();
122 params.putInt("errorid", 400);
123 sendEvent(EVENT_NOTIFY, params);
124 }
125 }
126
127 @ReactMethod
128 public void deleteOfflineData(String mac) {
129 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
130 if (bg5Control != null) {
131 bg5Control.deleteOfflineData();
132 } else {
133 WritableMap params = Arguments.createMap();
134 params.putInt("errorid", 400);
135 sendEvent(EVENT_NOTIFY, params);
136 }
137 }
138
139// @ReactMethod
140// public void setBottleMessage(String mac, String QRCode) {
141// Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
142// if (bg5Control != null) {
143// bg5Control.setBottleMessage(QRCode);
144// } else {
145// WritableMap params = Arguments.createMap();
146// params.putInt("errorid", 400);
147// sendEvent(EVENT_NOTIFY, params);
148// }
149// }
150
151// @ReactMethod
152// public void setBottleMessage(String mac , String QRCode, final int stripNum, final String overDate) {
153// Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
154// if (bg5Control != null) {
155// bg5Control.setBottleMessage(QRCode, stripNum, overDate);
156// } else {
157// WritableMap params = Arguments.createMap();
158// params.putInt("errorid", 400);
159// iHealthDeviceManagerModule.sendEvent("Error", params);
160// }
161// }
162
163 @ReactMethod
164 public void setBottleMessageWithInfo(String mac, int stripType, int measureType, String QRCode, int stripNum, String overDate) {
165 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
166 if (bg5Control != null) {
167 bg5Control.setBottleMessageWithInfo(stripType, measureType, QRCode, stripNum, overDate);
168 } else {
169 WritableMap params = Arguments.createMap();
170 params.putInt("errorid", 400);
171 sendEvent(EVENT_NOTIFY, params);
172 }
173 }
174
175 @ReactMethod
176 public void getBottleMessage(String mac) {
177 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
178 if (bg5Control != null) {
179 bg5Control.getBottleMessage();
180 } else {
181 WritableMap params = Arguments.createMap();
182 params.putInt("errorid", 400);
183 sendEvent(EVENT_NOTIFY, params);
184 }
185 }
186
187 @ReactMethod
188 public void setBottleId(String mac, String bottleID) {
189 long bottleId = 0;
190 try {
191 bottleId = Long.parseLong(bottleID);
192 } catch (NumberFormatException e) {
193 WritableMap params = Arguments.createMap();
194 params.putInt("errorid", 400);
195 sendEvent(EVENT_NOTIFY, params);
196 return;
197 }
198 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
199 if (bg5Control != null) {
200 bg5Control.setBottleId(bottleId);
201 } else {
202 WritableMap params = Arguments.createMap();
203 params.putInt("errorid", 400);
204 sendEvent(EVENT_NOTIFY, params);
205 }
206 }
207
208 @ReactMethod
209 public void getBottleId(String mac) {
210 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
211 if (bg5Control != null) {
212 bg5Control.getBottleId();
213 } else {
214 WritableMap params = Arguments.createMap();
215 params.putInt("errorid", 400);
216 sendEvent(EVENT_NOTIFY, params);
217 }
218 }
219
220 @ReactMethod
221 public void disConnect(String mac) {
222 Bg5Control bg5Control = iHealthDevicesManager.getInstance().getBg5Control(mac);
223 if (bg5Control != null) {
224 bg5Control.disconnect();
225 } else {
226 WritableMap params = Arguments.createMap();
227 params.putInt("errorid", 400);
228 sendEvent(EVENT_NOTIFY, params);
229 }
230 }
231
232 @ReactMethod
233 public void Logger(String tag, String msg) {
234 Log.e(TAG, msg);
235 }
236
237 @ReactMethod
238 public void getBottleInfoFromQR(String QRCode) {
239 String result = Bg5Control.getBottleInfoFromQR(QRCode);
240 Log.v(TAG, "code info = " + result);
241
242 JSONObject resultJsonStr = new JSONObject();
243
244 try {
245 JSONArray jsonArray = new JSONObject(result).getJSONArray("bottleInfo");
246 resultJsonStr.put("strip_num", ((JSONObject) jsonArray.get(0)).getString("stripNum"));
247 resultJsonStr.put("expire_time", ((JSONObject) jsonArray.get(0)).getString("overDate"));
248 resultJsonStr.put("bottle_id", ((JSONObject) jsonArray.get(0)).getString("bottleId"));
249
250 } catch (JSONException e) {
251 try {
252 resultJsonStr.put("description", "QRCode format error");
253 } catch (JSONException e1) {
254 e1.printStackTrace();
255 }
256 }
257
258
259 WritableMap params = Arguments.createMap();
260 params.putString("action", "action_code_analysis");
261 if (!TextUtils.isEmpty(resultJsonStr.toString())) {
262 Utils.jsonToMap(resultJsonStr.toString(), params);
263 }
264 sendEvent(EVENT_NOTIFY, params);
265 }
266
267 @ReactMethod
268 public void getAllConnectedDevices() {
269 List<String> devices = iHealthDevicesManager.getInstance().getBg5Devices();
270 WritableMap params = Arguments.createMap();
271 if (devices.size() > 0) {
272 WritableArray array = Arguments.createArray();
273 for (String device : devices) {
274 array.pushString(device);
275 }
276 params.putArray("devices", array);
277 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
278 }
279 sendEvent(EVENT_NOTIFY, params);
280 }
281
282 @Override
283 public void handleNotify(String mac, String deviceType, String action, String message) {
284 WritableMap params = Arguments.createMap();
285 params.putString("action", action);
286 params.putString("mac", mac);
287 params.putString("type", deviceType);
288 switch (action) {
289
290 //只需要Action就代表成功
291 case Bg5Profile.ACTION_KEEP_LINK:
292 case Bg5Profile.ACTION_SET_TIME:
293 case Bg5Profile.ACTION_SET_UNIT:
294 case Bg5Profile.ACTION_START_MEASURE:
295 case Bg5Profile.ACTION_DELETE_HISTORICAL_DATA:
296 case Bg5Profile.ACTION_SET_BOTTLE_ID_SUCCESS:
297 case Bg5Profile.ACTION_STRIP_IN:
298 case Bg5Profile.ACTION_STRIP_OUT:
299 case Bg5Profile.ACTION_GET_BLOOD:
300
301 sendEvent(EVENT_NOTIFY, params);
302 break;
303
304 case Bg5Profile.ACTION_BATTERY_BG:
305 case Bg5Profile.ACTION_HISTORICAL_NUM_BG:
306 case Bg5Profile.ACTION_HISTORICAL_DATA_BG:
307 case Bg5Profile.ACTION_SET_BOTTLE_MESSAGE_SUCCESS:
308 case Bg5Profile.ACTION_GET_CODEINFO:
309 case Bg5Profile.ACTION_GET_BOTTLEID:
310 case Bg5Profile.ACTION_ERROR_BG:
311 case Bg5Profile.ACTION_ONLINE_RESULT_BG:
312
313 if (!TextUtils.isEmpty(message)) {
314 Utils.jsonToMap(message, params);
315 }
316 sendEvent(EVENT_NOTIFY, params);
317 break;
318
319 default:
320 break;
321 }
322 }
323}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SModule.java
new file mode 100644
index 0000000..783835f
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SModule.java
@@ -0,0 +1,185 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Bg5Profile;
13import com.ihealth.communication.control.Bg5sControl;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.text.ParseException;
17import java.text.SimpleDateFormat;
18import java.util.Date;
19import java.util.HashMap;
20import java.util.List;
21import java.util.Map;
22
23import static com.ihealth.communication.control.Bg5Profile.ACTION_HISTORICAL_DATA_BG;
24
25/**
26 * @author chenxuewei
27 * @date 04/19/2019
28 */
29@ReactModule(name = "BG5SModule")
30public class BG5SModule extends iHealthBaseModule {
31
32 private static final String TAG = BG5SModule.class.getName();
33
34 private static final String ModelName = "BG5SModule";
35 private static final String EVENT_NOTIFY = "event_notify_bg5s";
36
37 public BG5SModule(ReactApplicationContext reactContext) {
38 super(TAG, reactContext);
39 }
40
41 @Override
42 public String getName() {
43 return ModelName;
44 }
45
46 @Override
47 public Map<String, Object> getConstants() {
48 Map<String, Object> map = new HashMap<>();
49 map.put("Event_Notify", EVENT_NOTIFY);
50 return map;
51 }
52
53 @ReactMethod
54 public void getStatusInfo(String mac) {
55 Bg5sControl bg5sControl = getBg5sControl(mac);
56 if (bg5sControl != null) {
57 bg5sControl.getStatusInfo();
58 }
59 }
60
61 @ReactMethod
62 public void setTime(String mac, String date, float timezone) {
63 Bg5sControl bg5sControl = getBg5sControl(mac);
64 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
65 try {
66 Date temp = formatter.parse(date);
67 if (bg5sControl != null) {
68 bg5sControl.setTime(temp, timezone);
69 }
70 } catch (ParseException e) {
71 Log.i(TAG, "time format need yyyy-MM-dd HH:mm:ss");
72 }
73
74 }
75
76 @ReactMethod
77 public void setUnit(String mac, int unitType) {
78 Bg5sControl bg5sControl = getBg5sControl(mac);
79 if (bg5sControl != null) {
80 bg5sControl.setUnit(unitType);
81 }
82 }
83
84 @ReactMethod
85 public void deleteUsedStrip(String mac) {
86 Bg5sControl bg5sControl = getBg5sControl(mac);
87 if (bg5sControl != null) {
88 bg5sControl.deleteUsedStrip();
89 }
90 }
91
92 @ReactMethod
93 public void deleteOfflineData(String mac) {
94 Bg5sControl bg5sControl = getBg5sControl(mac);
95 if (bg5sControl != null) {
96 bg5sControl.deleteOfflineData();
97 }
98 }
99
100 @ReactMethod
101 public void getOfflineData(String mac) {
102 Bg5sControl bg5sControl = getBg5sControl(mac);
103 if (bg5sControl != null) {
104 bg5sControl.getOfflineData();
105 }
106 }
107
108 @ReactMethod
109 public void setOfflineModel(String mac, boolean enable) {
110 Bg5sControl bg5sControl = getBg5sControl(mac);
111 if (bg5sControl != null) {
112 bg5sControl.setOfflineMeasurementMode(enable);
113 }
114 }
115
116 @ReactMethod
117 public void startMeasure(String mac, int measureType) {
118 Bg5sControl bg5sControl = getBg5sControl(mac);
119 if (bg5sControl != null) {
120 bg5sControl.startMeasure(measureType);
121 }
122 }
123
124 @ReactMethod
125 public void adjustOfflineData(String mac, String timeString, String originData) {
126 Bg5sControl bg5sControl = getBg5sControl(mac);
127 if (bg5sControl != null) {
128 String offlineData = bg5sControl.adjustOfflineData(timeString, originData);
129 WritableMap params = Arguments.createMap();
130 params.putString(Bg5Profile.HISTORICAL_DATA_BG, offlineData);
131 params.putString("action", "action_adjust_offline_data");
132 sendEvent(EVENT_NOTIFY, params);
133 }
134 }
135
136 @ReactMethod
137 public void disconnect(String mac) {
138 Bg5sControl bg5sControl = getBg5sControl(mac);
139 if (bg5sControl != null) {
140 bg5sControl.disconnect();
141 }
142 }
143
144 @ReactMethod
145 public void getAllConnectedDevices() {
146 List<String> devices = iHealthDevicesManager.getInstance().getBg5sDevices();
147 WritableMap params = Arguments.createMap();
148 if (devices.size() > 0) {
149
150 WritableArray array = Arguments.createArray();
151 for (String device : devices) {
152 array.pushString(device);
153 }
154 params.putArray("devices", array);
155 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
156 }
157 sendEvent(EVENT_NOTIFY, params);
158 }
159
160 private void senErrMessage(int errId) {
161 WritableMap params = Arguments.createMap();
162 params.putInt("errorid", errId);
163 sendEvent(EVENT_NOTIFY, params);
164 }
165
166 private Bg5sControl getBg5sControl(String mac) {
167 Bg5sControl bg5sControl = iHealthDevicesManager.getInstance().getBg5sControl(mac);
168 if (bg5sControl == null) {
169 senErrMessage(400);
170 }
171 return bg5sControl;
172 }
173
174 @Override
175 public void handleNotify(String mac, String deviceType, String action, String message) {
176 WritableMap params = Arguments.createMap();
177 params.putString("action", action);
178 params.putString("mac", mac);
179 params.putString("type", deviceType);
180 if (!TextUtils.isEmpty(message)) {
181 Utils.jsonToMap(message, params);
182 }
183 sendEvent(EVENT_NOTIFY, params);
184 }
185}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SProfileModule.java
new file mode 100644
index 0000000..e9d8140
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BG5SProfileModule.java
@@ -0,0 +1,113 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.Bg5Profile;
7import com.ihealth.communication.control.Bg5sProfile;
8
9import java.util.HashMap;
10import java.util.Map;
11
12import javax.annotation.Nullable;
13
14@ReactModule(name = "BG5SProfileModule")
15public class BG5SProfileModule extends ReactContextBaseJavaModule {
16
17 private static final String modelName = "BG5SProfileModule";
18 private static final String TAG = modelName;
19
20 private static final String ACTION_ERROR = "action_error";
21 private static final String ACTION_SET_TIME = "action_set_time";
22 private static final String ACTION_SET_UNIT = "action_set_unit";
23 private static final String ACTION_SEND_CODE = "action_send_code";
24 private static final String ACTION_DELETE_USED_STRIP = "action_delete_used_strip";
25 private static final String ACTION_DELETE_OFFLINE_DATA = "action_delete_offline_data";
26 private static final String ACTION_GET_OFFLINE_DATA = "action_get_offline_data";
27 private static final String ACTION_START_MEASURE = "action_start_measure";
28 private static final String ACTION_KEEP_LINK = "action_keep_link";
29 private static final String ACTION_STRIP_IN = "action_strip_in";
30 private static final String ACTION_GET_BLOOD = "action_get_blood";
31 private static final String ACTION_STRIP_OUT = "action_strip_out";
32 private static final String ACTION_RESULT = "action_result";
33 private static final String ACTION_GET_STATUS_INFO = "action_get_status_info";
34 private static final String ACTION_SET_OFFLINE_MEASUREMENT_MODE = "action_set_offline_measurement_mode";
35 private static final String ACTION_ENTER_CHARGED_STATE = "action_enter_charged_state";
36 private static final String ACTION_LEAVE_CHARGED_STATE = "action_leave_charged_state";
37 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
38
39 private static final String ERROR_NUM = "error_num";
40 private static final String ERROR_DESCRIPTION = "error_description";
41 private static final String INFO_BATTERY_LEVEL = "info_battery_level";
42 private static final String INFO_TIME = "info_time";
43 private static final String INFO_TIMEZONE = "info_timezone";
44 private static final String INFO_USED_STRIP = "info_used_strip";
45 private static final String INFO_OFFLINE_DATA_NUM = "info_offline_data_num";
46 private static final String INFO_CODE_VERSION_BLOOD = "info_code_version_blood";
47 private static final String INFO_CODE_VERSION_CTL = "info_code_version_ctl";
48 private static final String INFO_UNIT = "info_unit";
49 private static final String SEND_CODE_RESULT = "send_code_result";
50 private static final String OFFLINE_DATA = "offline_data";
51 private static final String DATA_TIME_PROOF = "data_time_proof";
52 private static final String DATA_MEASURE_TIME = "data_measure_time";
53 private static final String DATA_MEASURE_TIMEZONE = "data_measure_timezone";
54 private static final String DATA_VALUE = "data_value";
55 private static final String RESULT_VALUE = "result_value";
56 private static final String DATA_ID = "dataID";
57
58 public BG5SProfileModule(ReactApplicationContext reactContext) {
59 super(reactContext);
60 }
61
62 @Override
63 public String getName() {
64 return modelName;
65 }
66
67 @Nullable
68 @Override
69 public Map<String, Object> getConstants() {
70
71 final Map<String, Object> constants = new HashMap<>();
72
73 constants.put(ACTION_ERROR, Bg5sProfile.ACTION_ERROR);
74 constants.put(ACTION_SET_TIME, Bg5sProfile.ACTION_SET_TIME);
75 constants.put(ACTION_SET_UNIT, Bg5sProfile.ACTION_SET_UNIT);
76 constants.put(ACTION_SEND_CODE, Bg5sProfile.ACTION_SEND_CODE);
77 constants.put(ACTION_START_MEASURE, Bg5sProfile.ACTION_START_MEASURE);
78 constants.put(ACTION_DELETE_USED_STRIP, Bg5sProfile.ACTION_DELETE_USED_STRIP);
79 constants.put(ACTION_DELETE_OFFLINE_DATA, Bg5sProfile.ACTION_DELETE_OFFLINE_DATA);
80 constants.put(ACTION_GET_OFFLINE_DATA, Bg5sProfile.ACTION_GET_OFFLINE_DATA);
81 constants.put(ACTION_KEEP_LINK, Bg5sProfile.ACTION_KEEP_LINK);
82 constants.put(ACTION_STRIP_IN, Bg5sProfile.ACTION_STRIP_IN);
83 constants.put(ACTION_STRIP_OUT, Bg5sProfile.ACTION_STRIP_OUT);
84 constants.put(ACTION_GET_BLOOD, Bg5sProfile.ACTION_GET_BLOOD);
85 constants.put(ACTION_RESULT, Bg5sProfile.ACTION_RESULT);
86 constants.put(ACTION_GET_STATUS_INFO, Bg5sProfile.ACTION_GET_STATUS_INFO);
87 constants.put(ACTION_SET_OFFLINE_MEASUREMENT_MODE, Bg5sProfile.ACTION_SET_OFFLINE_MEASUREMENT_MODE);
88 constants.put(ACTION_ENTER_CHARGED_STATE, Bg5sProfile.ACTION_ENTER_CHARGED_STATE);
89 constants.put(ACTION_LEAVE_CHARGED_STATE, Bg5sProfile.ACTION_LEAVE_CHARGED_STATE);
90 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
91
92 constants.put(ERROR_NUM, Bg5sProfile.ERROR_NUM);
93 constants.put(ERROR_DESCRIPTION, Bg5sProfile.ERROR_DESCRIPTION);
94 constants.put(INFO_BATTERY_LEVEL, Bg5sProfile.INFO_BATTERY_LEVEL);
95 constants.put(INFO_TIME, Bg5sProfile.INFO_TIME);
96 constants.put(INFO_TIMEZONE, Bg5sProfile.INFO_TIMEZONE);
97 constants.put(INFO_USED_STRIP, Bg5sProfile.INFO_USED_STRIP);
98 constants.put(INFO_OFFLINE_DATA_NUM, Bg5sProfile.INFO_OFFLINE_DATA_NUM);
99 constants.put(INFO_CODE_VERSION_BLOOD, Bg5sProfile.INFO_CODE_VERSION_BLOOD);
100 constants.put(INFO_CODE_VERSION_CTL, Bg5sProfile.INFO_CODE_VERSION_CTL);
101 constants.put(INFO_UNIT, Bg5sProfile.INFO_UNIT);
102 constants.put(SEND_CODE_RESULT, Bg5sProfile.SEND_CODE_RESULT);
103 constants.put(OFFLINE_DATA, Bg5sProfile.OFFLINE_DATA);
104 constants.put(DATA_TIME_PROOF, Bg5sProfile.DATA_TIME_PROOF);
105 constants.put(DATA_MEASURE_TIME, Bg5sProfile.DATA_MEASURE_TIME);
106 constants.put(DATA_MEASURE_TIMEZONE, Bg5sProfile.DATA_MEASURE_TIMEZONE);
107 constants.put(DATA_VALUE, Bg5sProfile.DATA_VALUE);
108 constants.put(RESULT_VALUE, Bg5sProfile.RESULT_VALUE);
109 constants.put(DATA_ID, Bg5sProfile.DATA_ID);
110
111 return constants;
112 }
113}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BGProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BGProfileModule.java
new file mode 100755
index 0000000..256bb13
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BGProfileModule.java
@@ -0,0 +1,146 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.Bg5Profile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by gaoyuanlong on 16/11/17.
15 */
16@ReactModule(name = "BGProfileModule")
17public class BGProfileModule extends ReactContextBaseJavaModule {
18
19 private static final String modelName = "BGProfileModule";
20 private static final String TAG = modelName;
21
22 private static final String ACTION_KEEP_LINK = "ACTION_KEEP_LINK";
23 private static final String ACTION_SET_TIME = "ACTION_SET_TIME";
24 private static final String ACTION_SET_UNIT = "ACTION_SET_UNIT";
25 private static final String ACTION_GET_BATTERY = "ACTION_GET_BATTERY";
26 private static final String ACTION_START_MEASURE = "ACTION_START_MEASURE";
27 private static final String ACTION_GET_OFFLINEDATA_COUNT = "ACTION_GET_OFFLINEDATA_COUNT";
28 private static final String ACTION_GET_OFFLINEDATA = "ACTION_GET_OFFLINEDATA";
29 private static final String ACTION_DELETE_OFFLINEDATA = "ACTION_DELETE_OFFLINEDATA";
30 private static final String ACTION_SET_BOTTLEMESSAGE = "ACTION_SET_BOTTLEMESSAGE";
31 private static final String ACTION_GET_BOTTLEMESSAGE = "ACTION_GET_BOTTLEMESSAGE";
32 private static final String ACTION_SET_BOTTLEID = "ACTION_SET_BOTTLEID";
33 private static final String ACTION_GET_BOTTLEID = "ACTION_GET_BOTTLEID";
34 private static final String ACTION_ERROR_BG = "ACTION_ERROR_BG";
35 private static final String ACTION_STRIP_IN = "ACTION_STRIP_IN";
36 private static final String ACTION_STRIP_OUT = "ACTION_STRIP_OUT";
37 private static final String ACTION_GET_BLOOD = "ACTION_GET_BLOOD";
38 private static final String ACTION_ONLINE_RESULT_BG = "ACTION_ONLINE_RESULT_BG";
39
40
41// private static final String KEEP_LINK = "KEEP_LINK";
42// private static final String SET_TIME = "SET_TIME";
43// private static final String SET_UNIT = "SET_UNIT";
44 private static final String GET_BATTERY = "GET_BATTERY";
45// private static final String START_MEASURE = "START_MEASURE";
46 private static final String GET_OFFLINEDATA_COUNT = "GET_OFFLINEDATA_COUNT";
47 private static final String GET_OFFLINEDATA = "GET_OFFLINEDATA";
48// private static final String DELETE_OFFLINEDATA = "DELETE_OFFLINEDATA";
49 private static final String SET_BOTTLEMESSAGE = "SET_BOTTLEMESSAGE";
50 private static final String START_MODE = "START_MODE";
51 private static final String GET_EXPIRECTIME = "GET_EXPIRECTIME";
52 private static final String GET_USENUM = "GET_USENUM";
53// private static final String SET_BOTTLEID = "SET_BOTTLEID";
54 private static final String GET_BOTTLEID = "GET_BOTTLEID";
55 private static final String ERROR_NUM_BG = "ERROR_NUM_BG";
56 private static final String ERROR_DESCRIPTION_BG = "ERROR_DESCRIPTION_BG";
57 private static final String ONLINE_RESULT_BG = "ONLINE_RESULT_BG";
58 private static final String DATA_ID = "DATA_ID";
59
60 /**
61 * Callback indicating the code analysis result.
62 */
63 private static final String ACTION_CODE_ANALYSIS = "ACTION_CODE_ANALYSIS";
64
65
66 /**
67 * the strip number
68 */
69 private static final String STRIP_NUM_BG = "STRIP_NUM_BG";
70
71
72 /**
73 * the expire time
74 */
75 private static final String STRIP_EXPIRETIME_BG = "STRIP_EXPIRETIME_BG";
76
77
78 /**
79 * the bottle id
80 */
81 private static final String BOTTLEID_BG = "BOTTLEID_BG";
82
83 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
84
85
86 public BGProfileModule(ReactApplicationContext reactContext) {
87 super(reactContext);
88 }
89
90 @Override
91 public String getName() {
92 return modelName;
93 }
94
95 @Nullable
96 @Override
97 public Map<String, Object> getConstants() {
98
99 final Map<String, Object> constants = new HashMap<>();
100
101 constants.put(ACTION_KEEP_LINK, Bg5Profile.ACTION_KEEP_LINK);
102 constants.put(ACTION_SET_TIME, Bg5Profile.ACTION_SET_TIME);
103 constants.put(ACTION_SET_UNIT, Bg5Profile.ACTION_SET_UNIT);
104 constants.put(ACTION_GET_BATTERY, Bg5Profile.ACTION_BATTERY_BG);
105 constants.put(ACTION_START_MEASURE, Bg5Profile.ACTION_START_MEASURE);
106 constants.put(ACTION_GET_OFFLINEDATA_COUNT, Bg5Profile.ACTION_HISTORICAL_NUM_BG);
107 constants.put(ACTION_GET_OFFLINEDATA, Bg5Profile.ACTION_HISTORICAL_DATA_BG);
108 constants.put(ACTION_DELETE_OFFLINEDATA, Bg5Profile.ACTION_DELETE_HISTORICAL_DATA);
109 constants.put(ACTION_SET_BOTTLEMESSAGE, Bg5Profile.ACTION_SET_BOTTLE_MESSAGE_SUCCESS);
110 constants.put(ACTION_GET_BOTTLEMESSAGE, Bg5Profile.ACTION_GET_CODEINFO);
111 constants.put(ACTION_SET_BOTTLEID, Bg5Profile.ACTION_SET_BOTTLE_ID_SUCCESS);
112 constants.put(ACTION_GET_BOTTLEID, Bg5Profile.ACTION_GET_BOTTLEID);
113 constants.put(ACTION_ERROR_BG, Bg5Profile.ACTION_ERROR_BG);
114 constants.put(ACTION_STRIP_IN, Bg5Profile.ACTION_STRIP_IN);
115 constants.put(ACTION_STRIP_OUT, Bg5Profile.ACTION_STRIP_OUT);
116 constants.put(ACTION_GET_BLOOD, Bg5Profile.ACTION_GET_BLOOD);
117 constants.put(ACTION_ONLINE_RESULT_BG, Bg5Profile.ACTION_ONLINE_RESULT_BG);
118
119
120// constants.put(KEEP_LINK, Bg5Profile.KEEP_LINK);
121// constants.put(SET_TIME, Bg5Profile.SET_TIME);
122// constants.put(SET_UNIT, Bg5Profile.SET_UNIT);
123 constants.put(GET_BATTERY, Bg5Profile.BATTERY_BG);
124// constants.put(START_MEASURE, Bg5Profile.START_MEASURE);
125 constants.put(GET_OFFLINEDATA_COUNT, Bg5Profile.HISTORICAL_NUM_BG);
126 constants.put(GET_OFFLINEDATA, Bg5Profile.HISTORICAL_DATA_BG);
127// constants.put(DELETE_OFFLINEDATA, Bg5Profile.DELETE_HISTORICAL_DATA);
128 constants.put(SET_BOTTLEMESSAGE, Bg5Profile.SET_BOTTLE_MESSAGE);
129 constants.put(START_MODE,Bg5Profile.START_MODE_EXTRA);
130 constants.put(GET_EXPIRECTIME, Bg5Profile.GET_EXPIRECTIME);
131 constants.put(GET_USENUM, Bg5Profile.GET_USENUM);
132 constants.put(GET_BOTTLEID, Bg5Profile.GET_BOTTLEID);
133// constants.put(SET_BOTTLEID, Bg5Profile.SET_BOTTLE_MESSAGE);
134 constants.put(ERROR_NUM_BG, Bg5Profile.ERROR_NUM_BG);
135 constants.put(ERROR_DESCRIPTION_BG, Bg5Profile.ERROR_DESCRIPTION_BG);
136 constants.put(ONLINE_RESULT_BG, Bg5Profile.ONLINE_RESULT_BG);
137 constants.put(DATA_ID, Bg5Profile.DATA_ID);
138
139 constants.put(ACTION_CODE_ANALYSIS, "action_code_analysis");
140 constants.put(STRIP_NUM_BG, "strip_num");
141 constants.put(STRIP_EXPIRETIME_BG, "expire_time");
142 constants.put(BOTTLEID_BG, "bottle_id");
143 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
144 return constants;
145 }
146}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP3LModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP3LModule.java
new file mode 100755
index 0000000..587a06b
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP3LModule.java
@@ -0,0 +1,133 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.Bp3lControl;
12import com.ihealth.communication.control.BpProfile;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import org.json.JSONException;
16import org.json.JSONObject;
17
18import java.util.HashMap;
19import java.util.List;
20import java.util.Map;
21
22/**
23 * Created by zhangxu on 16/11/14.
24 */
25@ReactModule(name = "BP3LModule")
26public class BP3LModule extends iHealthBaseModule {
27 private String modelName = "BP3LModule";
28 private static final String TAG = "BP3LModule";
29
30 private static final String EVENT_NOTIFY = "event_notify_bp3l";
31
32 public BP3LModule(ReactApplicationContext reactContext) {
33 super(TAG, reactContext);
34 }
35
36 @Override
37 public String getName() {
38 return modelName;
39 }
40
41 @Override
42 public Map<String, Object> getConstants() {
43 Map<String, Object> map = new HashMap<>();
44 map.put("Event_Notify", EVENT_NOTIFY);
45 return map;
46 }
47
48
49 @ReactMethod
50 public void startMeasure(String mac) {
51 Bp3lControl bp3lControl = iHealthDevicesManager.getInstance().getBp3lControl(mac);
52 if (bp3lControl != null) {
53 bp3lControl.startMeasure();
54 } else {
55 WritableMap params = Arguments.createMap();
56 params.putInt("errorid",400);
57 sendEvent("Error", params);
58 }
59 }
60
61
62 @ReactMethod
63 public void stopMeasure(String mac) {
64 Bp3lControl bp3lControl = iHealthDevicesManager.getInstance().getBp3lControl(mac);
65 if (bp3lControl != null) {
66 bp3lControl.interruptMeasure();
67 } else {
68 WritableMap params = Arguments.createMap();
69 params.putInt("errorid",400);
70 sendEvent("Error", params);
71 }
72 }
73
74 @ReactMethod
75 public void getBattery(String mac) {
76 Bp3lControl bp3lControl = iHealthDevicesManager.getInstance().getBp3lControl(mac);
77 if (bp3lControl != null) {
78 bp3lControl.getBattery();
79 }else {
80 WritableMap params = Arguments.createMap();
81 params.putInt("errorid",400);
82 sendEvent("Error",params);
83 }
84 }
85
86 @ReactMethod
87 public void disconnect(String mac) {
88 Bp3lControl bp3lControl = iHealthDevicesManager.getInstance().getBp3lControl(mac);
89 if (bp3lControl != null) {
90 bp3lControl.disconnect();
91 }else {
92 WritableMap params = Arguments.createMap();
93 params.putInt("errorid",400);
94 sendEvent("Error",params);
95 }
96 }
97
98 @Override
99 public void handleNotify(String mac, String deviceType, String action, String message) {
100 if (action.equals(BpProfile.ACTION_ONLINE_RESULT_BP)) {
101 try {
102 JSONObject jsonObject = new JSONObject(message);
103 jsonObject.remove(BpProfile.MEASUREMENT_HSD_BP);
104 message = jsonObject.toString();
105 } catch (JSONException e) {
106 e.printStackTrace();
107 }
108 }
109 WritableMap params = Arguments.createMap();
110 params.putString("action", action);
111 params.putString("mac", mac);
112 params.putString("type", deviceType);
113 if (!TextUtils.isEmpty(message)) {
114 Utils.jsonToMap(message, params);
115 }
116 sendEvent(EVENT_NOTIFY, params);
117 }
118
119 @ReactMethod
120 public void getAllConnectedDevices() {
121 List<String> devices = iHealthDevicesManager.getInstance().getBp3lDevices();
122 WritableMap params = Arguments.createMap();
123 if (devices.size() > 0) {
124 WritableArray array = Arguments.createArray();
125 for (String device : devices) {
126 array.pushString(device);
127 }
128 params.putArray("devices", array);
129 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
130 }
131 sendEvent(EVENT_NOTIFY, params);
132 }
133}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP550BTModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP550BTModule.java
new file mode 100755
index 0000000..41023b5
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP550BTModule.java
@@ -0,0 +1,159 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.Bp550BTControl;
12import com.ihealth.communication.control.BpProfile;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19/**
20 * Created by zhangxu on 16/11/20.
21 */
22@ReactModule(name = "BP550BTModule")
23public class BP550BTModule extends iHealthBaseModule {
24 private static final String modelName = "BP550BTModule";
25 private static final String TAG = "BP550BTModule";
26
27 private static final String EVENT_NOTIFY = "event_notify_bp550bt";
28
29 public BP550BTModule(ReactApplicationContext reactContext) {
30 super(TAG, reactContext);
31 }
32
33 @Override
34 public String getName() {
35 return modelName;
36 }
37
38 @Override
39 public Map<String, Object> getConstants() {
40 Map<String, Object> map = new HashMap<>();
41 map.put("Event_Notify", EVENT_NOTIFY);
42 return map;
43 }
44
45 @ReactMethod
46 public void getBattery(String mac) {
47 Bp550BTControl bp550BTControl = iHealthDevicesManager.getInstance().getBp550BTControl(mac);
48
49 if (bp550BTControl != null) {
50 bp550BTControl.getBattery();
51 } else {
52 WritableMap params = Arguments.createMap();
53 params.putInt("errorid", 400);
54 sendEvent("Error", params);
55 }
56 }
57
58 @ReactMethod
59 public void getOffLineNum(String mac) {
60 Bp550BTControl bp550BTControl = iHealthDevicesManager.getInstance().getBp550BTControl(mac);
61 if (bp550BTControl != null) {
62 bp550BTControl.getOfflineNum();
63 } else {
64 WritableMap params = Arguments.createMap();
65 params.putInt("errorid", 400);
66 sendEvent("Error", params);
67 }
68 }
69
70 @ReactMethod
71 public void getOffLineData(String mac) {
72 Bp550BTControl bp550BTControl = iHealthDevicesManager.getInstance().getBp550BTControl(mac);
73 ;
74 if (bp550BTControl != null) {
75 bp550BTControl.getOfflineData();
76 } else {
77 WritableMap params = Arguments.createMap();
78 params.putInt("errorid", 400);
79 sendEvent("Error", params);
80 }
81 }
82
83 @ReactMethod
84 public void getFunctionInfo(String mac) {
85 Bp550BTControl bp550BTControl = iHealthDevicesManager.getInstance().getBp550BTControl(mac);
86 if (bp550BTControl != null) {
87 bp550BTControl.getFunctionInfo();
88 } else {
89 WritableMap params = Arguments.createMap();
90 params.putInt("errorid", 400);
91 sendEvent("Error", params);
92 }
93 }
94
95 @ReactMethod
96 public void disconnect(String mac) {
97 Bp550BTControl bp550BTControl = iHealthDevicesManager.getInstance().getBp550BTControl(mac);
98 if (bp550BTControl != null) {
99 bp550BTControl.disconnect();
100 } else {
101 WritableMap params = Arguments.createMap();
102 params.putInt("errorid", 400);
103 sendEvent("Error", params);
104 }
105 }
106
107 @Override
108 public void handleNotify(String mac, String deviceType, String action, String message) {
109 switch (action) {
110 case BpProfile.ACTION_BATTERY_BP:
111
112 break;
113 case BpProfile.ACTION_ZOREING_BP:
114
115 break;
116 case BpProfile.ACTION_ZOREOVER_BP:
117
118 break;
119 case BpProfile.ACTION_ONLINE_PRESSURE_BP:
120
121 break;
122 case BpProfile.ACTION_ONLINE_PULSEWAVE_BP:
123
124 break;
125 case BpProfile.ACTION_ONLINE_RESULT_BP:
126
127 break;
128 default:
129 break;
130 }
131 WritableMap params = Arguments.createMap();
132 params.putString("action", action);
133 params.putString("mac", mac);
134 if (deviceType.equals("KN-550BT")) {
135 params.putString("type", "KN550");
136 } else {
137 params.putString("type", deviceType);
138 }
139 if (!TextUtils.isEmpty(message)) {
140 Utils.jsonToMap(message, params);
141 }
142 sendEvent(EVENT_NOTIFY, params);
143 }
144
145 @ReactMethod
146 public void getAllConnectedDevices() {
147 List<String> devices = iHealthDevicesManager.getInstance().getBp550BTDevices();
148 WritableMap params = Arguments.createMap();
149 if (devices.size() > 0) {
150 WritableArray array = Arguments.createArray();
151 for (String device : devices) {
152 array.pushString(device);
153 }
154 params.putArray("devices", array);
155 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
156 }
157 sendEvent(EVENT_NOTIFY, params);
158 }
159}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5Module.java
new file mode 100755
index 0000000..e190ad7
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5Module.java
@@ -0,0 +1,193 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Bp5Control;
13import com.ihealth.communication.control.BpProfile;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import org.json.JSONException;
17import org.json.JSONObject;
18
19import java.util.HashMap;
20import java.util.List;
21import java.util.Map;
22
23/**
24 * Created by jing on 16/10/24.
25 */
26@ReactModule(name = "BP5Module")
27public class BP5Module extends iHealthBaseModule {
28
29 private static final String modelName = "BP5Module";
30 private static final String TAG = "BP5Module";
31 private static final String EVENT_NOTIFY = "event_notify_bp5";
32
33 public BP5Module(ReactApplicationContext reactContext) {
34 super(TAG, reactContext);
35 }
36
37
38 @Override
39 public String getName() {
40 return modelName;
41 }
42
43 @Override
44 public Map<String, Object> getConstants() {
45 Map<String, Object> map = new HashMap<>();
46 map.put("Event_Notify", EVENT_NOTIFY);
47 return map;
48 }
49
50 @ReactMethod
51 public void startMeasure(String mac) {
52 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
53 if (bp5Control != null) {
54 bp5Control.startMeasure();
55 } else {
56 WritableMap params = Arguments.createMap();
57 params.putInt("errorid",400);
58 sendEvent("Error", params);
59 }
60 }
61
62 @ReactMethod
63 public void stopMeasure(String mac) {
64 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
65 if (bp5Control != null) {
66 bp5Control.interruptMeasure();
67 } else {
68 WritableMap params = Arguments.createMap();
69 params.putInt("errorid",400);
70 sendEvent("Error", params);
71 }
72 }
73 @ReactMethod
74 public void getBattery(String mac) {
75 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
76 if (bp5Control != null) {
77 bp5Control.getBattery();
78 }else {
79 WritableMap params = Arguments.createMap();
80 params.putInt("errorid",400);
81 sendEvent("Error", params);
82 }
83 }
84 @ReactMethod
85 public void enbleOffline(String mac) {
86 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
87 if (bp5Control != null) {
88 bp5Control.enbleOffline();
89 }else {
90 WritableMap params = Arguments.createMap();
91 params.putInt("errorid",400);
92 sendEvent("Error", params);
93 }
94 }
95 @ReactMethod
96 public void disableOffline(String mac) {
97 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
98 if (bp5Control != null) {
99 bp5Control.disableOffline();
100 }else {
101 WritableMap params = Arguments.createMap();
102 params.putInt("errorid",400);
103 sendEvent("Error", params);
104 }
105 }
106 @ReactMethod
107 public void isEnableOffline(String mac) {
108 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
109 if (bp5Control != null) {
110 bp5Control.isEnableOffline();
111 }else {
112 WritableMap params = Arguments.createMap();
113 params.putInt("errorid",400);
114 sendEvent("Error", params);
115 }
116 }
117
118 @ReactMethod
119 public void getOfflineNum(String mac) {
120 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
121 if (bp5Control != null) {
122 bp5Control.getOfflineNum();
123 }else {
124 WritableMap params = Arguments.createMap();
125 params.putInt("errorid",400);
126 sendEvent("Error", params);
127 }
128 }
129 @ReactMethod
130 public void getOfflineData(String mac) {
131 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
132 if (bp5Control != null) {
133 bp5Control.getOfflineData();
134 }else {
135 WritableMap params = Arguments.createMap();
136 params.putInt("errorid",400);
137 sendEvent("Error", params);
138 }
139 }
140
141 @ReactMethod
142 public void disconnect(String mac) {
143 Bp5Control bp5Control = iHealthDevicesManager.getInstance().getBp5Control(mac);
144 if (bp5Control != null) {
145 bp5Control.disconnect();
146 }else {
147 WritableMap params = Arguments.createMap();
148 params.putInt("errorid",400);
149 sendEvent("Error",params);
150 }
151 }
152
153 @ReactMethod
154 public void Logger(String tag, String msg) {
155 Log.e(TAG, msg);
156 }
157
158 @Override
159 public void handleNotify(String mac, String deviceType, String action, String message) {
160 if (action.equals(BpProfile.ACTION_ONLINE_RESULT_BP)) {
161 try {
162 JSONObject jsonObject = new JSONObject(message);
163 jsonObject.remove(BpProfile.MEASUREMENT_HSD_BP);
164 message = jsonObject.toString();
165 } catch (JSONException e) {
166 e.printStackTrace();
167 }
168 }
169 WritableMap params = Arguments.createMap();
170 params.putString("action", action);
171 params.putString("mac", mac);
172 params.putString("type", deviceType);
173 if (!TextUtils.isEmpty(message)) {
174 Utils.jsonToMap(message, params);
175 }
176 sendEvent(EVENT_NOTIFY, params);
177 }
178
179 @ReactMethod
180 public void getAllConnectedDevices() {
181 List<String> devices = iHealthDevicesManager.getInstance().getBp5Devices();
182 WritableMap params = Arguments.createMap();
183 if (devices.size() > 0) {
184 WritableArray array = Arguments.createArray();
185 for (String device : devices) {
186 array.pushString(device);
187 }
188 params.putArray("devices", array);
189 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
190 }
191 sendEvent(EVENT_NOTIFY, params);
192 }
193}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5SModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5SModule.java
new file mode 100644
index 0000000..6a99caf
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP5SModule.java
@@ -0,0 +1,155 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Bp5sControl;
13import com.ihealth.communication.control.BpProfile;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.util.HashMap;
17import java.util.List;
18import java.util.Map;
19
20@ReactModule(name = "BP5SModule")
21public class BP5SModule extends iHealthBaseModule {
22
23 private static final String moduleName = "BP5SModule";
24 private static final String TAG = "BP5SModule";
25 private static final String EVENT_NOTIFY = "event_notify_bp5s";
26
27 public BP5SModule(ReactApplicationContext reactContext) {
28 super(TAG, reactContext);
29 }
30
31 @Override
32 public String getName() {
33 return moduleName;
34 }
35
36 @Override
37 public Map<String, Object> getConstants() {
38 Map<String, Object> map = new HashMap<>();
39 map.put("Event_Notify", EVENT_NOTIFY);
40 return map;
41 }
42
43 @ReactMethod
44 public void getBattery(String mac) {
45 Bp5sControl bp5sControl = getBp5sControl(mac);
46 if (bp5sControl != null) {
47 bp5sControl.getBattery();
48 }
49 }
50
51 @ReactMethod
52 public void getOffLineNum(String mac) {
53 Bp5sControl bp5sControl = getBp5sControl(mac);
54 if (bp5sControl != null) {
55 bp5sControl.getOfflineDataNum();
56 }
57 }
58
59 @ReactMethod
60 public void getOffLineData(String mac) {
61 Bp5sControl bp5sControl = getBp5sControl(mac);
62 if (bp5sControl != null) {
63 bp5sControl.getOfflineData();
64 }
65 }
66
67 @ReactMethod
68 public void getFunctionInfo(String mac) {
69 Bp5sControl bp5sControl = getBp5sControl(mac);
70 if (bp5sControl != null) {
71 bp5sControl.getFunctionInfo();
72 }
73 }
74
75 @ReactMethod
76 public void startMeasure(String mac) {
77 Bp5sControl bp5sControl = getBp5sControl(mac);
78 if (bp5sControl != null) {
79 bp5sControl.startMeasure();
80 }
81 }
82
83 @ReactMethod
84 public void stopMeasure(String mac) {
85 Bp5sControl bp5sControl = getBp5sControl(mac);
86 if (bp5sControl != null) {
87 bp5sControl.interruptMeasure();
88 }
89 }
90
91 @ReactMethod
92 public void enbleOffline(String mac, int mode) {
93 Bp5sControl bp5sControl = getBp5sControl(mac);
94 if (bp5sControl != null) {
95 bp5sControl.setMode(mode);
96 }
97 }
98
99 @ReactMethod
100 public void deleteData(String mac) {
101 Bp5sControl bp5sControl = getBp5sControl(mac);
102 if (bp5sControl != null) {
103 bp5sControl.deleteMemoryData();
104 }
105 }
106
107 @ReactMethod
108 public void disconnect(String mac) {
109 Bp5sControl bp5sControl = getBp5sControl(mac);
110 if (bp5sControl != null) {
111 bp5sControl.disconnect();
112 }
113 }
114
115 private void senErrMessage(int errId) {
116 WritableMap params = Arguments.createMap();
117 params.putInt("errorid", errId);
118 sendEvent(EVENT_NOTIFY, params);
119 }
120
121 private Bp5sControl getBp5sControl(String mac) {
122 Bp5sControl bp5sControl = iHealthDevicesManager.getInstance().getBp5sControl(mac);
123 if (bp5sControl == null) {
124 senErrMessage(400);
125 }
126 return bp5sControl;
127 }
128
129 @Override
130 public void handleNotify(String mac, String deviceType, String action, String message) {
131 WritableMap params = Arguments.createMap();
132 params.putString("action", action);
133 params.putString("mac", mac);
134 params.putString("type", deviceType);
135 if (!TextUtils.isEmpty(message)) {
136 Utils.jsonToMap(message, params);
137 }
138 sendEvent(EVENT_NOTIFY, params);
139 }
140
141 @ReactMethod
142 public void getAllConnectedDevices() {
143 List<String> devices = iHealthDevicesManager.getInstance().getBp5sDevices();
144 WritableMap params = Arguments.createMap();
145 if (devices.size() > 0) {
146 WritableArray array = Arguments.createArray();
147 for (String device : devices) {
148 array.pushString(device);
149 }
150 params.putArray("devices", array);
151 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
152 }
153 sendEvent(EVENT_NOTIFY, params);
154 }
155}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7Module.java
new file mode 100755
index 0000000..f68b93c
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7Module.java
@@ -0,0 +1,148 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.Bp7Control;
12import com.ihealth.communication.control.BpProfile;
13import com.ihealth.communication.control.Po1Control;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.util.HashMap;
17import java.util.List;
18import java.util.Map;
19
20@ReactModule(name = "BP7Module")
21public class BP7Module extends iHealthBaseModule {
22
23 private static final String moduleName = BP7Module.class.getSimpleName();
24 private static final String TAG = BP7Module.class.getSimpleName();
25
26 private static final String EVENT_NOTIFY = "event_notify_bp7";
27
28 public BP7Module(ReactApplicationContext reactContext) {
29 super(TAG, reactContext);
30 }
31
32 @Override
33 public String getName() {
34 return moduleName;
35 }
36
37 @Override
38 public Map<String, Object> getConstants() {
39 Map<String, Object> map = new HashMap<>();
40 map.put("Event_Notify", EVENT_NOTIFY);
41 return map;
42 }
43
44 private void senErrMessage(int errId) {
45 WritableMap params = Arguments.createMap();
46 params.putInt("errorid", errId);
47 sendEvent(EVENT_NOTIFY, params);
48 }
49
50 private Bp7Control getBp7Control(String mac) {
51 Bp7Control bp7Control = iHealthDevicesManager.getInstance().getBp7Control(mac);
52 if (bp7Control == null) {
53 senErrMessage(400);
54 }
55 return bp7Control;
56 }
57
58 @ReactMethod
59 public void getBattery(String mac) {
60 Bp7Control bp7Control = getBp7Control(mac);
61 if (bp7Control != null) {
62 bp7Control.getBattery();
63 }
64 }
65
66 @ReactMethod
67 public void startMeasure(String mac) {
68 Bp7Control bp7Control = getBp7Control(mac);
69 if (bp7Control != null) {
70 bp7Control.startMeasure();
71 }
72 }
73
74 @ReactMethod
75 public void stopMeasure(String mac) {
76 Bp7Control bp7Control = getBp7Control(mac);
77 if (bp7Control != null) {
78 bp7Control.interruptMeasure();
79 }
80 }
81
82 @ReactMethod
83 public void enableOfflineMeasurement(String mac) {
84 Bp7Control bp7Control = getBp7Control(mac);
85 if (bp7Control != null) {
86 bp7Control.enableOffline();
87 }
88 }
89
90 @ReactMethod
91 public void getOfflineNum(String mac) {
92 Bp7Control bp7Control = getBp7Control(mac);
93 if (bp7Control != null) {
94 bp7Control.getOfflineNum();
95 }
96 }
97
98 @ReactMethod
99 public void getOfflineData(String mac) {
100 Bp7Control bp7Control = getBp7Control(mac);
101 if (bp7Control != null) {
102 bp7Control.getOfflineData();
103 }
104 }
105
106 @ReactMethod
107 public void conformAngle(String mac) {
108 Bp7Control bp7Control = getBp7Control(mac);
109 if (bp7Control != null) {
110 bp7Control.conformAngle();
111 }
112 }
113
114 @ReactMethod
115 public void disconnect(String mac) {
116 Bp7Control bp7Control = getBp7Control(mac);
117 if (bp7Control != null) {
118 bp7Control.disconnect();
119 }
120 }
121
122 public void handleNotify(String mac, String deviceType, String action, String message) {
123 WritableMap params = Arguments.createMap();
124 params.putString("action", action);
125 params.putString("mac", mac);
126 params.putString("type", deviceType);
127 if (!TextUtils.isEmpty(message)) {
128 Utils.jsonToMap(message, params);
129 }
130 sendEvent(EVENT_NOTIFY, params);
131 }
132
133 @ReactMethod
134 public void getAllConnectedDevices() {
135 List<String> devices = iHealthDevicesManager.getInstance().getBp7sDevices();
136 WritableMap params = Arguments.createMap();
137 if (devices.size() > 0) {
138 WritableArray array = Arguments.createArray();
139 for (String device : devices) {
140 array.pushString(device);
141 }
142 params.putArray("devices", array);
143 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
144 }
145 sendEvent(EVENT_NOTIFY, params);
146 }
147
148}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7SModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7SModule.java
new file mode 100755
index 0000000..bc4f109
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BP7SModule.java
@@ -0,0 +1,176 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.Bp7sControl;
12import com.ihealth.communication.control.BpProfile;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19/**
20 * Created by zhangxu on 16/11/20.
21 */
22@ReactModule(name = "BP7SModule")
23public class BP7SModule extends iHealthBaseModule {
24
25 private static final String moduleName = "BP7SModule";
26 private static final String TAG = "BP7SModule";
27
28 private static final String EVENT_NOTIFY = "event_notify_bp7s";
29
30 public BP7SModule(ReactApplicationContext reactContext) {
31 super(TAG, reactContext);
32 }
33
34 @Override
35 public String getName() {
36 return moduleName;
37 }
38
39 @Override
40 public Map<String, Object> getConstants() {
41 Map<String, Object> map = new HashMap<>();
42 map.put("Event_Notify", EVENT_NOTIFY);
43 return map;
44 }
45
46 @ReactMethod
47 public void getBattery(String mac) {
48 Bp7sControl bp7sControl = iHealthDevicesManager.getInstance().getBp7sControl(mac);
49 if (bp7sControl != null) {
50 bp7sControl.getBattery();
51 }else {
52 WritableMap params = Arguments.createMap();
53 params.putInt("errorid",400);
54 sendEvent("Error", params);
55 }
56 }
57
58 @ReactMethod
59 public void getOffLineNum(String mac) {
60 Bp7sControl bp7sControl = iHealthDevicesManager.getInstance().getBp7sControl(mac);
61 if (bp7sControl != null) {
62 bp7sControl.getOfflineNum();
63 }else {
64 WritableMap params = Arguments.createMap();
65 params.putInt("errorid",400);
66 sendEvent("Error", params);
67 }
68 }
69 @ReactMethod
70 public void getOffLineData(String mac) {
71 Bp7sControl bp7sControl = iHealthDevicesManager.getInstance().getBp7sControl(mac);
72 if (bp7sControl != null) {
73 bp7sControl.getOfflineData();
74 }else {
75 WritableMap params = Arguments.createMap();
76 params.putInt("errorid",400);
77 sendEvent("Error", params);
78 }
79 }
80 @ReactMethod
81 public void setUnit(String mac, int unit) {
82 Bp7sControl bp7sControl = iHealthDevicesManager.getInstance().getBp7sControl(mac);
83 if (bp7sControl != null) {
84 bp7sControl.setUnit(unit);
85 }else {
86 WritableMap params = Arguments.createMap();
87 params.putInt("errorid",400);
88 sendEvent("Error", params);
89 }
90 }
91 @ReactMethod
92 public void angleSet(String mac, int leftUpper,int leftLow, int rightUpper, int rightLow) {
93 Bp7sControl bp7sControl = iHealthDevicesManager.getInstance().getBp7sControl(mac);
94 if (bp7sControl != null) {
95 bp7sControl.angleSet((byte)leftUpper,(byte)leftLow,(byte)rightUpper,(byte)rightLow);
96 }else {
97 WritableMap params = Arguments.createMap();
98 params.putInt("errorid",400);
99 sendEvent("Error", params);
100 }
101 }
102 @ReactMethod
103 public void getFunctionInfo(String mac) {
104 Bp7sControl bp7sControl = iHealthDevicesManager.getInstance().getBp7sControl(mac);
105 if (bp7sControl != null) {
106 bp7sControl.getFunctionInfo();
107 }else {
108 WritableMap params = Arguments.createMap();
109 params.putInt("errorid",400);
110 sendEvent("Error", params);
111 }
112 }
113
114 @ReactMethod
115 public void disconnect(String mac) {
116 Bp7sControl bp7sControl = iHealthDevicesManager.getInstance().getBp7sControl(mac);
117 if (bp7sControl != null) {
118 bp7sControl.disconnect();
119 }else {
120 WritableMap params = Arguments.createMap();
121 params.putInt("errorid",400);
122 sendEvent("Error",params);
123 }
124 }
125
126
127 public void handleNotify(String mac, String deviceType, String action, String message) {
128 switch (action) {
129 case BpProfile.ACTION_BATTERY_BP:
130
131 break;
132 case BpProfile.ACTION_ZOREING_BP:
133
134 break;
135 case BpProfile.ACTION_ZOREOVER_BP:
136
137 break;
138 case BpProfile.ACTION_ONLINE_PRESSURE_BP:
139
140 break;
141 case BpProfile.ACTION_ONLINE_PULSEWAVE_BP:
142
143 break;
144 case BpProfile.ACTION_ONLINE_RESULT_BP:
145
146 break;
147 default:
148 break;
149 }
150
151 WritableMap params = Arguments.createMap();
152 params.putString("action", action);
153 params.putString("mac", mac);
154 params.putString("type", deviceType);
155 if (!TextUtils.isEmpty(message)) {
156 Utils.jsonToMap(message, params);
157 }
158 sendEvent(EVENT_NOTIFY, params);
159 }
160
161 @ReactMethod
162 public void getAllConnectedDevices() {
163 List<String> devices = iHealthDevicesManager.getInstance().getBp7sDevices();
164 WritableMap params = Arguments.createMap();
165 if (devices.size() > 0) {
166 WritableArray array = Arguments.createArray();
167 for (String device : devices) {
168 array.pushString(device);
169 }
170 params.putArray("devices", array);
171 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
172 }
173 sendEvent(EVENT_NOTIFY, params);
174 }
175
176}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BPProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BPProfileModule.java
new file mode 100755
index 0000000..e92b417
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BPProfileModule.java
@@ -0,0 +1,168 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.BpProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by zhangxu on 16/11/16.
15 */
16@ReactModule(name = "BPProfileModule")
17public class BPProfileModule extends ReactContextBaseJavaModule {
18
19
20 private static final String modelName = "BPProfileModule";
21 private static final String TAG = "BPProfileModule";
22
23
24 private static final String ACTION_ERROR_BP = "ACTION_ERROR_BP";
25 private static final String ERROR_NUM_BP = "ERROR_NUM_BP";
26 private static final String ERROR_DESCRIPTION_BP = "ERROR_DESCRIPTION_BP";
27
28 //battery
29 private static final String ACTION_BATTERY_BP = "ACTION_BATTERY_BP";
30 private static final String BATTERY_BP = "BATTERY_BP";
31
32 private static final String ACTION_ZOREING_BP = "ACTION_ZOREING_BP";
33 private static final String ACTION_ZOREOVER_BP = "ACTION_ZOREOVER_BP";
34
35 private static final String ACTION_ONLINE_PRESSURE_BP = "ACTION_ONLINE_PRESSURE_BP";
36 private static final String BLOOD_PRESSURE_BP = "BLOOD_PRESSURE_BP";
37
38 private static final String ACTION_ONLINE_PULSEWAVE_BP = "ACTION_ONLINE_PULSEWAVE_BP";
39 private static final String FLAG_HEARTBEAT_BP = "FLAG_HEARTBEAT_BP";
40 private static final String PULSEWAVE_BP = "PULSEWAVE_BP";
41
42 private static final String ACTION_ONLINE_RESULT_BP = "ACTION_ONLINE_RESULT_BP";
43 private static final String HIGH_BLOOD_PRESSURE_BP = "HIGH_BLOOD_PRESSURE_BP";
44 private static final String LOW_BLOOD_PRESSURE_BP = "LOW_BLOOD_PRESSURE_BP";
45 private static final String PULSE_BP = "PULSE_BP";
46 private static final String MEASUREMENT_AHR_BP = "MEASUREMENT_AHR_BP";
47 private static final String MEASUREMENT_HSD_BP = "MEASUREMENT_HSD_BP";
48 private static final String DATAID = "DATAID";
49
50 private static final String ACTION_HISTORICAL_NUM_BP = "ACTION_HISTORICAL_NUM_BP";
51 private static final String HISTORICAL_NUM_BP = "HISTORICAL_NUM_BP";
52
53
54 private static final String ACTION_HISTORICAL_DATA_BP = "ACTION_HISTORICAL_DATA_BP";
55 private static final String HISTORICAL_DATA_BP = "HISTORICAL_DATA_BP";
56 private static final String MEASUREMENT_DATE_BP = "MEASUREMENT_DATE_BP";
57 private static final String MEASUREMENT_STRAT_ANGLE_BP = "MEASUREMENT_STRAT_ANGLE_BP";
58 private static final String MEASUREMENT_ANGLE_CHANGE_BP = "MEASUREMENT_ANGLE_CHANGE_BP";
59 private static final String MEASUREMENT_HAND_BP = "MEASUREMENT_HAND_BP";
60
61 private static final String ACTION_HISTORICAL_OVER_BP = "ACTION_HISTORICAL_OVER_BP";
62
63 private static final String ACTION_FUNCTION_INFORMATION_BP = "ACTION_FUNCTION_INFORMATION_BP";
64 private static final String FUNCTION_IS_UPAIR_MEASURE = "FUNCTION_IS_UPAIR_MEASURE";
65 private static final String FUNCTION_IS_ARM_MEASURE = "FUNCTION_IS_ARM_MEASURE";
66 private static final String FUNCTION_HAVE_ANGLE_SENSOR = "FUNCTION_HAVE_ANGLE_SENSOR";
67 private static final String FUNCTION_HAVE_OFFLINE = "FUNCTION_HAVE_OFFLINE";
68 private static final String FUNCTION_HAVE_HSD = "FUNCTION_HAVE_HSD";
69 private static final String FUNCTION_HAVE_ANGLE_SETTING = "FUNCTION_HAVE_ANGLE_SETTING";
70 private static final String FUNCTION_IS_MULTI_UPLOAD = "FUNCTION_IS_MULTI_UPLOAD";
71 private static final String FUNCTION_HAVE_SELF_UPDATE = "FUNCTION_HAVE_SELF_UPDATE";
72
73 private static final String ACTION_ENABLE_OFFLINE_BP = "ACTION_ENABLE_OFFLINE_BP";
74 private static final String ACTION_DISENABLE_OFFLINE_BP = "ACTION_DISENABLE_OFFLINE_BP";
75 private static final String ACTION_IS_ENABLE_OFFLINE = "ACTION_IS_ENABLE_OFFLINE";
76 private static final String IS_ENABLE_OFFLINE = "IS_ENABLE_OFFLINE";
77
78 private static final String ACTION_SET_UNIT_SUCCESS_BP = "ACTION_SET_UNIT_SUCCESS_BP";
79 private static final String ACTION_SET_ANGLE_SUCCESS_BP = "ACTION_SET_ANGLE_SUCCESS_BP";
80
81 private static final String ACTION_INTERRUPTED_BP = "ACTION_INTERRUPTED_BP";
82 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
83
84 private static final String ACTION_ANGLE_BP = "ACTION_ANGLE_BP";
85 private static final String WHICH_ARM = "WHICH_ARM";
86 private static final String ANGLE_BP = "ANGLE_BP";
87
88 public BPProfileModule(ReactApplicationContext reactContext) {
89 super(reactContext);
90 }
91
92 @Override
93 public String getName() {
94 return modelName;
95 }
96
97 @Nullable
98 @Override
99 public Map<String, Object> getConstants() {
100
101 final Map<String, Object> constants = new HashMap<>();
102
103 constants.put(ACTION_ERROR_BP, BpProfile.ACTION_ERROR_BP);
104 constants.put(ERROR_NUM_BP, BpProfile.ERROR_NUM_BP);
105 constants.put(ERROR_DESCRIPTION_BP, BpProfile.ERROR_DESCRIPTION_BP);
106
107 constants.put(ACTION_BATTERY_BP, BpProfile.ACTION_BATTERY_BP);
108 constants.put(BATTERY_BP,BpProfile.BATTERY_BP);
109
110 constants.put(ACTION_ZOREING_BP, BpProfile.ACTION_ZOREING_BP);
111 constants.put(ACTION_ZOREOVER_BP, BpProfile.ACTION_ZOREOVER_BP);
112
113 constants.put(ACTION_ONLINE_PRESSURE_BP, BpProfile.ACTION_ONLINE_PRESSURE_BP);
114 constants.put(BLOOD_PRESSURE_BP,BpProfile.BLOOD_PRESSURE_BP);
115
116 constants.put(ACTION_ONLINE_PULSEWAVE_BP,BpProfile.ACTION_ONLINE_PULSEWAVE_BP);
117 constants.put(FLAG_HEARTBEAT_BP,BpProfile.FLAG_HEARTBEAT_BP);
118 constants.put(PULSEWAVE_BP,BpProfile.PULSEWAVE_BP);
119
120 constants.put(ACTION_ONLINE_RESULT_BP, BpProfile.ACTION_ONLINE_RESULT_BP);
121 constants.put(HIGH_BLOOD_PRESSURE_BP,BpProfile.HIGH_BLOOD_PRESSURE_BP);
122 constants.put(LOW_BLOOD_PRESSURE_BP,BpProfile.LOW_BLOOD_PRESSURE_BP);
123 constants.put(PULSE_BP,BpProfile.PULSE_BP);
124 constants.put(MEASUREMENT_AHR_BP,BpProfile.MEASUREMENT_AHR_BP);
125 constants.put(MEASUREMENT_HSD_BP,BpProfile.MEASUREMENT_HSD_BP);
126 constants.put(DATAID,BpProfile.DATAID);
127
128 constants.put(ACTION_HISTORICAL_NUM_BP, BpProfile.ACTION_HISTORICAL_NUM_BP);
129 constants.put(HISTORICAL_NUM_BP, BpProfile.HISTORICAL_NUM_BP);
130
131 constants.put(ACTION_HISTORICAL_DATA_BP,BpProfile.ACTION_HISTORICAL_DATA_BP);
132 constants.put(HISTORICAL_DATA_BP, BpProfile.HISTORICAL_DATA_BP);
133 constants.put(MEASUREMENT_DATE_BP, BpProfile.MEASUREMENT_DATE_BP);
134 constants.put(MEASUREMENT_STRAT_ANGLE_BP,BpProfile.MEASUREMENT_STRAT_ANGLE_BP);
135 constants.put(MEASUREMENT_ANGLE_CHANGE_BP,BpProfile.MEASUREMENT_ANGLE_CHANGE_BP);
136 constants.put(MEASUREMENT_HAND_BP,BpProfile.MEASUREMENT_HAND_BP);
137
138 constants.put(ACTION_HISTORICAL_OVER_BP,BpProfile.ACTION_HISTORICAL_OVER_BP);
139
140 constants.put(ACTION_FUNCTION_INFORMATION_BP,BpProfile.ACTION_FUNCTION_INFORMATION_BP);
141 constants.put(FUNCTION_IS_UPAIR_MEASURE, BpProfile.FUNCTION_IS_UPAIR_MEASURE);
142 constants.put(FUNCTION_IS_ARM_MEASURE, BpProfile.FUNCTION_IS_ARM_MEASURE);
143 constants.put(FUNCTION_HAVE_ANGLE_SENSOR, BpProfile.FUNCTION_HAVE_ANGLE_SENSOR);
144 constants.put(FUNCTION_HAVE_OFFLINE, BpProfile.FUNCTION_HAVE_OFFLINE);
145 constants.put(FUNCTION_HAVE_HSD, BpProfile.FUNCTION_HAVE_HSD);
146 constants.put(FUNCTION_HAVE_ANGLE_SETTING, BpProfile.FUNCTION_HAVE_ANGLE_SETTING);
147 constants.put(FUNCTION_IS_MULTI_UPLOAD, BpProfile.FUNCTION_IS_MULTI_UPLOAD);
148 constants.put(FUNCTION_HAVE_SELF_UPDATE, BpProfile.FUNCTION_HAVE_SELF_UPDATE);
149
150 constants.put(ACTION_ENABLE_OFFLINE_BP, BpProfile.ACTION_ENABLE_OFFLINE_BP);
151 constants.put(ACTION_DISENABLE_OFFLINE_BP, BpProfile.ACTION_DISENABLE_OFFLINE_BP);
152
153 constants.put(ACTION_IS_ENABLE_OFFLINE, BpProfile.ACTION_IS_ENABLE_OFFLINE);
154 constants.put(IS_ENABLE_OFFLINE,BpProfile.IS_ENABLE_OFFLINE);
155
156 constants.put(ACTION_SET_UNIT_SUCCESS_BP,BpProfile.ACTION_SET_UNIT_SUCCESS_BP);
157 constants.put(ACTION_SET_ANGLE_SUCCESS_BP,BpProfile.ACTION_SET_ANGLE_SUCCESS_BP);
158
159 constants.put(ACTION_INTERRUPTED_BP, BpProfile.ACTION_INTERRUPTED_BP);
160 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
161
162 constants.put(ACTION_ANGLE_BP, BpProfile.ACTION_ANGLE_BP);
163 constants.put(WHICH_ARM, BpProfile.WHICH_ARM);
164 constants.put(ANGLE_BP, BpProfile.ANGLE_BP);
165
166 return constants;
167 }
168}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMModule.java
new file mode 100755
index 0000000..32e7106
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMModule.java
@@ -0,0 +1,145 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.BtmControl;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19/**
20 * Created by lixuesong on 2016/11/21.
21 */
22@ReactModule(name = "BTMModule")
23public class BTMModule extends iHealthBaseModule {
24 private static final String modelName = "BTMModule";
25 private static final String TAG = "BTMModule";
26
27 private static final String EVENT_NOTIFY = "event_notify_btm";
28
29 public BTMModule(ReactApplicationContext reactContext) {
30 super(TAG, reactContext);
31 }
32
33 @Override
34 public String getName() {
35 return modelName;
36 }
37
38 @Override
39 public Map<String, Object> getConstants() {
40 Map<String, Object> map = new HashMap<>();
41 map.put("Event_Notify", EVENT_NOTIFY);
42 return map;
43 }
44
45 private static BtmControl getControl(String mac) {
46 return iHealthDevicesManager.getInstance().getBtmControl(mac);
47 }
48
49 @ReactMethod
50 public void getBattery(String mac) {
51 BtmControl btmControl = getControl(mac);
52 if (btmControl != null) {
53 btmControl.getBattery();
54 } else {
55 Log.e(TAG, "Can not find BTM Control mac:" + mac);
56 }
57 }
58
59 @ReactMethod
60 public void setStandbyTime(String mac, int hour, int minute, int second) {
61 BtmControl btmControl = getControl(mac);
62 if (btmControl != null) {
63 btmControl.setStandbyTime(hour, minute, second);
64 } else {
65 Log.e(TAG, "Can not find BTM Control mac:" + mac);
66 }
67 }
68
69 @ReactMethod
70 public void setTemperatureUnit(String mac, int unit) {
71 BtmControl btmControl = getControl(mac);
72 if (btmControl != null) {
73 btmControl.setTemperatureUnit((byte) unit);
74 } else {
75 Log.e(TAG, "Can not find BTM Control mac:" + mac);
76 }
77 }
78
79 @ReactMethod
80 public void setMeasuringTarget(String mac, int target) {
81 BtmControl btmControl = getControl(mac);
82 if (btmControl != null) {
83 btmControl.setMeasuringTarget((byte) target);
84 } else {
85 Log.e(TAG, "Can not find BTM Control mac:" + mac);
86 }
87 }
88
89 @ReactMethod
90 public void setOfflineTarget(String mac, int target) {
91 BtmControl btmControl = getControl(mac);
92 if (btmControl != null) {
93 btmControl.setOfflineTarget((byte) target);
94 } else {
95 Log.e(TAG, "Can not find BTM Control mac:" + mac);
96 }
97 }
98
99 @ReactMethod
100 public void getMemoryData(String mac) {
101 BtmControl btmControl = getControl(mac);
102 if (btmControl != null) {
103 btmControl.getMemoryData();
104 } else {
105 Log.e(TAG, "Can not find BTM Control mac:" + mac);
106 }
107 }
108
109 @ReactMethod
110 public void disconnect(String mac) {
111 BtmControl btmControl = getControl(mac);
112 if (btmControl != null) {
113 btmControl.disconnect();
114 } else {
115 Log.e(TAG, "Can not find BTM Control mac:" + mac);
116 }
117 }
118
119 @Override
120 public void handleNotify(String mac, String deviceType, String action, String message) {
121 WritableMap params = Arguments.createMap();
122 params.putString("action", action);
123 params.putString("mac", mac);
124 params.putString("type", deviceType);
125 if (!TextUtils.isEmpty(message)) {
126 Utils.jsonToMap(message, params);
127 }
128 sendEvent(EVENT_NOTIFY, params);
129 }
130
131 @ReactMethod
132 public void getAllConnectedDevices() {
133 List<String> devices = iHealthDevicesManager.getInstance().getBTMDevices();
134 WritableMap params = Arguments.createMap();
135 if (devices.size() > 0) {
136 WritableArray array = Arguments.createArray();
137 for (String device : devices) {
138 array.pushString(device);
139 }
140 params.putArray("devices", array);
141 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
142 }
143 sendEvent(EVENT_NOTIFY, params);
144 }
145}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMProfileModule.java
new file mode 100755
index 0000000..4949093
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/BTMProfileModule.java
@@ -0,0 +1,74 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.BtmProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by lixuesong on 15/11/2016.
15 */
16@ReactModule(name = "BTMProfileModule")
17public class BTMProfileModule extends ReactContextBaseJavaModule {
18 private static final String modelName = "BTMProfileModule";
19 private static final String TAG = "BTMProfileModule";
20
21 private static final String ACTION_BTM_BATTERY = "ACTION_BTM_BATTERY";
22 private static final String BTM_BATTERY = "BTM_BATTERY";
23
24 private static final String ACTION_BTM_MEMORY = "ACTION_BTM_MEMORY";
25 private static final String MEMORY_COUNT = "MEMORY_COUNT";
26 private static final String BTM_TEMPERATURE_ARRAY = "BTM_TEMPERATURE_ARRAY";
27 private static final String BTM_TEMPERATURE = "BTM_TEMPERATURE";
28 private static final String BTM_TEMPERATURE_TARGET = "BTM_TEMPERATURE_TARGET";
29 private static final String BTM_MEASURE_TIME = "BTM_MEASURE_TIME";
30
31 private static final String ACTION_BTM_MEASURE = "ACTION_BTM_MEASURE";
32
33 private static final String ACTION_BTM_CALLBACK = "ACTION_BTM_CALLBACK";
34
35 private static final String ACTION_ERROR_BTM = "ACTION_ERROR_BTM";
36 private static final String ERROR_NUM_BTM = "ERROR_NUM_BTM";
37 private static final String ERROR_DESCRIPTION_BTM = "ERROR_DESCRIPTION_BTM";
38 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
39
40
41 public BTMProfileModule(ReactApplicationContext reactContext) {
42 super(reactContext);
43 }
44
45 @Override
46 public String getName() {
47 return modelName;
48 }
49
50 @Nullable
51 @Override
52 public Map<String, Object> getConstants() {
53 Map<String, Object> constants = new HashMap<>();
54 constants.put(ACTION_BTM_BATTERY, BtmProfile.ACTION_BTM_BATTERY);
55 constants.put(BTM_BATTERY, BtmProfile.BTM_BATTERY);
56
57 constants.put(ACTION_BTM_MEMORY, BtmProfile.ACTION_BTM_MEMORY);
58 constants.put(MEMORY_COUNT, BtmProfile.MEMORY_COUNT);
59 constants.put(BTM_TEMPERATURE_ARRAY, BtmProfile.BTM_TEMPERATURE_ARRAY);
60 constants.put(BTM_TEMPERATURE, BtmProfile.BTM_TEMPERATURE);
61 constants.put(BTM_TEMPERATURE_TARGET, BtmProfile.BTM_TEMPERATURE_TARGET);
62 constants.put(BTM_MEASURE_TIME, BtmProfile.BTM_MEASURE_TIME);
63
64 constants.put(ACTION_BTM_MEASURE, BtmProfile.ACTION_BTM_MEASURE);
65
66 constants.put(ACTION_BTM_CALLBACK, BtmProfile.ACTION_BTM_CALLBACK);
67
68 constants.put(ACTION_ERROR_BTM, BtmProfile.ACTION_ERROR_BTM);
69 constants.put(ERROR_NUM_BTM, BtmProfile.ERROR_NUM_BTM);
70 constants.put(ERROR_DESCRIPTION_BTM, BtmProfile.ERROR_DESCRIPTION_BTM);
71 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
72 return constants;
73 }
74}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGModule.java
new file mode 100644
index 0000000..566e276
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGModule.java
@@ -0,0 +1,157 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.ECG3Control;
12import com.ihealth.communication.control.ECG3Profile;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import org.json.JSONObject;
16
17import java.util.HashMap;
18import java.util.List;
19import java.util.Map;
20
21import static com.ihealth.communication.control.ECG3Profile.ONLINE_DATA;
22import static com.ihealth.communication.control.ECG3Profile.ONLINE_HR;
23import static com.ihealth.ihealthlibrary.ECGProfileModule.MEASURE_WAVEData;
24import static com.ihealth.ihealthlibrary.ECGProfileModule.MEASURE_ECGPulse;
25
26/**
27 * Created by zhaoyongguang on 2018/1/22.
28 */
29@ReactModule(name = "ECGModule")
30public class ECGModule extends iHealthBaseModule {
31 private static final String modelName = "ECGModule";
32 private static final String TAG = "ECGModule";
33
34 private static final String EVENT_NOTIFY = "event_notify_ecg3";
35
36 public ECGModule(ReactApplicationContext reactContext) {
37 super(TAG, reactContext);
38 }
39
40 @Override
41 public Map<String, Object> getConstants() {
42 Map<String, Object> map = new HashMap<>();
43 map.put("Event_Notify", EVENT_NOTIFY);
44 return map;
45 }
46
47 @Override
48 public void handleNotify(String mac, String deviceType, String action, String message) {
49 WritableMap params = Arguments.createMap();
50
51 if (action.equals(ECG3Profile.ACTION_SYNC_ONLINE_DATA)) {
52 params.putString("action", ECGProfileModule.ACTION_MEASURE_WAVEData);
53 try {
54 JSONObject jsonObject = new JSONObject(message);
55 params.putArray(MEASURE_WAVEData, Utils.getWritableArrayFromJSONArray(jsonObject.getJSONArray(ONLINE_DATA)));
56
57 //split pulse
58 if (jsonObject.getInt(MEASURE_ECGPulse) > 0) {
59 WritableMap paramsHR = Arguments.createMap();
60 paramsHR.putString("action", ECGProfileModule.ACTION_MEASURE_ECGPulse);
61 paramsHR.putInt(MEASURE_ECGPulse, jsonObject.getInt(ONLINE_HR));
62 paramsHR.putString("mac", mac);
63 paramsHR.putString("type", deviceType);
64 sendEvent(EVENT_NOTIFY, paramsHR);
65 }
66 } catch (Exception e) {
67 e.printStackTrace();
68 }
69 } else {
70 params.putString("action", action);
71 if (!TextUtils.isEmpty(message)) {
72 Utils.jsonToMap(message, params);
73 }
74 }
75 params.putString("mac", mac);
76 params.putString("type", deviceType);
77
78 sendEvent(EVENT_NOTIFY, params);
79 }
80
81
82 private static ECG3Control getControl(String mac) {
83 return iHealthDevicesManager.getInstance().getECG3Control(mac);
84 }
85
86 /**
87 * @return the name of this module. This will be the name used to {@code require()} this module
88 * from javascript.
89 */
90 @Override
91 public String getName() {
92 return modelName;
93 }
94
95 @ReactMethod
96 public void getAllConnectedDevices() {
97 List<String> devices = iHealthDevicesManager.getInstance().getECG3Devices();
98 WritableMap params = Arguments.createMap();
99 if (devices.size() > 0) {
100 WritableArray array = Arguments.createArray();
101 for (String device : devices) {
102 array.pushString(device);
103 }
104 params.putArray("devices", array);
105 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
106 }
107 sendEvent(EVENT_NOTIFY, params);
108 }
109
110 @ReactMethod
111 public void sysTime(String mac) {
112 ECG3Control control = getControl(mac);
113 if (control != null) {
114 control.setTime();
115 } else {
116 WritableMap params = Arguments.createMap();
117 params.putInt("errorid", 400);
118 sendEvent("Error", params);
119 }
120 }
121
122 @ReactMethod
123 public void getBattery(String mac) {
124 ECG3Control control = getControl(mac);
125 if (control != null) {
126 control.getBattery();
127 } else {
128 WritableMap params = Arguments.createMap();
129 params.putInt("errorid", 400);
130 sendEvent("Error", params);
131 }
132 }
133
134 @ReactMethod
135 public void startMeasure(String mac) {
136 ECG3Control control = getControl(mac);
137 if (control != null) {
138 control.startMeasure();
139 } else {
140 WritableMap params = Arguments.createMap();
141 params.putInt("errorid", 400);
142 sendEvent("Error", params);
143 }
144 }
145
146 @ReactMethod
147 public void stopMeasure(String mac) {
148 ECG3Control control = getControl(mac);
149 if (control != null) {
150 control.stopMeasure();
151 } else {
152 WritableMap params = Arguments.createMap();
153 params.putInt("errorid", 400);
154 sendEvent("Error", params);
155 }
156 }
157}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGProfileModule.java
new file mode 100644
index 0000000..6f51279
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGProfileModule.java
@@ -0,0 +1,385 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.ECG3Profile;
7import com.ihealth.communication.manager.iHealthDevicesManager;
8
9import java.util.HashMap;
10import java.util.Map;
11
12import javax.annotation.Nullable;
13
14/**
15 * Created by zhaoyongguang on 2018/1/22.
16 */
17@ReactModule(name = "ECGProfileModule")
18public class ECGProfileModule extends ReactContextBaseJavaModule {
19 private static final String modelName = "ECGProfileModule";
20
21 private static final String ACTION_ERROR_ECG = "ACTION_ERROR_ECG";
22 private static final String ERROR_NUM_ECG = "ERROR_NUM_ECG";
23 private static final String ERROR_DESCRIPTION_ECG = "ERROR_DESCRIPTION_ECG";
24 private static final String ACTION_BATTERY_ECG = "ACTION_BATTERY_ECG";
25 private static final String BATTERY_ECG = "BATTERY_ECG";
26 private static final String ACTION_SYSTIME = "ACTION_SYSTIME";
27 private static final String ACTION_STOPMEASURE_ECG = "ACTION_STOPMEASURE_ECG";
28 public static final String ACTION_MEASURE_WAVEData = "ACTION_MEASURE_WAVEData";
29 public static final String ACTION_MEASURE_ECGPulse = "ACTION_MEASURE_ECGPulse";
30
31 /**
32 * Callback indicating sync offline data from ECG3_USB.
33 * <ul>
34 * KeyList:
35 * <ul>
36 * <li>{@link #OFFLINE_DATA_SYNC_PROGRESS} </li>
37 * <li>{@link #OFFLINE_DATA_SYNC_FINISH} </li>
38 * <li>{@link #OFFLINE_DATAS} </li>
39 * </ul>
40 * </ul>
41 * <p>
42 * <p>
43 * If {@link #OFFLINE_DATA_SYNC_FINISH sync finish }, you can get filtered data info with {@link #OFFLINE_DATAS}.
44 * <br />eg.<br />
45 * {<br />
46 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_sync_progress": 100,<br />
47 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_sync_finish": true,<br />
48 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;"offline_datas": [{<br />
49 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_file_name": "20160420022253",<br />
50 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_simpling_rate": 248,<br />
51 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_start_time": "20160420022253",<br />
52 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_finish_time": "20160420022357",<br />
53 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_flag": 7<br />
54 * <span> </span>}]<br />
55 * }<br />
56 * <p>
57 * <p>All the filtered data is stored in the current app`s internal storage {@link iHealthDevicesManager#TYPE_ECG3_USB ECG3_USB} directory.
58 * <b>And the data fields are in the order of MSB to LSB. Where MSB = Most Significant Bit and LSB = Least Significant Bit.</b>
59 * <p>The definition of those data as bellow 1~7:
60 * <ol>
61 * <li>Filtered ECG data, Short type, every 2 bytes represent a simpling value. The target file: {@link ECGAnalyseResult_[fileName].txt} That is {@link #PREFIX_FILTERED_DATA} + fileName + .txt
62 * <li>ECG HR Information EveryHour, Int type, every 4 bytes represent a value, and every 4 value as a group. Act as Maximum HR/Minimum HR/Average HR/Total heart beat of every hour. The target file: {@link ECGHREveryHour_[fileName].txt} That is {@link #PREFIX_HR_EVERY_HOUR} + fileName + .txt
63 * <li>ECG HR Information for Day, Int type, every 4 bytes represent a value, and every 4 value as a group. Act as Maximum HR/Minimum HR/Average HR/Total heart beat of the day. The target file: {@link ECGDetail_[fileName].txt} That is {@link #PREFIX_HR_DETAIL} + fileName + .txt
64 * <li>Abnormal points filtered by algorithm, Int type, every 4 bytes represent a value. The target file: {@link ECGOBByFilter_[fileName].txt} That is {@link #PREFIX_OB_BY_FILTER} + fileName + .txt
65 * <li>Abnormal points marked by user, Int type, every 4 bytes represent a value.The target file: {@link OBData_[fileName].txt} That is {@link #PREFIX_OB} + fileName + .txt
66 * <li>Electrode lead off Begin points, Int type, every 4 bytes represent a value. The target file: {@link ECGLeadOffBegin_[fileName].txt} That is {@link #PREFIX_LEADOFF_BEGIN} + fileName + .txt
67 * <li>Electrode lead off End points, Int type, every 4 bytes represent a value. The target file: {@link ECGLeadOffEnd_[fileName].txt} That is {@link #PREFIX_LEADOFF_END} + fileName + .txt
68 * <p>
69 * </ol>
70 * <p>{@link notice And then, read the target data as follows:}
71 * <pre class="prettyprint lang-java">
72 * //Example to access the result files
73 * private void readData() {
74 * // Step 1, get the dir path
75 * File resultsDir = new File(getFilesDir().getAbsolutePath() + File.separator + iHealthDevicesManager.TYPE_ECG3_USB);
76 * // Step 2, get the target file according to the file name and flags {@link ECG3Profile#OFFLINE_DATA_FLAG}
77 * //check bit 0 of OFFLINE_DATA_FLAG
78 * if ((offline_data_flag &amp; 0x01) != 0) {
79 * //wave data
80 * File file = new File(resultsDir, ECG3Profile.PREFIX_FILTERED_DATA + fileName + ".txt");
81 * if (file.exists()) {
82 * byte[] array = new byte[(int) file.length()];
83 * InputStream in = null;
84 * try {
85 * in = new FileInputStream(file);
86 * in.read(array);
87 * } catch (FileNotFoundException e) {
88 * e.printStackTrace();
89 * } catch (IOException e) {
90 * e.printStackTrace();
91 * } finally {
92 * if (in != null) {
93 * try {
94 * in.close();
95 * } catch (IOException e) {
96 * e.printStackTrace();
97 * }
98 * }
99 * }
100 * short[] waveBuffer = BytetoShort(array);
101 * float[] formatDataBuffer = FormatECGData(waveBuffer);
102 * //todo draw view
103 * } else {
104 * Log.e(TAG, "File not exist: " + file);
105 * }
106 * }
107 * //check bit 1 of OFFLINE_DATA_FLAG
108 * if ((offline_data_flag &amp; 0x02) != 0) {
109 * //heart rate data
110 * File fileHREveryHour = new File(resultsDir, ECG3Profile.PREFIX_HR_EVERY_HOUR + fileName + ".txt");
111 * if (fileHREveryHour.exists()) {
112 * byte[] array = new byte[(int) fileHREveryHour.length()];
113 * InputStream in = null;
114 * try {
115 * in = new FileInputStream(fileHREveryHour);
116 * in.read(array);
117 * } catch (FileNotFoundException e) {
118 * e.printStackTrace();
119 * } catch (IOException e) {
120 * e.printStackTrace();
121 * } finally {
122 * if (in != null) {
123 * try {
124 * in.close();
125 * } catch (IOException e) {
126 * e.printStackTrace();
127 * }
128 * }
129 * }
130 * int[] hrEveryHourBuffer = BytetoInt(array);
131 * //todo show hr list
132 * } else {
133 * Log.e(TAG, "File not exist: " + fileHREveryHour);
134 * }
135 * File fileHRAllDay = new File(resultsDir, ECG3Profile.PREFIX_HR_DETAIL + fileName + ".txt");
136 * if (fileHRAllDay.exists()) {
137 * byte[] array = new byte[(int) fileHRAllDay.length()];
138 * InputStream in = null;
139 * try {
140 * in = new FileInputStream(fileHRAllDay);
141 * in.read(array);
142 * } catch (FileNotFoundException e) {
143 * e.printStackTrace();
144 * } catch (IOException e) {
145 * e.printStackTrace();
146 * } finally {
147 * if (in != null) {
148 * try {
149 * in.close();
150 * } catch (IOException e) {
151 * e.printStackTrace();
152 * }
153 * }
154 * }
155 * int[] hrAllDayBuffer = BytetoInt(array);
156 * //todo show hr list
157 * } else {
158 * Log.e(TAG, "File not exist: " + fileHRAllDay);
159 * }
160 * }
161 * // the same for other data
162 * }
163 * // Every 2 bytes represents a short data, the fields are in the order of MSB to LSB. Where MSB = Most Significant Bit and LSB = Least Significant Bit
164 * private short[] BytetoShort(byte[] array) {
165 * short[] result = new short[array.length / 2];
166 * for (int i = 0; i &lt; result.length; i++) {
167 * int value = array[i * 2] * 256 + array[i * 2 + 1];
168 * result[i] = (short) ((value &gt; 32767) ? (value - 65536) : value);
169 * }
170 * return result;
171 * }
172 * // Every 4 bytes represents a int data, the fields are in the order of MSB to LSB. Where MSB = Most Significant Bit and LSB = Least Significant Bit
173 * private int[] BytetoInt(byte[] array) {
174 * int[] result = new int[array.length / 4];
175 * for (int i = 0; i &lt; result.length; i++) {
176 * result[i] = array[i * 4] * 256 * 256 * 256
177 * + array[i * 4 + 1] * 256 * 256
178 * + array[i * 4 + 2] * 256
179 * + array[i * 4 + 3];
180 * }
181 * return result;
182 * }
183 * //Format ECG value, unit mV
184 * private float[] FormatECGData(short[] array) {
185 * float[] result = new float[array.length];
186 * for (int i = 0; i < result.length; i++) {
187 * result[i] = array[i] * 2420.0f / (6 * 32767);
188 * }
189 * return result;
190 * }
191 * </pre>
192 * Otherwise, no filtered data, only update the sync progress.
193 * <br /> eg.
194 * {<br />
195 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_sync_progress": 30.5,<br />
196 * <span> </span>&nbsp;&nbsp;&nbsp;&nbsp;"offline_data_sync_finish": false<br />
197 * }<br />
198 * <br />
199 */
200 public static final String ACTION_STARTSYNCDATA_ECGUSB = "ACTION_STARTSYNCDATA_ECGUSB";
201
202 public static final String ACTION_SYNCDATAPROGRESS_ECGUSB = "ACTION_SYNCDATAPROGRESS_ECGUSB";
203 /**
204 * Callback indicating no historical data for ECG device.
205 */
206 public static final String ACTION_NO_HISTORICAL_DATA = "ACTION_NO_HISTORICAL_DATA";
207 /**
208 * Key of sync progress, range [0, 100]. Value 100 indicates sync finish.
209 */
210 public static final String PROGRESS = "PROGRESS";
211
212 public static final String ACTION_SYNCDATAINFO_ECGUSB = "ACTION_SYNCDATAINFO_ECGUSB";
213 public static final String DATAINFO = "DATAINFO";
214
215 public static final String MEASURE_WAVEData = "MEASURE_WAVEData";
216 public static final String MEASURE_ECGPulse = "MEASURE_ECGPulse";
217
218 public static final String FILEPATH = "FilePath";
219 /**
220 * Key of file name.
221 */
222 private static final String OFFLINE_DATA_FILE_NAME = "OFFLINE_DATA_FILE_NAME";
223
224 /**
225 * Key of simpling rate.You should use it to display view.
226 */
227 private static final String OFFLINE_DATA_SIMPLING_RATE = "OFFLINE_DATA_SIMPLING_RATE";
228 /**
229 * Key of start measure time.
230 */
231 private static final String OFFLINE_DATA_START_TIME = "OFFLINE_DATA_START_TIME";
232 /**
233 * Key of stop measure time.
234 */
235 private static final String OFFLINE_DATA_FINISH_TIME = "OFFLINE_DATA_FINISH_TIME";
236
237 public static final String ACTION_SPLICE = "ACTION_SPLICE";
238 public static final String SPLICE_DATA = "SPLICE_DATA";
239 public static final String ACTION_GET_CACHE = "ACTION_GET_CACHE";
240 public static final String GET_CACHE_DATA = "GET_CACHE_DATA";
241 public static final String ACTION_FILTER = "ACTION_FILTER";
242 public static final String FILTER_DATA = "FILTER_DATA";
243
244
245 /**
246 * Key of data flags, define which data fields are valid in the result.
247 * <p>
248 * <table style="width:200px;" align="center" cellpadding="2" cellspacing="0" border="1" bordercolor="#000000">
249 * <tbody>
250 * <tr><td>Name</td><td>Format</td><td>Bit field</td></tr>
251 * <tr><td>Flags</td><td>32bits</td><td>
252 * <table style="width:500px;" cellpadding="2" cellspacing="0">
253 * <tbody>
254 * <tr><td>Bit</td><td>Size</td><td>Name</td><td>Definition</td></tr>
255 * <tr><td>0</td><td>1</td><td>Represent filtered data, target file: {@link #PREFIX_FILTERED_DATA}+[fileName].txt</td><td>
256 * <table style="width:300px;" cellpadding="2" cellspacing="0">
257 * <tbody>
258 * <tr><td>Value</td><td>Description</td></tr>
259 * <tr><td>0</td><td>NA</td></tr>
260 * <tr><td>1</td><td>Valid</td></tr>
261 * </tbody>
262 * </table></td>
263 * </tr>
264 * <tr><td>1</td><td>1</td><td>Represent heart rate data, target file: {@link #PREFIX_HR_EVERY_HOUR}+[fileName].txt and {@link #PREFIX_HR_DETAIL}+[fileName].txt</td><td>
265 * <table style="width:300px;" cellpadding="2" cellspacing="0">
266 * <tbody>
267 * <tr><td>0</td><td>NA</td></tr>
268 * <tr><td>1</td><td>Valid</td></tr>
269 * </tbody>
270 * </table></td>
271 * </tr>
272 * <tr><td>2</td><td>1</td><td>Represent abnormal points filtered by algorithm, target file: {@link #PREFIX_OB_BY_FILTER}+[fileName].txt</td><td>
273 * <table style="width:300px;" cellpadding="2" cellspacing="0">
274 * <tbody>
275 * <tr><td>0</td><td>NA</td></tr>
276 * <tr><td>1</td><td>Valid</td></tr>
277 * </tbody>
278 * </table></td>
279 * </tr>
280 * <tr><td>3</td><td>1</td><td>Represent electrode lead off data,target file: {@link #PREFIX_LEADOFF_BEGIN}+[fileName].txt and {@link #PREFIX_LEADOFF_END}+[fileName].txt</td><td>
281 * <table style="width:300px;" cellpadding="2" cellspacing="0">
282 * <tbody>
283 * <tr><td>0</td><td>NA</td></tr>
284 * <tr><td>1</td><td>Valid</td></tr>
285 * </tbody>
286 * </table></td>
287 * </tr>
288 * <tr><td>4</td><td>1</td><td>Represent abnormal points marked by user, target file: {@link #PREFIX_OB}+[fileName].txt</td><td>
289 * <table style="width:300px;" cellpadding="2" cellspacing="0">
290 * <tbody>
291 * <tr><td>0</td><td>NA</td></tr>
292 * <tr><td>1</td><td>Valid</td></tr>
293 * </tbody>
294 * </table></td>
295 * </tr>
296 * <tr><td>5~31</td><td>27</td><td>Reserved</td><td></td>
297 * </tr>
298 * </tbody>
299 * </table></td>
300 * </tr>
301 * </tbody>
302 * </table>
303 */
304 private static final String OFFLINE_DATA_FLAG = "offline_data_flag";
305
306 private static final String ACTION_DELETEDATA_ECGUSB = "ACTION_DELETEDATA_ECGUSB";
307 private static final String DELETE_RESULT = "DELETE_RESULT";
308 private static final String ACTION_ELECTRODE_STATUS = "ACTION_ELECTRODE_STATUS";
309 private static final String ELECTRODE_STATUS = "ELECTRODE_STATUS";
310
311 private static final String ACTION_GET_IDPS = "ACTION_GET_IDPS";
312
313 private static final String ACTION_ERROR_ECGUSB = "ACTION_ERROR_ECGUSB";
314 private static final String ERROR_NUM_ECGUSB = "ERROR_NUM_ECGUSB";
315 private static final String ERROR_DESCRIPTION_ECGUSB = "ERROR_DESCRIPTION_ECGUSB";
316 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
317
318 public ECGProfileModule(ReactApplicationContext reactContext) {
319 super(reactContext);
320 }
321
322 /**
323 * @return the name of this module. This will be the name used to {@code require()} this module
324 * from javascript.
325 */
326 @Override
327 public String getName() {
328 return modelName;
329 }
330
331 /**
332 * @return a map of constants this module exports to JS. Supports JSON types.
333 */
334 @Nullable
335 @Override
336 public Map<String, Object> getConstants() {
337 final Map<String, Object> constants = new HashMap<>();
338
339 constants.put(ACTION_ERROR_ECG, ECG3Profile.ACTION_ERROR);
340 constants.put(ERROR_NUM_ECG, ECG3Profile.ERROR_NUM);
341 constants.put(ERROR_DESCRIPTION_ECG, ECG3Profile.ERROR_DESCRIPTION);
342 constants.put(ACTION_BATTERY_ECG, ECG3Profile.ACTION_GET_BATTERY);
343 constants.put(BATTERY_ECG, ECG3Profile.BATTERY);
344 constants.put(ACTION_SYSTIME, ECG3Profile.ACTION_SET_TIME);
345 constants.put(ACTION_STOPMEASURE_ECG, ECG3Profile.ACTION_STOP_ONLINE_MEASUREMENT);
346 constants.put(ACTION_MEASURE_WAVEData, ACTION_MEASURE_WAVEData);
347 constants.put(MEASURE_WAVEData, MEASURE_WAVEData);
348 constants.put(ACTION_MEASURE_ECGPulse, ACTION_MEASURE_ECGPulse);
349 constants.put(MEASURE_ECGPulse, MEASURE_ECGPulse);
350
351 constants.put(ACTION_STARTSYNCDATA_ECGUSB, ACTION_STARTSYNCDATA_ECGUSB);
352 constants.put(ACTION_SYNCDATAPROGRESS_ECGUSB, ACTION_SYNCDATAPROGRESS_ECGUSB);
353 constants.put(PROGRESS, PROGRESS);
354 constants.put(ACTION_SYNCDATAINFO_ECGUSB, ACTION_SYNCDATAINFO_ECGUSB);
355 constants.put(DATAINFO, DATAINFO);
356 constants.put(OFFLINE_DATA_FILE_NAME, ECG3Profile.OFFLINE_DATA_FILE_NAME);
357 constants.put(OFFLINE_DATA_SIMPLING_RATE, ECG3Profile.OFFLINE_DATA_SIMPLING_RATE);
358 constants.put(OFFLINE_DATA_START_TIME, ECG3Profile.OFFLINE_DATA_START_TIME);
359 constants.put(OFFLINE_DATA_FINISH_TIME, ECG3Profile.OFFLINE_DATA_FINISH_TIME);
360 constants.put(OFFLINE_DATA_FLAG, ECG3Profile.OFFLINE_DATA_FLAG);
361
362 constants.put(ACTION_DELETEDATA_ECGUSB, ECG3Profile.ACTION_DELETE_DATA);
363 constants.put(DELETE_RESULT, ECG3Profile.DELETE_RESULT);
364 constants.put(ACTION_ELECTRODE_STATUS, ECG3Profile.ACTION_ELECTRODE_STATUS);
365 constants.put(ELECTRODE_STATUS, ECG3Profile.ELECTRODE_STATUS);
366
367 constants.put(ACTION_GET_IDPS, ECG3Profile.ACTION_GET_IDPS);
368
369 constants.put(ACTION_ERROR_ECGUSB, ECG3Profile.ACTION_ERROR);
370 constants.put(ERROR_NUM_ECGUSB, ECG3Profile.ERROR_NUM);
371 constants.put(ERROR_DESCRIPTION_ECGUSB, ECG3Profile.ERROR_DESCRIPTION);
372 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
373 constants.put(FILEPATH,ECG3Profile.FILE_PATH);
374
375 constants.put(ACTION_SPLICE, ECG3Profile.ACTION_SPLICING_DATA);
376 constants.put(SPLICE_DATA, ECG3Profile.GET_SPLICING_DATA);
377
378 constants.put(ACTION_GET_CACHE, ECG3Profile.ACTION_GET_CACHE_DATA);
379 constants.put(GET_CACHE_DATA, ECG3Profile.GET_CACHE_DATA);
380
381 constants.put(ACTION_FILTER, ECG3Profile.ACTION_GET_FILTER_FILES);
382 constants.put(FILTER_DATA, ECG3Profile.GET_FILTER_DATA);
383 return constants;
384 }
385}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGUSBModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGUSBModule.java
new file mode 100644
index 0000000..94f3451
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/ECGUSBModule.java
@@ -0,0 +1,290 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.ReadableArray;
10import com.facebook.react.bridge.WritableArray;
11import com.facebook.react.bridge.WritableMap;
12import com.facebook.react.module.annotations.ReactModule;
13import com.ihealth.communication.control.ECG3Profile;
14import com.ihealth.communication.control.ECG3USBControl;
15import com.ihealth.communication.manager.iHealthDevicesManager;
16import com.facebook.react.bridge.Callback;
17
18import org.json.JSONException;
19import org.json.JSONObject;
20
21import java.util.HashMap;
22import java.util.List;
23import java.util.Map;
24
25
26import static com.ihealth.ihealthlibrary.ECGProfileModule.ACTION_FILTER;
27import static com.ihealth.ihealthlibrary.ECGProfileModule.ACTION_SPLICE;
28import static com.ihealth.ihealthlibrary.ECGProfileModule.ACTION_GET_CACHE;
29import static com.ihealth.ihealthlibrary.ECGProfileModule.ACTION_SYNCDATAINFO_ECGUSB;
30import static com.ihealth.ihealthlibrary.ECGProfileModule.ACTION_SYNCDATAPROGRESS_ECGUSB;
31import static com.ihealth.ihealthlibrary.ECGProfileModule.DATAINFO;
32import static com.ihealth.ihealthlibrary.ECGProfileModule.GET_CACHE_DATA;
33import static com.ihealth.ihealthlibrary.ECGProfileModule.FILTER_DATA;
34import static com.ihealth.ihealthlibrary.ECGProfileModule.SPLICE_DATA;
35import static com.ihealth.ihealthlibrary.ECGProfileModule.PROGRESS;
36import static com.ihealth.ihealthlibrary.ECGProfileModule.FILEPATH;
37
38
39/**
40 * Created by zhaoyongguang on 2018/1/22.
41 */
42@ReactModule(name = "ECGUSBModule")
43public class ECGUSBModule extends iHealthBaseModule {
44 private static final String modelName = "ECGUSBModule";
45 private static final String TAG = "ECGUSBModule";
46 private static final String mac = "000000000000";
47 private static final String EVENT_NOTIFY = "event_notify_ecg3_usb";
48
49 public ECGUSBModule(ReactApplicationContext reactContext) {
50 super(TAG, reactContext);
51 }
52
53 @Override
54 public Map<String, Object> getConstants() {
55 Map<String, Object> map = new HashMap<>();
56 map.put("Event_Notify", EVENT_NOTIFY);
57 return map;
58 }
59
60 @Override
61 public void handleNotify(String mac, String deviceType, String action, String message) {
62 if (action.equals(ECG3Profile.ACTION_SYNC_OFFLINE_DATA)){
63 WritableMap params = Arguments.createMap();
64 try {
65 JSONObject jsonObject = new JSONObject(message);
66 //split progress
67 if (jsonObject.getBoolean(ECG3Profile.OFFLINE_DATA_SYNC_FINISH)) {
68 WritableMap paramsFinish = Arguments.createMap();
69 paramsFinish.putString("action", ACTION_SYNCDATAPROGRESS_ECGUSB);
70 paramsFinish.putDouble(PROGRESS, 100);
71 paramsFinish.putString("mac", mac);
72 paramsFinish.putString("type", deviceType);
73 sendEvent(EVENT_NOTIFY, paramsFinish);
74
75
76 params.putString("action", ACTION_SYNCDATAINFO_ECGUSB);
77 params.putArray(DATAINFO, Utils.getWritableArrayFromJSONArray(jsonObject.getJSONArray(ECG3Profile.OFFLINE_DATAS)));
78 params.putString("mac", mac);
79 params.putString("type", deviceType);
80// params.putString(FILEPATH, jsonObject.getString(ECG3Profile.FILE_PATH));
81 sendEvent(EVENT_NOTIFY, params);
82 } else {
83 params.putString("action", ACTION_SYNCDATAPROGRESS_ECGUSB);
84 params.putDouble(PROGRESS, jsonObject.getDouble(ECG3Profile.OFFLINE_DATA_SYNC_PROGRESS));
85 params.putString("mac", mac);
86 params.putString("type", deviceType);
87 sendEvent(EVENT_NOTIFY, params);
88 }
89
90 } catch (Exception e) {
91 e.printStackTrace();
92 }
93
94 return;
95 }
96 if (action.equals(ECG3Profile.ACTION_SPLICING_DATA)) {
97 WritableMap params = Arguments.createMap();
98 try {
99 JSONObject jsonObject = new JSONObject(message);
100 params.putString("action", ACTION_SPLICE);
101 params.putMap(SPLICE_DATA, Utils.getMapFromJSONObject(jsonObject.getJSONObject(ECG3Profile.GET_SPLICING_DATA)));
102 params.putString("mac", mac);
103 params.putString("type", deviceType);
104 params.putString(FILEPATH, jsonObject.getString(ECG3Profile.FILE_PATH));
105 sendEvent(EVENT_NOTIFY, params);
106 } catch (Exception e) {
107 e.printStackTrace();
108 }
109
110 return;
111 }
112 if (action.equals(ECG3Profile.ACTION_GET_CACHE_DATA))
113 {
114 WritableMap params = Arguments.createMap();
115 try {
116 JSONObject jsonObject = new JSONObject(message);
117 params.putString("action", ACTION_GET_CACHE);
118 params.putArray(GET_CACHE_DATA, Utils.getWritableArrayFromJSONArray(jsonObject.getJSONArray(GET_CACHE_DATA)));
119 params.putString("mac", mac);
120 params.putString("type", deviceType);
121 params.putString(FILEPATH, jsonObject.getString(ECG3Profile.FILE_PATH));
122 sendEvent(EVENT_NOTIFY, params);
123 } catch (
124 Exception e)
125 {
126 e.printStackTrace();
127 }
128
129 return;
130 }
131 if (action.equals(ECG3Profile.ACTION_GET_FILTER_FILES))
132 {
133 WritableMap params = Arguments.createMap();
134 try {
135 JSONObject jsonObject = new JSONObject(message);
136 params.putString("action", ACTION_FILTER);
137 params.putArray(FILTER_DATA, Utils.getWritableArrayFromJSONArray(jsonObject.getJSONArray(ECG3Profile.GET_FILTER_DATA)));
138 params.putString("mac", mac);
139 params.putString("type", deviceType);
140 params.putString(FILEPATH, jsonObject.getString(ECG3Profile.FILE_PATH));
141 sendEvent(EVENT_NOTIFY, params);
142 } catch (
143 Exception e)
144 {
145 e.printStackTrace();
146 }
147
148 return;
149 }
150 if (action.equals(ECG3Profile.ACTION_GET_IDPS)){
151 WritableMap params = Arguments.createMap();
152 params.putString("action", action);
153 params.putString("mac", mac);
154 params.putString("type", deviceType);
155 try {
156 params.putMap("idps", Utils.getMapFromJSONObject(new JSONObject(message)));
157 } catch (JSONException e) {
158 e.printStackTrace();
159 }
160 sendEvent(EVENT_NOTIFY, params);
161 return;
162 }
163 WritableMap params = Arguments.createMap();
164 params.putString("action", action);
165 params.putString("mac", mac);
166 params.putString("type", deviceType);
167 if (!TextUtils.isEmpty(message)) {
168 Utils.jsonToMap(message, params);
169 }
170 sendEvent(EVENT_NOTIFY, params);
171 }
172
173 /**
174 * @return the name of this module. This will be the name used to {@code require()} this module
175 * from javascript.
176 */
177 @Override
178 public String getName() {
179 return modelName;
180 }
181
182 private static ECG3USBControl getControl() {
183 return iHealthDevicesManager.getInstance().getECG3USBControl(mac);
184 }
185
186 @ReactMethod
187 public void syncData() {
188 ECG3USBControl control = getControl();
189 if (control != null) {
190 control.syncData();
191 } else {
192 WritableMap params = Arguments.createMap();
193 params.putInt("errorid", 400);
194 sendEvent("Error", params);
195 }
196 }
197
198 @ReactMethod
199 public void getIdps() {
200 ECG3USBControl control = getControl();
201 if (control != null) {
202 control.getIdps();
203 } else {
204 WritableMap params = Arguments.createMap();
205 params.putInt("errorid", 400);
206 sendEvent("Error", params);
207 }
208 }
209
210 @ReactMethod
211 public void deleteData() {
212 ECG3USBControl control = getControl();
213 if (control != null) {
214 control.deleteAll();
215 } else {
216 WritableMap params = Arguments.createMap();
217 params.putInt("errorid", 400);
218 sendEvent("Error", params);
219 }
220 }
221
222 @ReactMethod
223 public void getAllConnectedDevices() {
224 List<String> devices = iHealthDevicesManager.getInstance().getECG3USBDevices();
225 WritableMap params = Arguments.createMap();
226 if (devices.size() > 0) {
227 WritableArray array = Arguments.createArray();
228 for (String device : devices) {
229 array.pushString(device);
230 }
231 params.putArray("devices", array);
232 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
233 }
234 sendEvent(EVENT_NOTIFY, params);
235 }
236
237 @ReactMethod
238 public void spliceData(ReadableArray filesNames) {
239 ECG3USBControl control = getControl();
240 if (control != null && filesNames != null) {
241
242 String[] files = new String[filesNames.size()];
243 for (int x = 0; x < filesNames.size(); x++) {
244 files[x] = filesNames.getString(x);
245 }
246 control.spliceWithFileNames(files);
247 } else {
248 WritableMap params = Arguments.createMap();
249 params.putInt("errorid", 400);
250 sendEvent("Error", params);
251 }
252 }
253
254 @ReactMethod
255 public void getCache() {
256 ECG3USBControl control = getControl();
257 if (control != null) {
258 control.getCacheData();
259 } else {
260 WritableMap params = Arguments.createMap();
261 params.putInt("errorid", 400);
262 sendEvent("Error", params);
263 }
264 }
265
266 @ReactMethod
267 public void deleteCacheData() {
268 ECG3USBControl control = getControl();
269 if (control != null) {
270 control.deleteCacheData();
271 } else {
272 WritableMap params = Arguments.createMap();
273 params.putInt("errorid", 400);
274 sendEvent("Error", params);
275 }
276 }
277
278 @ReactMethod
279 public void getFilterDataByFileName(String dataFileName,String markFileName) {
280 ECG3USBControl control = getControl();
281 if (control != null) {
282 control.getFilterDataByFileName(dataFileName,markFileName);
283 } else {
284 WritableMap params = Arguments.createMap();
285 params.putInt("errorid", 400);
286 sendEvent("Error", params);
287 }
288 }
289
290}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2Module.java
new file mode 100755
index 0000000..b637b7e
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2Module.java
@@ -0,0 +1,115 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Hs2Control;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19/**
20 * Created by lixuesong on 16/10/20.
21 */
22@ReactModule(name = "HS2Module")
23public class HS2Module extends iHealthBaseModule {
24 private static final String modelName = "HS2Module";
25 private static final String TAG = "HS2Module";
26
27 private static final String EVENT_NOTIFY = "event_notify_hs2";
28
29 public HS2Module(ReactApplicationContext reactContext) {
30 super(TAG, reactContext);
31 }
32
33 @Override
34 public String getName() {
35 return modelName;
36 }
37
38 @Override
39 public Map<String, Object> getConstants() {
40 Map<String, Object> map = new HashMap<>();
41 map.put("Event_Notify", EVENT_NOTIFY);
42 return map;
43 }
44
45 private static Hs2Control getControl(String mac) {
46 return iHealthDevicesManager.getInstance().getHs2Control(mac);
47 }
48
49 @ReactMethod
50 public void getOfflineData(String mac) {
51 Hs2Control control = getControl(mac);
52 if (control != null) {
53 control.getOfflineData();
54 } else {
55 Log.e(TAG, "Can not find HS2 Control mac:" + mac);
56 }
57 }
58
59 @ReactMethod
60 public void measureOnline(String mac, int unit, int userId) {
61 Hs2Control control = getControl(mac);
62 if (control != null) {
63 control.measureOnline(unit, userId);
64 } else {
65 Log.e(TAG, "Can not find HS2 Control mac:" + mac);
66 }
67 }
68
69 @ReactMethod
70 public void disconnect(String mac) {
71 Hs2Control hs2Control = getControl(mac);
72 if (hs2Control != null) {
73 hs2Control.disconnect();
74 } else {
75 Log.e(TAG, "Can not find HS2 Control mac:" + mac);
76 }
77 }
78
79 @ReactMethod
80 public void getBattery(String mac) {
81 Hs2Control hs2Control = getControl(mac);
82 if (hs2Control != null) {
83 hs2Control.getBattery();
84 } else {
85 Log.e(TAG, "Can not find HS2 Control mac:" + mac);
86 }
87 }
88
89 @Override
90 public void handleNotify(String mac, String deviceType, String action, String message) {
91 WritableMap params = Arguments.createMap();
92 params.putString("action", action);
93 params.putString("mac", mac);
94 params.putString("type", deviceType);
95 if (!TextUtils.isEmpty(message)) {
96 Utils.jsonToMap(message, params);
97 }
98 sendEvent(EVENT_NOTIFY, params);
99 }
100
101 @ReactMethod
102 public void getAllConnectedDevices() {
103 List<String> devices = iHealthDevicesManager.getInstance().getHs2Devices();
104 WritableMap params = Arguments.createMap();
105 if (devices.size() > 0) {
106 WritableArray array = Arguments.createArray();
107 for (String device : devices) {
108 array.pushString(device);
109 }
110 params.putArray("devices", array);
111 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
112 }
113 sendEvent(EVENT_NOTIFY, params);
114 }
115}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SModule.java
new file mode 100755
index 0000000..f99dfcc
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SModule.java
@@ -0,0 +1,322 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.ReadableArray;
11import com.facebook.react.bridge.WritableMap;
12import com.facebook.react.module.annotations.ReactModule;
13import com.ihealth.communication.control.Hs2sControl;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.util.HashMap;
17import java.util.List;
18import java.util.Map;
19
20@ReactModule(name = "HS2SModule")
21public class HS2SModule extends iHealthBaseModule {
22 private static final String modelName = "HS2SModule";
23 private static final String TAG = "HS2SModule";
24
25 private static final String EVENT_NOTIFY = "event_notify_hs2s";
26
27 public HS2SModule(ReactApplicationContext reactContext) {
28 super(TAG, reactContext);
29 }
30
31 @Override
32 public String getName() {
33 return modelName;
34 }
35
36 @Override
37 public Map<String, Object> getConstants() {
38 Map<String, Object> map = new HashMap<>();
39 map.put("Event_Notify", EVENT_NOTIFY);
40 return map;
41 }
42
43 private static Hs2sControl getControl(String mac) {
44 return iHealthDevicesManager.getInstance().getHs2sControl(mac);
45 }
46
47 @ReactMethod
48 public void getDeviceInfo(String mac) {
49 Hs2sControl control = getControl(mac);
50 if (control != null) {
51 control.getDeviceInfo();
52 } else {
53 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
54 }
55 }
56
57 @ReactMethod
58 public void disconnect(String mac) {
59 Hs2sControl control = getControl(mac);
60 if (control != null) {
61 control.disconnect();
62 } else {
63 Log.e(TAG, "Can not find HS2 Control mac:" + mac);
64 }
65 }
66
67 @ReactMethod
68 public void getBattery(String mac) {
69 Hs2sControl control = getControl(mac);
70 if (control != null) {
71 control.getBattery();
72 } else {
73 Log.e(TAG, "Can not find HS2 Control mac:" + mac);
74 }
75 }
76
77 @ReactMethod
78 public void setUnit(String mac, int unit) {
79 Hs2sControl control = getControl(mac);
80 if (control != null) {
81 control.setUnit(unit);
82 } else {
83 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
84 }
85 }
86
87 @ReactMethod
88 public void getUserInfo(String mac) {
89 Hs2sControl control = getControl(mac);
90 if (control != null) {
91 control.getUserInfo();
92 } else {
93 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
94 }
95 }
96
97 @ReactMethod
98 public void updateUserInfo(String mac, String id, int createTS, float weight, int age, int height, int gender, int impedance, int bodybuilding) {
99 Hs2sControl control = getControl(mac);
100 if (control != null) {
101 control.createOrUpdateUserInfo(id, weight, gender, age, height, impedance, bodybuilding);
102 } else {
103 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
104 }
105 }
106
107 @ReactMethod
108 public void deleteUser(String mac, String id) {
109 Hs2sControl control = getControl(mac);
110 if (control != null) {
111 control.deleteUserInfo(id);
112 } else {
113 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
114 }
115 }
116
117 @ReactMethod
118 public void specifyTouristUsers(String mac) {
119 Hs2sControl control = getControl(mac);
120 if (control != null) {
121 control.specifyTouristUsers();
122 } else {
123 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
124 }
125 }
126
127 @ReactMethod
128 public void measure(String mac, int index, String id, int ts, float weight, int age, int height, int gender, int impedance, int bodybuilding) {
129 Hs2sControl control = getControl(mac);
130 if (control != null) {
131 control.specifyOnlineUsers(id, weight, gender, age, height, impedance, bodybuilding);
132 } else {
133 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
134 }
135 }
136
137 @ReactMethod
138 public void getMemoryDataCount(String mac, String id) {
139 Hs2sControl control = getControl(mac);
140 if (control != null) {
141 control.getOfflineDataCount(id);
142 } else {
143 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
144 }
145 }
146
147 @ReactMethod
148 public void getMemoryData(String mac, String id) {
149 Hs2sControl control = getControl(mac);
150 if (control != null) {
151 control.getOfflineData(id);
152 } else {
153 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
154 }
155 }
156
157 @ReactMethod
158 public void deleteMemoryData(String mac, String id) {
159 Hs2sControl control = getControl(mac);
160 if (control != null) {
161 control.deleteOfflineData(id);
162 } else {
163 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
164 }
165 }
166
167 @ReactMethod
168 public void getAnonymousMemoryDataCount(String mac) {
169 Hs2sControl control = getControl(mac);
170 if (control != null) {
171 control.getAnonymousDataCount();
172 } else {
173 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
174 }
175 }
176
177 @ReactMethod
178 public void getAnonymousMemoryData(String mac) {
179 Hs2sControl control = getControl(mac);
180 if (control != null) {
181 control.getAnonymousData();
182 } else {
183 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
184 }
185 }
186
187 @ReactMethod
188 public void deleteAnonymousMemoryData(String mac) {
189 Hs2sControl control = getControl(mac);
190 if (control != null) {
191 control.deleteAnonymousData();
192 } else {
193 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
194 }
195 }
196
197 @ReactMethod
198 public void resetDevice(String mac) {
199 Hs2sControl control = getControl(mac);
200 if (control != null) {
201 control.restoreFactorySettings();
202 } else {
203 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
204 }
205 }
206
207 @ReactMethod
208 public void setDeviceLightUp(String mac) {
209 Hs2sControl control = getControl(mac);
210 if (control != null) {
211 control.setBleLight();
212 } else {
213 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
214 }
215 }
216
217 @ReactMethod
218 public void enterHS2SHeartRateMeasurementMode(String mac) {
219 Hs2sControl control = getControl(mac);
220 if (control != null) {
221 control.startHeartRateMode();
222 } else {
223 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
224 }
225 }
226
227 @ReactMethod
228 public void exitHS2SHeartRateMeasurementMode(String mac) {
229 Hs2sControl control = getControl(mac);
230 if (control != null) {
231 control.stopHeartRateMode();
232 } else {
233 Log.e(TAG, "Can not find HS2S Control mac:" + mac);
234 }
235 }
236
237 @Override
238 public void handleNotify(String mac, String deviceType, String action, String message) {
239 Log.i(TAG, "message -> " + message);
240 WritableMap params = Arguments.createMap();
241 params.putString("action", action);
242 params.putString("mac", mac);
243 params.putString("type", deviceType);
244
245 if ("action_history_data".equals(action) || "action_anonymous_data".equals(action)) {
246 message = "{\"history_data\":" + message + "}";
247 }
248
249 if (!TextUtils.isEmpty(message)) {
250 Utils.jsonToMap(message, params);
251 }
252 if ("battery_hs".equals(action)) {
253 params.putString("action", "action_get_battery_hs");
254 int battery = params.getInt("battery");
255 params.putInt("battery", battery);
256
257 } else if ("action_set_unit_success".equals(action)) {
258 params.putString("action", "action_set_unit");
259 params.putBoolean("result", true);
260
261 } else if ("action_create_or_update_user_info".equals(action)) {
262 int status = params.getInt("status");
263 params.putInt("result", status);
264 params.putNull("describe");
265 params.putNull("status");
266
267 } else if ("action_delete_user_info".equals(action)) {
268 int status = params.getInt("status");
269 params.putInt("result", status);
270 params.putNull("describe");
271 params.putNull("status");
272
273 } else if ("action_history_data_num".equals(action)) {
274 ReadableArray array = params.getArray("history_data_count_array");
275 int history_data_count = 0;
276 if (array != null && array.size() > 0) {
277 history_data_count = array.getMap(0).getInt("history_data_count");
278 }
279 params.putNull("history_data_count_array");
280 params.putNull("history_data_user_count");
281 params.putInt("history_data_count", history_data_count);
282
283 } else if ("action_delete_history_data".equals(action)) {
284 int status = params.getInt("status");
285 params.putInt("result", status);
286 params.putNull("describe");
287 params.putNull("status");
288
289 } else if ("action_delete_anonymous_data".equals(action)) {
290 int status = params.getInt("status");
291 params.putInt("result", status);
292 params.putNull("describe");
293 params.putNull("status");
294
295 } else if ("action_restore_factory_settings".equals(action)) {
296 params.putBoolean("result", true);
297
298 } else if ("action_specify_users".equals(action)) {
299 int status = params.getInt("status");
300 params.putInt("result", status);
301 params.putNull("describe");
302 params.putNull("status");
303 }
304
305 sendEvent(EVENT_NOTIFY, params);
306 }
307
308 @ReactMethod
309 public void getAllConnectedDevices() {
310 List<String> devices = iHealthDevicesManager.getInstance().getHs2sDevices();
311 WritableMap params = Arguments.createMap();
312 if (devices.size() > 0) {
313 WritableArray array = Arguments.createArray();
314 for (String device : devices) {
315 array.pushString(device);
316 }
317 params.putArray("devices", array);
318 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
319 }
320 sendEvent(EVENT_NOTIFY, params);
321 }
322}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SProfileModule.java
new file mode 100755
index 0000000..725d09c
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS2SProfileModule.java
@@ -0,0 +1,209 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.Hs2sProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13@ReactModule(name = "HS2SProfileModule")
14public class HS2SProfileModule extends ReactContextBaseJavaModule {
15 private static final String modelName = "HS2SProfileModule";
16 private static final String TAG = "HS2SProfileModule";
17
18 private static final String ACTION_ERROR_HS = "ACTION_ERROR_HS";
19 private static final String ERROR_NUM_HS = "ERROR_NUM_HS";
20 private static final String ERROR_DESCRIPTION_HS = "ERROR_DESCRIPTION_HS";
21
22 private static final String ACTION_GET_DEVICE_INFO = "ACTION_GET_DEVICE_INFO";
23 private static final String HS_USER_COUNT = "HS_USER_COUNT";
24 private static final String HS_UNIT_CURRENT = "HS_UNIT_CURRENT";
25
26 private static final String ACTION_BATTERY_HS = "ACTION_BATTERY_HS";
27 private static final String BATTERY_HS = "BATTERY_HS";
28
29 private static final String ACTION_SET_UNIT_SUCCESS = "ACTION_SET_UNIT_SUCCESS";
30
31 private static final String ACTION_GET_USER_INFO = "ACTION_GET_USER_INFO";
32 private static final String USER_INFO_COUNT = "USER_INFO_COUNT";
33 private static final String USER_INFO_ARRAY = "USER_INFO_ARRAY";
34 private static final String USER_INFO_USER_ID = "USER_INFO_USER_ID";
35 private static final String USER_INFO_CREATE_TIME = "USER_INFO_CREATE_TIME";
36 private static final String USER_INFO_WEIGHT = "USER_INFO_WEIGHT";
37 private static final String USER_INFO_GENDER = "USER_INFO_GENDER";
38 private static final String USER_INFO_AGE = "USER_INFO_AGE";
39 private static final String USER_INFO_HEIGHT = "USER_INFO_HEIGHT";
40 private static final String USER_INFO_IMPEDANCE = "USER_INFO_IMPEDANCE";
41 private static final String USER_INFO_BODYBUILDING = "USER_INFO_BODYBUILDING";
42
43 private static final String ACTION_CREATE_OR_UPDATE_USER_INFO = "ACTION_CREATE_OR_UPDATE_USER_INFO";
44 private static final String OPERATION_STATUS = "OPERATION_STATUS";
45 private static final String OPERATION_DESCRIBE = "OPERATION_DESCRIBE";
46
47 private static final String ACTION_DELETE_USER_INFO = "ACTION_DELETE_USER_INFO";
48
49 private static final String ACTION_SPECIFY_USERS = "ACTION_SPECIFY_USERS";
50
51 private static final String ACTION_MEASURE_FINISH_AT_CRITICAL = "ACTION_MEASURE_FINISH_AT_CRITICAL";
52
53 private static final String ACTION_HISTORY_DATA_NUM = "ACTION_HISTORY_DATA_NUM";
54 private static final String HISTORY_DATA_USER_COUNT = "HISTORY_DATA_USER_COUNT";
55 private static final String HISTORY_DATA_COUNT_ARRAY = "HISTORY_DATA_COUNT_ARRAY";
56 private static final String HISTORY_DATA_COUNT = "HISTORY_DATA_COUNT";
57
58 private static final String ACTION_HISTORY_DATA = "ACTION_HISTORY_DATA";
59 private static final String DATA_ID = "DATA_ID";
60 private static final String DATA_WEIGHT = "DATA_WEIGHT";
61 private static final String DATA_IMPEDANCE = "DATA_IMPEDANCE";
62 private static final String DATA_USER_NUM = "DATA_USER_NUM";
63 private static final String DATA_GENDER = "DATA_GENDER";
64 private static final String DATA_AGE = "DATA_AGE";
65 private static final String DATA_HEIGHT = "DATA_HEIGHT";
66 private static final String DATA_MEASURE_TIME = "DATA_MEASURE_TIME";
67 private static final String DATA_RIGHT_TIME = "DATA_RIGHT_TIME";
68 private static final String DATA_BODYBUILDING = "DATA_BODYBUILDING";
69 private static final String DATA_INSTRUCTION_TYPE = "DATA_INSTRUCTION_TYPE";
70 private static final String DATA_BODY_FIT_PERCENTAGE = "DATA_BODY_FIT_PERCENTAGE";
71 private static final String DATA_MUSCLE_MASS = "DATA_MUSCLE_MASS";
72 private static final String DATA_BONE_SALT_CONTENT = "DATA_BONE_SALT_CONTENT";
73 private static final String DATA_BODY_WATER_RATE = "DATA_BODY_WATER_RATE";
74 private static final String DATA_PROTEIN_RATE = "DATA_PROTEIN_RATE";
75 private static final String DATA_SKELETAL_MUSCLE_MASS = "DATA_SKELETAL_MUSCLE_MASS";
76 private static final String DATA_BASAL_METABOLIC_RATE = "DATA_BASAL_METABOLIC_RATE";
77 private static final String DATA_VISCERAL_FAT_GRADE = "DATA_VISCERAL_FAT_GRADE";
78 private static final String DATA_PHYSICAL_AGE = "DATA_PHYSICAL_AGE";
79 private static final String DATA_BODY_MASS_INDEX = "DATA_BODY_MASS_INDEX";
80
81 private static final String DATA_STANDARD_WEIGHT = "DATA_STANDARD_WEIGHT";
82 private static final String DATA_WEIGHT_CONTROL = "DATA_WEIGHT_CONTROL";
83 private static final String DATA_MUSCLE_CONTROL = "DATA_MUSCLE_CONTROL";
84 private static final String DATA_FAT_CONTROL = "DATA_FAT_CONTROL";
85 private static final String DATA_FAT_WEIGHT = "DATA_FAT_WEIGHT";
86 private static final String DATA_DE_FAT_WEIGHT = "DATA_DE_FAT_WEIGHT";
87
88 private static final String ACTION_ONLINE_RESULT = "ACTION_ONLINE_RESULT";
89 private static final String ACTION_DELETE_HISTORY_DATA = "ACTION_DELETE_HISTORY_DATA";
90
91 private static final String ACTION_ANONYMOUS_DATA_NUM = "ACTION_ANONYMOUS_DATA_NUM";
92 private static final String ANONYMOUS_DATA_COUNT = "ANONYMOUS_DATA_COUNT";
93
94 private static final String ACTION_DELETE_ANONYMOUS_DATA = "ACTION_DELETE_ANONYMOUS_DATA";
95 private static final String ACTION_ONLINE_REAL_TIME_WEIGHT = "ACTION_ONLINE_REAL_TIME_WEIGHT";
96 private static final String ACTION_BODY_FAT_RESULT = "ACTION_BODY_FAT_RESULT";
97 private static final String DATA_BODY_FAT_RESULT = "DATA_BODY_FAT_RESULT";
98
99 private static final String ACTION_RESTORE_FACTORY_SETTINGS = "ACTION_RESTORE_FACTORY_SETTINGS";
100
101 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
102
103 private static final String ACTION_HS2S_LightUp_DEVICE = "ACTION_HS2S_LightUp_DEVICE";
104 private static final String HS2S_DEVICE_STATUS = "HS2S_DEVICE_STATUS";
105 private static final String ACTION_HS2S_MEASURE_HEARTRATE = "ACTION_HS2S_MEASURE_HEARTRATE";
106 private static final String ACTION_HS2S_EXIT_MEASURE_HEARTRATE_STATUS = "ACTION_HS2S_EXIT_MEASURE_HEARTRATE_STATUS";
107 private static final String HS2S_MEASURE_HEARTRATE_RESULT = "HS2S_MEASURE_HEARTRATE_RESULT";
108
109 public HS2SProfileModule(ReactApplicationContext reactContext) {
110 super(reactContext);
111 }
112
113 @Override
114 public String getName() {
115 return modelName;
116 }
117
118 @Nullable
119 @Override
120 public Map<String, Object> getConstants() {
121 Map<String, Object> constants = new HashMap<>();
122 constants.put(ACTION_ERROR_HS, Hs2sProfile.ACTION_ERROR_HS);
123 constants.put(ERROR_NUM_HS, Hs2sProfile.ERROR_NUM_HS);
124 constants.put(ERROR_DESCRIPTION_HS, Hs2sProfile.ERROR_DESCRIPTION_HS);
125
126 constants.put(ACTION_GET_DEVICE_INFO, Hs2sProfile.ACTION_GET_DEVICE_INFO);
127 constants.put(HS_USER_COUNT, Hs2sProfile.HS_USER_COUNT);
128 constants.put(HS_UNIT_CURRENT, Hs2sProfile.HS_UNIT_CURRENT);
129
130 constants.put(ACTION_BATTERY_HS, Hs2sProfile.ACTION_BATTERY_HS);
131 constants.put(BATTERY_HS, Hs2sProfile.BATTERY_HS);
132
133 constants.put(ACTION_SET_UNIT_SUCCESS, Hs2sProfile.ACTION_SET_UNIT_SUCCESS);
134
135 constants.put(ACTION_GET_USER_INFO, Hs2sProfile.ACTION_GET_USER_INFO);
136 constants.put(USER_INFO_COUNT, Hs2sProfile.USER_INFO_COUNT);
137 constants.put(USER_INFO_ARRAY, Hs2sProfile.USER_INFO_ARRAY);
138 constants.put(USER_INFO_USER_ID, Hs2sProfile.USER_INFO_USER_ID);
139 constants.put(USER_INFO_CREATE_TIME, Hs2sProfile.USER_INFO_CREATE_TIME);
140 constants.put(USER_INFO_WEIGHT, Hs2sProfile.USER_INFO_WEIGHT);
141 constants.put(USER_INFO_GENDER, Hs2sProfile.USER_INFO_GENDER);
142 constants.put(USER_INFO_AGE, Hs2sProfile.USER_INFO_AGE);
143 constants.put(USER_INFO_HEIGHT, Hs2sProfile.USER_INFO_HEIGHT);
144 constants.put(USER_INFO_IMPEDANCE, Hs2sProfile.USER_INFO_IMPEDANCE);
145 constants.put(USER_INFO_BODYBUILDING, Hs2sProfile.USER_INFO_BODYBUILDING);
146
147 constants.put(ACTION_CREATE_OR_UPDATE_USER_INFO, Hs2sProfile.ACTION_CREATE_OR_UPDATE_USER_INFO);
148 constants.put(OPERATION_STATUS, Hs2sProfile.OPERATION_STATUS);
149 constants.put(OPERATION_DESCRIBE, Hs2sProfile.OPERATION_DESCRIBE);
150
151 constants.put(ACTION_DELETE_USER_INFO, Hs2sProfile.ACTION_DELETE_USER_INFO);
152 constants.put(ACTION_SPECIFY_USERS, Hs2sProfile.ACTION_SPECIFY_USERS);
153 constants.put(ACTION_MEASURE_FINISH_AT_CRITICAL, Hs2sProfile.ACTION_MEASURE_FINISH_AT_CRITICAL);
154
155 constants.put(ACTION_HISTORY_DATA_NUM, Hs2sProfile.ACTION_HISTORY_DATA_NUM);
156 constants.put(HISTORY_DATA_USER_COUNT, Hs2sProfile.HISTORY_DATA_USER_COUNT);
157 constants.put(HISTORY_DATA_COUNT_ARRAY, Hs2sProfile.HISTORY_DATA_COUNT_ARRAY);
158 constants.put(HISTORY_DATA_COUNT, Hs2sProfile.HISTORY_DATA_COUNT);
159
160 constants.put(ACTION_HISTORY_DATA, Hs2sProfile.ACTION_HISTORY_DATA);
161 constants.put(DATA_ID, Hs2sProfile.DATA_ID);
162 constants.put(DATA_WEIGHT, Hs2sProfile.DATA_WEIGHT);
163 constants.put(DATA_IMPEDANCE, Hs2sProfile.DATA_IMPEDANCE);
164 constants.put(DATA_USER_NUM, Hs2sProfile.DATA_USER_NUM);
165 constants.put(DATA_GENDER, Hs2sProfile.DATA_GENDER);
166 constants.put(DATA_AGE, Hs2sProfile.DATA_AGE);
167 constants.put(DATA_HEIGHT, Hs2sProfile.DATA_HEIGHT);
168 constants.put(DATA_MEASURE_TIME, Hs2sProfile.DATA_MEASURE_TIME);
169 constants.put(DATA_RIGHT_TIME, Hs2sProfile.DATA_RIGHT_TIME);
170 constants.put(DATA_BODYBUILDING, Hs2sProfile.DATA_BODYBUILDING);
171 constants.put(DATA_INSTRUCTION_TYPE, Hs2sProfile.DATA_INSTRUCTION_TYPE);
172 constants.put(DATA_BODY_FIT_PERCENTAGE, Hs2sProfile.DATA_BODY_FIT_PERCENTAGE);
173 constants.put(DATA_MUSCLE_MASS, Hs2sProfile.DATA_MUSCLE_MASS);
174 constants.put(DATA_BONE_SALT_CONTENT, Hs2sProfile.DATA_BONE_SALT_CONTENT);
175 constants.put(DATA_BODY_WATER_RATE, Hs2sProfile.DATA_BODY_WATER_RATE);
176 constants.put(DATA_SKELETAL_MUSCLE_MASS, Hs2sProfile.DATA_SKELETAL_MUSCLE_MASS);
177 constants.put(DATA_BASAL_METABOLIC_RATE, Hs2sProfile.DATA_BASAL_METABOLIC_RATE);
178 constants.put(DATA_VISCERAL_FAT_GRADE, Hs2sProfile.DATA_VISCERAL_FAT_GRADE);
179 constants.put(DATA_PHYSICAL_AGE, Hs2sProfile.DATA_PHYSICAL_AGE);
180 constants.put(DATA_BODY_MASS_INDEX, Hs2sProfile.DATA_BODY_MASS_INDEX);
181 constants.put(DATA_STANDARD_WEIGHT, Hs2sProfile.DATA_STANDARD_WEIGHT);
182 constants.put(DATA_WEIGHT_CONTROL, Hs2sProfile.DATA_WEIGHT_CONTROL);
183 constants.put(DATA_MUSCLE_CONTROL, Hs2sProfile.DATA_MUSCLE_CONTROL);
184 constants.put(DATA_FAT_CONTROL, Hs2sProfile.DATA_FAT_CONTROL);
185 constants.put(DATA_FAT_WEIGHT, Hs2sProfile.DATA_FAT_WEIGHT);
186 constants.put(DATA_DE_FAT_WEIGHT, Hs2sProfile.DATA_DE_FAT_WEIGHT);
187
188 constants.put(ACTION_ONLINE_RESULT, Hs2sProfile.ACTION_ONLINE_RESULT);
189 constants.put(ACTION_DELETE_HISTORY_DATA, Hs2sProfile.ACTION_DELETE_HISTORY_DATA);
190
191 constants.put(ACTION_ANONYMOUS_DATA_NUM, Hs2sProfile.ACTION_ANONYMOUS_DATA_NUM);
192 constants.put(ANONYMOUS_DATA_COUNT, Hs2sProfile.ANONYMOUS_DATA_COUNT);
193
194 constants.put(ACTION_DELETE_ANONYMOUS_DATA, Hs2sProfile.ACTION_DELETE_ANONYMOUS_DATA);
195 constants.put(ACTION_ONLINE_REAL_TIME_WEIGHT, Hs2sProfile.ACTION_ONLINE_REAL_TIME_WEIGHT);
196 constants.put(ACTION_BODY_FAT_RESULT, Hs2sProfile.ACTION_BODY_FAT_RESULT);
197 constants.put(DATA_BODY_FAT_RESULT, Hs2sProfile.DATA_BODY_FAT_RESULT);
198
199 constants.put(ACTION_RESTORE_FACTORY_SETTINGS, Hs2sProfile.ACTION_RESTORE_FACTORY_SETTINGS);
200 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
201
202 constants.put(ACTION_HS2S_LightUp_DEVICE, Hs2sProfile.ACTION_SET_BLE_LIGHT);
203 constants.put(HS2S_DEVICE_STATUS, Hs2sProfile.OPERATION_STATUS);
204 constants.put(ACTION_HS2S_MEASURE_HEARTRATE, Hs2sProfile.ACTION_START_HEARTRATE_MEASURE);
205 constants.put(ACTION_HS2S_EXIT_MEASURE_HEARTRATE_STATUS, Hs2sProfile.ACTION_STOP_HEARTRATE_MEASURE);
206 constants.put(HS2S_MEASURE_HEARTRATE_RESULT, Hs2sProfile.DATA_HEARTRATE);
207 return constants;
208 }
209}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS4SModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS4SModule.java
new file mode 100755
index 0000000..e7b8469
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS4SModule.java
@@ -0,0 +1,129 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Hs4Control;
13import com.ihealth.communication.control.Hs4sControl;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.util.ArrayList;
17import java.util.HashMap;
18import java.util.List;
19import java.util.Map;
20
21/**
22 * Created by lixuesong on 16/10/20.
23 */
24@ReactModule(name = "HS4SModule")
25public class HS4SModule extends iHealthBaseModule {
26 private static final String modelName = "HS4SModule";
27 private static final String TAG = "HS4SModule";
28
29 private static final String EVENT_NOTIFY = "event_notify_hs4s";
30
31 public HS4SModule(ReactApplicationContext reactContext) {
32 super(TAG, reactContext);
33 }
34
35 @Override
36 public String getName() {
37 return modelName;
38 }
39
40 @Override
41 public Map<String, Object> getConstants() {
42 Map<String, Object> map = new HashMap<>();
43 map.put("Event_Notify", EVENT_NOTIFY);
44 return map;
45 }
46
47 private static Hs4Control getHs4Control(String mac) {
48 return iHealthDevicesManager.getInstance().getHs4Control(mac);
49 }
50
51 private static Hs4sControl getHs4sControl(String mac) {
52 return iHealthDevicesManager.getInstance().getHs4sControl(mac);
53 }
54
55 @ReactMethod
56 public void getOfflineData(String mac) {
57 Hs4Control hs4Control = getHs4Control(mac);
58 Hs4sControl hs4sControl = getHs4sControl(mac);
59 if (hs4Control != null) {
60 hs4Control.getOfflineData();
61
62 } else if (hs4sControl != null){
63 hs4sControl.getOfflineData();
64
65 } else {
66 Log.e(TAG, "Can not find HS4/HS4S Control mac:" + mac);
67 }
68 }
69
70 @ReactMethod
71 public void measureOnline(String mac, int unit, int userId) {
72 Hs4Control hs4Control = getHs4Control(mac);
73 Hs4sControl hs4sControl = getHs4sControl(mac);
74 if (hs4Control != null) {
75 hs4Control.measureOnline(unit, userId);
76
77 } else if (hs4sControl != null) {
78 hs4sControl.measureOnline(unit, userId);
79
80 } else {
81 Log.e(TAG, "Can not find HS4/HS4S Control mac:" + mac);
82 }
83 }
84
85 @ReactMethod
86 public void disconnect(String mac) {
87 Hs4Control hs4Control = getHs4Control(mac);
88 Hs4sControl hs4sControl = getHs4sControl(mac);
89 if (hs4Control != null) {
90 hs4Control.disconnect();
91
92 } else if (hs4sControl != null) {
93 hs4sControl.disconnect();
94
95 } else {
96 Log.e(TAG, "Can not find HS4/HS4S Control mac:" + mac);
97 }
98 }
99
100 @Override
101 public void handleNotify(String mac, String deviceType, String action, String message) {
102 WritableMap params = Arguments.createMap();
103 params.putString("action", action);
104 params.putString("mac", mac);
105 params.putString("type", deviceType);
106 if (!TextUtils.isEmpty(message)) {
107 Utils.jsonToMap(message, params);
108 }
109 sendEvent(EVENT_NOTIFY, params);
110 }
111
112 @ReactMethod
113 public void getAllConnectedDevices() {
114 List<String> devices = iHealthDevicesManager.getInstance().getHs4Devices();
115 List<String> device2 = iHealthDevicesManager.getInstance().getHs4sDevices();
116 devices.addAll(device2);
117
118 WritableMap params = Arguments.createMap();
119 if (devices.size() > 0) {
120 WritableArray array = Arguments.createArray();
121 for (String device : devices) {
122 array.pushString(device);
123 }
124 params.putArray("devices", array);
125 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
126 }
127 sendEvent(EVENT_NOTIFY, params);
128 }
129}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6Module.java
new file mode 100755
index 0000000..c0da5b2
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6Module.java
@@ -0,0 +1,134 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.HS6Control;
12import com.ihealth.communication.manager.iHealthDeviceHs6Callback;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.Map;
17
18/**
19 * Created by lixuesong on 16/10/20.
20 */
21@ReactModule(name = "HS6Module")
22public class HS6Module extends iHealthBaseModule {
23 private static final String modelName = "HS6Module";
24 private static final String TAG = "HS6Module";
25
26 private static final String EVENT_NOTIFY = "event_notify_hs6";
27 private ReactApplicationContext mContext;
28 private HS6Control mHS6control;
29
30 public HS6Module(ReactApplicationContext reactContext) {
31 super(TAG, reactContext);
32 this.mContext = reactContext;
33 }
34
35 @Override
36 public String getName() {
37 return modelName;
38 }
39
40 @Override
41 public Map<String, Object> getConstants() {
42 Map<String, Object> map = new HashMap<>();
43 map.put("Event_Notify", EVENT_NOTIFY);
44 return map;
45 }
46
47 @ReactMethod
48 public void init(String userName) {
49 mHS6control = new HS6Control(userName, mContext, iHealthDevicesManager.TYPE_HS6, mIHealthDeviceHs6Callback);
50 }
51
52 @ReactMethod
53 public void setWifi(String ssid, String password) {
54 if (mHS6control != null) {
55 mHS6control.setWifi(ssid, password);
56 } else {
57 Log.e(TAG, "Please call init(String username) method first");
58 }
59 }
60
61 @ReactMethod
62 public void bindDeviceHS6(String birthday, float weight, int height, int isSporter, int gender, String serialNumber) {
63 if (mHS6control != null) {
64 mHS6control.bindDeviceHS6(birthday, weight, height, isSporter, gender, serialNumber);
65 } else {
66 Log.e(TAG, "Please call init(String username) method first");
67 }
68 }
69
70 @ReactMethod
71 public void unBindDeviceHS6(String serialNumber) {
72 if (mHS6control != null) {
73 mHS6control.unBindDeviceHS6(serialNumber);
74 } else {
75 Log.e(TAG, "Please call init(String username) method first");
76 }
77 }
78
79 @ReactMethod
80 public void getToken(String clientId, String clientSecret, String username, String clientPara) {
81 if (mHS6control != null) {
82 mHS6control.getToken(clientId, clientSecret, username, clientPara);
83 } else {
84 Log.e(TAG, "Please call init(String username) method first");
85 }
86 }
87
88 @ReactMethod
89 public void setUnit(String username, int unitType) {
90 if (mHS6control != null) {
91 mHS6control.setUnit(username, unitType);
92 } else {
93 Log.e(TAG, "Please call init(String username) method first");
94 }
95 }
96
97 @ReactMethod
98 public void getCloudData(String clientId, String clientSecret, String username, double downloadTS, double pageSize) {
99 if (mHS6control != null) {
100 mHS6control.getDataByMeasuretimeFromCloud(clientId, clientSecret, username, (long) downloadTS, (long) pageSize);
101 } else {
102 Log.e(TAG, "Please call init(String username) method first");
103 }
104 }
105
106
107 @Override
108 public void handleNotify(String mac, String deviceType, String action, String message) {
109 WritableMap params = Arguments.createMap();
110 params.putString("action", action);
111 params.putString("mac", mac);
112 params.putString("type", deviceType);
113 if (!TextUtils.isEmpty(message)) {
114 Utils.jsonToMap(message, params);
115 }
116 sendEvent(EVENT_NOTIFY, params);
117 }
118
119 private iHealthDeviceHs6Callback mIHealthDeviceHs6Callback = new iHealthDeviceHs6Callback() {
120 public void setWifiNotify(String deviceType, String action, String message) {
121 WritableMap params = Arguments.createMap();
122 params.putString("action", action);
123 params.putString("deviceType", deviceType);
124 if (!TextUtils.isEmpty(message)) {
125 Utils.jsonToMap(message, params);
126 }
127 sendEvent(EVENT_NOTIFY, params);
128 }
129
130 public void onNotify(String mac, String deviceType, String action, String message) {
131 handleNotify(mac, deviceType, action, message);
132 }
133 };
134}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6ProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6ProfileModule.java
new file mode 100755
index 0000000..2b3a77d
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HS6ProfileModule.java
@@ -0,0 +1,93 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.HS6Control;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by lixuesong on 15/11/2016.
15 */
16@ReactModule(name = "HS6ProfileModule")
17public class HS6ProfileModule extends ReactContextBaseJavaModule {
18 private static final String modelName = "HS6ProfileModule";
19 private static final String TAG = "HS6ProfileModule";
20
21 private static final String ACTION_HS6_SETWIFI = "ACTION_HS6_SETWIFI";
22 private static final String SETWIFI_RESULT = "SETWIFI_RESULT";
23
24 private static final String ACTION_HS6_BIND = "ACTION_HS6_BIND";
25 private static final String HS6_BIND_EXTRA = "HS6_BIND_EXTRA";
26 private static final String BIND_HS6_RESULT = "BIND_HS6_RESULT";
27 private static final String HS6_MODEL = "HS6_MODEL";
28 private static final String HS6_POSITION = "HS6_POSITION";
29 private static final String HS6_SETTED_WIFI = "HS6_SETTED_WIFI";
30
31 private static final String ACTION_HS6_UNBIND = "ACTION_HS6_UNBIND";
32 private static final String HS6_UNBIND_RESULT = "HS6_UNBIND_RESULT";
33
34 private static final String ACTION_HS6_GET_TOKEN = "ACTION_HS6_GET_TOKEN";
35 private static final String GET_TOKEN_RESULT = "GET_TOKEN_RESULT";
36
37 private static final String ACTION_HS6_SET_UNIT = "ACTION_HS6_SET_UNIT";
38 private static final String SET_UNIT_RESULT = "SET_UNIT_RESULT";
39
40 private static final String ACTION_HS6_ERROR = "ACTION_HS6_ERROR";
41 private static final String HS6_ERROR = "HS6_ERROR";
42
43
44 public static final String ACTION_HS6_GET_DATA = "ACTION_HS6_GET_DATA";
45
46 public static final String DATA_RESULT = "DATA_RESULT";
47
48 public static final String DATA_DOWNLOAD_TS = "DATA_DOWNLOAD_TS";
49 public static final String DATA_LEFTNUMBER = "DATA_LEFTNUMBER";
50
51
52 public HS6ProfileModule(ReactApplicationContext reactContext) {
53 super(reactContext);
54 }
55
56 @Override
57 public String getName() {
58 return modelName;
59 }
60
61 @Nullable
62 @Override
63 public Map<String, Object> getConstants() {
64 Map<String, Object> constants = new HashMap<>();
65 constants.put(ACTION_HS6_SETWIFI, HS6Control.ACTION_HS6_SETWIFI);
66 constants.put(SETWIFI_RESULT, HS6Control.SETWIFI_RESULT);
67
68 constants.put(ACTION_HS6_BIND, HS6Control.ACTION_HS6_BIND);
69 constants.put(HS6_BIND_EXTRA, HS6Control.HS6_BIND_EXTRA);
70 constants.put(BIND_HS6_RESULT, HS6Control.BIND_HS6_RESULT);
71 constants.put(HS6_MODEL, HS6Control.HS6_MODEL);
72 constants.put(HS6_POSITION, HS6Control.HS6_POSITION);
73 constants.put(HS6_SETTED_WIFI, HS6Control.HS6_SETTED_WIFI);
74
75 constants.put(ACTION_HS6_UNBIND, HS6Control.ACTION_HS6_UNBIND);
76 constants.put(HS6_UNBIND_RESULT, HS6Control.HS6_UNBIND_RESULT);
77
78 constants.put(ACTION_HS6_GET_TOKEN, HS6Control.ACTION_HS6_GET_TOKEN);
79 constants.put(GET_TOKEN_RESULT, HS6Control.GET_TOKEN_RESULT);
80
81 constants.put(ACTION_HS6_SET_UNIT, HS6Control.ACTION_HS6_SET_UNIT);
82 constants.put(SET_UNIT_RESULT, HS6Control.SET_UNIT_RESULT);
83
84 constants.put(ACTION_HS6_ERROR, HS6Control.ACTION_HS6_ERROR);
85 constants.put(HS6_ERROR, HS6Control.HS6_ERROR);
86 constants.put(ACTION_HS6_GET_DATA, HS6Control.ACTION_HS6_GET_DATA);
87 constants.put(DATA_RESULT, HS6Control.DATA_RESULT);
88 constants.put(DATA_DOWNLOAD_TS, HS6Control.DATA_DOWNLOAD_TS);
89 constants.put(DATA_LEFTNUMBER, HS6Control.DATA_LEFTNUMBER);
90
91 return constants;
92 }
93}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HSProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HSProfileModule.java
new file mode 100755
index 0000000..75c7930
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/HSProfileModule.java
@@ -0,0 +1,92 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.HsProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by lixuesong on 15/11/2016.
15 */
16@ReactModule(name = "HSProfileModule")
17public class HSProfileModule extends ReactContextBaseJavaModule {
18 private static final String modelName = "HSProfileModule";
19 private static final String TAG = "HSProfileModule";
20
21 private static final String ACTION_LIVEDATA_HS = "ACTION_LIVEDATA_HS";
22 private static final String LIVEDATA_HS = "LIVEDATA_HS";
23
24 private static final String ACTION_ONLINE_RESULT_HS = "ACTION_ONLINE_RESULT_HS";
25 private static final String DATAID = "DATAID";
26 private static final String WEIGHT_HS = "WEIGHT_HS";
27 private static final String FAT_HS = "FAT_HS";
28 private static final String WATER_HS = "WATER_HS";
29 private static final String MUSCLE_HS = "MUSCLE_HS";
30 private static final String SKELETON_HS = "SKELETON_HS";
31 private static final String FATELEVEL_HS = "FATELEVEL_HS";
32 private static final String DCI_HS = "DCI_HS";
33
34 private static final String ACTION_HISTORICAL_DATA_HS = "ACTION_HISTORICAL_DATA_HS";
35 private static final String HISTORDATA_HS = "HISTORDATA_HS";
36 private static final String MEASUREMENT_DATE_HS = "MEASUREMENT_DATE_HS";
37
38 private static final String ACTION_HISTORICAL_DATA_COMPLETE_HS = "ACTION_HISTORICAL_DATA_COMPLETE_HS";
39
40 private static final String ACTION_NO_HISTORICALDATA = "ACTION_NO_HISTORICALDATA";
41
42 private static final String ACTION_ERROR_HS = "ACTION_ERROR_HS";
43 private static final String ERROR_NUM_HS = "ERROR_NUM_HS";
44 private static final String ERROR_ID_ILLEGAL_ARGUMENT = "ERROR_ID_ILLEGAL_ARGUMENT";
45 private static final String ERROR_ID_WIFI_DISABLED = "ERROR_ID_WIFI_DISABLED";
46 private static final String ERROR_DESCRIPTION_HS = "ERROR_DESCRIPTION_HS";
47 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
48
49
50 public HSProfileModule(ReactApplicationContext reactContext) {
51 super(reactContext);
52 }
53
54 @Override
55 public String getName() {
56 return modelName;
57 }
58
59 @Nullable
60 @Override
61 public Map<String, Object> getConstants() {
62 Map<String, Object> constants = new HashMap<>();
63 constants.put(ACTION_LIVEDATA_HS, HsProfile.ACTION_LIVEDATA_HS);
64 constants.put(LIVEDATA_HS, HsProfile.LIVEDATA_HS);
65
66 constants.put(ACTION_ONLINE_RESULT_HS, HsProfile.ACTION_ONLINE_RESULT_HS);
67 constants.put(HISTORDATA_HS, HsProfile.HISTORDATA_HS);
68 constants.put(DATAID, HsProfile.DATAID);
69 constants.put(WEIGHT_HS, HsProfile.WEIGHT_HS);
70 constants.put(FAT_HS, HsProfile.FAT_HS);
71 constants.put(WATER_HS, HsProfile.WATER_HS);
72 constants.put(MUSCLE_HS, HsProfile.MUSCLE_HS);
73 constants.put(SKELETON_HS, HsProfile.SKELETON_HS);
74 constants.put(FATELEVEL_HS, HsProfile.FATELEVEL_HS);
75 constants.put(DCI_HS, HsProfile.DCI_HS);
76
77 constants.put(ACTION_HISTORICAL_DATA_HS, HsProfile.ACTION_HISTORICAL_DATA_HS);
78 constants.put(MEASUREMENT_DATE_HS, HsProfile.MEASUREMENT_DATE_HS);
79
80 constants.put(ACTION_HISTORICAL_DATA_COMPLETE_HS, HsProfile.ACTION_HISTORICAL_DATA_COMPLETE_HS);
81
82 constants.put(ACTION_NO_HISTORICALDATA, HsProfile.ACTION_NO_HISTORICALDATA);
83
84 constants.put(ACTION_ERROR_HS, HsProfile.ACTION_ERROR_HS);
85 constants.put(ERROR_NUM_HS, HsProfile.ERROR_NUM_HS);
86 constants.put(ERROR_ID_ILLEGAL_ARGUMENT, HsProfile.ERROR_ID_ILLEGAL_ARGUMENT);
87 constants.put(ERROR_ID_WIFI_DISABLED, HsProfile.ERROR_ID_WIFI_DISABLED);
88 constants.put(ERROR_DESCRIPTION_HS, HsProfile.ERROR_DESCRIPTION_HS);
89 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
90 return constants;
91 }
92}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BModule.java
new file mode 100644
index 0000000..ab26294
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BModule.java
@@ -0,0 +1,98 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.NT13BControl;
12import com.ihealth.communication.manager.iHealthDevicesManager;
13
14import java.util.HashMap;
15import java.util.List;
16import java.util.Map;
17
18@ReactModule(name = "NT13BModule")
19public class NT13BModule extends iHealthBaseModule{
20
21 private static final String modelName = "NT13BModule";
22 private static final String TAG = "NT13BModule";
23
24 private static final String EVENT_NOTIFY = "event_notify_nt13b";
25
26 public NT13BModule(ReactApplicationContext reactContext) {
27 super(TAG, reactContext);
28 }
29
30 @Override
31 public String getName() {
32 return modelName;
33 }
34
35 @Override
36 public Map<String, Object> getConstants() {
37 Map<String, Object> map = new HashMap<>();
38 map.put("Event_Notify", EVENT_NOTIFY);
39 return map;
40 }
41
42 @ReactMethod
43 public void measure(String mac) {
44 NT13BControl nt13bControl = getNt13bControl(mac);
45 if (nt13bControl != null) {
46 nt13bControl.getMeasurement();
47 }
48 }
49
50 @ReactMethod
51 public void disconnect(String mac) {
52 NT13BControl nt13bControl = getNt13bControl(mac);
53 if (nt13bControl != null) {
54 nt13bControl.disconnect();
55 }
56 }
57
58 private NT13BControl getNt13bControl(String mac) {
59 NT13BControl nt13bControl = iHealthDevicesManager.getInstance().getNT13BControl(mac);
60 if (nt13bControl == null) {
61 senErrMessage(400);
62 }
63 return nt13bControl;
64 }
65
66 private void senErrMessage(int errId) {
67 WritableMap params = Arguments.createMap();
68 params.putInt("errorid", errId);
69 sendEvent(EVENT_NOTIFY, params);
70 }
71
72 @Override
73 public void handleNotify(String mac, String deviceType, String action, String message) {
74 WritableMap params = Arguments.createMap();
75 params.putString("action", action);
76 params.putString("mac", mac);
77 params.putString("type", deviceType);
78 if (!TextUtils.isEmpty(message)) {
79 Utils.jsonToMap(message, params);
80 }
81 sendEvent(EVENT_NOTIFY, params);
82 }
83
84 @ReactMethod
85 public void getAllConnectedDevices() {
86 List<String> devices = iHealthDevicesManager.getInstance().getNT13BDevices();
87 WritableMap params = Arguments.createMap();
88 if (devices.size() > 0) {
89 WritableArray array = Arguments.createArray();
90 for (String device : devices) {
91 array.pushString(device);
92 }
93 params.putArray("devices", array);
94 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
95 }
96 sendEvent(EVENT_NOTIFY, params);
97 }
98}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BProfileModule.java
new file mode 100644
index 0000000..8160b90
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/NT13BProfileModule.java
@@ -0,0 +1,52 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.NT13BProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13@ReactModule(name = "NT13BProfileModule")
14public class NT13BProfileModule extends ReactContextBaseJavaModule {
15
16 private static final String modelName = "NT13BProfileModule";
17 private static final String TAG = "NT13BProfileModule";
18
19 private static final String ACTION_MEASUREMENT_RESULT = "ACTION_MEASUREMENT_RESULT";
20 private static final String UNIT_FLAG = "unit_flag";
21 private static final String RESULT = "result";
22 private static final String TS_FLAG = "ts_flag";
23 private static final String TS = "ts";
24 private static final String THERMOMETER_TYPE_FLAG = "thermometer_type_flag";
25 private static final String THERMOMETER_TYPE = "thermometer_type";
26
27 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
28
29 public NT13BProfileModule(ReactApplicationContext reactContext) {
30 super(reactContext);
31 }
32
33 @Override
34 public String getName() {
35 return modelName;
36 }
37
38 @Nullable
39 @Override
40 public Map<String, Object> getConstants() {
41 Map<String, Object> constants = new HashMap<>();
42 constants.put(ACTION_MEASUREMENT_RESULT, NT13BProfile.ACTION_MEASUREMENT_RESULT);
43 constants.put(UNIT_FLAG, NT13BProfile.UNIT_FLAG);
44 constants.put(RESULT, NT13BProfile.RESULT);
45 constants.put(TS_FLAG, NT13BProfile.TS_FLAG);
46 constants.put(TS, NT13BProfile.TS);
47 constants.put(THERMOMETER_TYPE_FLAG, NT13BProfile.THERMOMETER_TYPE_FLAG);
48 constants.put(THERMOMETER_TYPE, NT13BProfile.THERMOMETER_TYPE);
49 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
50 return constants;
51 }
52}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1Module.java
new file mode 100644
index 0000000..3213531
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1Module.java
@@ -0,0 +1,99 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.Po1Control;
12import com.ihealth.communication.control.Pt3sbtControl;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19@ReactModule(name = "PO1Module")
20public class PO1Module extends iHealthBaseModule {
21
22 private static final String modelName = PO1Module.class.getSimpleName();
23 private static final String TAG = PO1Module.class.getSimpleName();
24
25 private static final String EVENT_NOTIFY = "event_notify_po1";
26
27 public PO1Module(ReactApplicationContext reactContext) {
28 super(TAG, reactContext);
29 }
30
31 @Override
32 public String getName() {
33 return modelName;
34 }
35
36 @Override
37 public Map<String, Object> getConstants() {
38 Map<String, Object> map = new HashMap<>();
39 map.put("Event_Notify", EVENT_NOTIFY);
40 return map;
41 }
42
43 @ReactMethod
44 public void getBattery(String mac) {
45 Po1Control po1Control = getPo1Control(mac);
46 if (po1Control != null) {
47 po1Control.getBattery();
48 }
49 }
50
51 @ReactMethod
52 public void disconnect(String mac) {
53 Po1Control po1Control = getPo1Control(mac);
54 if (po1Control != null) {
55 po1Control.disconnect();
56 }
57 }
58
59 private Po1Control getPo1Control(String mac) {
60 Po1Control po1Control = iHealthDevicesManager.getInstance().getPo1Device(mac);
61 if (po1Control == null) {
62 senErrMessage(400);
63 }
64 return po1Control;
65 }
66
67 private void senErrMessage(int errId) {
68 WritableMap params = Arguments.createMap();
69 params.putInt("errorid", errId);
70 sendEvent(EVENT_NOTIFY, params);
71 }
72
73 @Override
74 public void handleNotify(String mac, String deviceType, String action, String message) {
75 WritableMap params = Arguments.createMap();
76 params.putString("action", action);
77 params.putString("mac", mac);
78 params.putString("type", deviceType);
79 if (!TextUtils.isEmpty(message)) {
80 Utils.jsonToMap(message, params);
81 }
82 sendEvent(EVENT_NOTIFY, params);
83 }
84
85 @ReactMethod
86 public void getAllConnectedDevices() {
87 List<String> devices = iHealthDevicesManager.getInstance().getPo1Devices();
88 WritableMap params = Arguments.createMap();
89 if (devices.size() > 0) {
90 WritableArray array = Arguments.createArray();
91 for (String device : devices) {
92 array.pushString(device);
93 }
94 params.putArray("devices", array);
95 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
96 }
97 sendEvent(EVENT_NOTIFY, params);
98 }
99}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1ProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1ProfileModule.java
new file mode 100644
index 0000000..8860361
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO1ProfileModule.java
@@ -0,0 +1,73 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactContextBaseJavaModule;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Po1Profile;
13import com.ihealth.communication.control.PoProfile;
14import com.ihealth.communication.control.Pt3sbtControl;
15import com.ihealth.communication.manager.iHealthDevicesManager;
16
17import java.util.HashMap;
18import java.util.List;
19import java.util.Map;
20
21import javax.annotation.Nullable;
22
23@ReactModule(name = "PO1ProfileModule")
24public class PO1ProfileModule extends ReactContextBaseJavaModule {
25
26 private static final String modelName = PO1ProfileModule.class.getSimpleName();
27 private static final String TAG = PO1ProfileModule.class.getSimpleName();
28
29 private static final String ACTION_BO_MEASUREMENT = "ACTION_BO_MEASUREMENT";
30 private static final String ACTION_ERROR_PO1 = "ACTION_ERROR_PO1";
31 private static final String ACTION_GET_BATTERY = "ACTION_GET_BATTERY";
32 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
33
34 private static final String ERROR_ID = "ERROR_ID";
35 private static final String ERROR_DESCRIPTION = "ERROR_DESCRIPTION";
36 private static final String BATTERY = "BATTERY";
37 private static final String STATUS = "STATUS";
38
39 private static final String BLOOD_OXYGEN = "PO1_BLOOD_OXYGEN";
40 private static final String PULSE = "PO1_PULSE";
41 private static final String PULSE_FORCE = "PO1_PULSE_FORCE";
42 private static final String PI = "PO1_PI";
43 private static final String WAVE = "PO1_WAVE";
44
45 public PO1ProfileModule(ReactApplicationContext reactContext) {
46 super(reactContext);
47 }
48
49 @Override
50 public String getName() {
51 return modelName;
52 }
53
54 @Nullable
55 @Override
56 public Map<String, Object> getConstants() {
57 Map<String, Object> constants = new HashMap<>();
58 constants.put(ACTION_BO_MEASUREMENT, Po1Profile.ACTION_BO_MEASUREMENT);
59 constants.put(ACTION_GET_BATTERY, Po1Profile.ACTION_GET_BATTERY);
60 constants.put(ACTION_ERROR_PO1, Po1Profile.ACTION_ERROR_PO1);
61 constants.put(ERROR_ID, Po1Profile.ERROR_ID);
62 constants.put(ERROR_DESCRIPTION, Po1Profile.ERROR_DESCRIPTION);
63 constants.put(BATTERY, Po1Profile.BATTERY);
64 constants.put(STATUS, Po1Profile.STATUS);
65 constants.put(BLOOD_OXYGEN, Po1Profile.BLOOD_OXYGEN);
66 constants.put(PULSE, Po1Profile.PULSE);
67 constants.put(PULSE_FORCE, Po1Profile.PULSE_FORCE);
68 constants.put(PI, Po1Profile.PI);
69 constants.put(WAVE, Po1Profile.WAVE);
70 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
71 return constants;
72 }
73}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO3Module.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO3Module.java
new file mode 100755
index 0000000..2db176c
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PO3Module.java
@@ -0,0 +1,115 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4import android.util.Log;
5
6import com.facebook.react.bridge.Arguments;
7import com.facebook.react.bridge.ReactApplicationContext;
8import com.facebook.react.bridge.ReactMethod;
9import com.facebook.react.bridge.WritableArray;
10import com.facebook.react.bridge.WritableMap;
11import com.facebook.react.module.annotations.ReactModule;
12import com.ihealth.communication.control.Po3Control;
13import com.ihealth.communication.manager.iHealthDevicesManager;
14
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19/**
20 * Created by lixuesong on 2016/11/21.
21 */
22@ReactModule(name = "PO3Module")
23public class PO3Module extends iHealthBaseModule {
24 private static final String modelName = "PO3Module";
25 private static final String TAG = "PO3Module";
26
27 private static final String EVENT_NOTIFY = "event_notify_po3";
28
29 public PO3Module(ReactApplicationContext reactContext) {
30 super(TAG, reactContext);
31 }
32
33 @Override
34 public String getName() {
35 return modelName;
36 }
37
38 @Override
39 public Map<String, Object> getConstants() {
40 Map<String, Object> map = new HashMap<>();
41 map.put("Event_Notify", EVENT_NOTIFY);
42 return map;
43 }
44
45 private static Po3Control getControl(String mac) {
46 return iHealthDevicesManager.getInstance().getPo3Control(mac);
47 }
48
49 @ReactMethod
50 public void getBattery(String mac) {
51 Po3Control po3Control = getControl(mac);
52 if (po3Control != null) {
53 po3Control.getBattery();
54 } else {
55 Log.e(TAG, "Can not find PO3 Control mac:" + mac);
56 }
57 }
58
59 @ReactMethod
60 public void startMeasure(String mac) {
61 Po3Control po3Control = getControl(mac);
62 if (po3Control != null) {
63 po3Control.startMeasure();
64 } else {
65 Log.e(TAG, "Can not find PO3 Control mac:" + mac);
66 }
67 }
68
69 @ReactMethod
70 public void getHistoryData(String mac) {
71 Po3Control po3Control = getControl(mac);
72 if (po3Control != null) {
73 po3Control.getHistoryData();
74 } else {
75 Log.e(TAG, "Can not find PO3 Control mac:" + mac);
76 }
77 }
78
79 @ReactMethod
80 public void disconnect(String mac) {
81 Po3Control po3Control = getControl(mac);
82 if (po3Control != null) {
83 po3Control.disconnect();
84 } else {
85 Log.e(TAG, "Can not find PO3 Control mac:" + mac);
86 }
87 }
88
89 @Override
90 public void handleNotify(String mac, String deviceType, String action, String message) {
91 WritableMap params = Arguments.createMap();
92 params.putString("action", action);
93 params.putString("mac", mac);
94 params.putString("type", deviceType);
95 if (!TextUtils.isEmpty(message)) {
96 Utils.jsonToMap(message, params);
97 }
98 sendEvent(EVENT_NOTIFY, params);
99 }
100
101 @ReactMethod
102 public void getAllConnectedDevices() {
103 List<String> devices = iHealthDevicesManager.getInstance().getPo3Devices();
104 WritableMap params = Arguments.createMap();
105 if (devices.size() > 0) {
106 WritableArray array = Arguments.createArray();
107 for (String device : devices) {
108 array.pushString(device);
109 }
110 params.putArray("devices", array);
111 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
112 }
113 sendEvent(EVENT_NOTIFY, params);
114 }
115}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/POProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/POProfileModule.java
new file mode 100755
index 0000000..ca6a962
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/POProfileModule.java
@@ -0,0 +1,78 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.PoProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13/**
14 * Created by lixuesong on 15/11/2016.
15 */
16@ReactModule(name = "POProfileModule")
17public class POProfileModule extends ReactContextBaseJavaModule {
18 private static final String modelName = "POProfileModule";
19 private static final String TAG = "POProfileModule";
20
21 private static final String ACTION_BATTERY_PO = "ACTION_BATTERY_PO";
22 private static final String BATTERY_PO = "BATTERY_PO";
23
24 private static final String ACTION_LIVEDA_PO = "ACTION_LIVEDA_PO";
25 private static final String PULSE_WAVE_PO = "PULSE_WAVE_PO";
26 private static final String PI_PO = "PI_PO";
27 private static final String PULSE_STRENGTH_PO = "PULSE_STRENGTH_PO";
28 private static final String BLOOD_OXYGEN_PO = "BLOOD_OXYGEN_PO";
29 private static final String PULSE_RATE_PO = "PULSE_RATE_PO";
30
31 private static final String ACTION_RESULTDATA_PO = "ACTION_RESULTDATA_PO";
32 private static final String DATAID = "DATAID";
33
34 private static final String ACTION_OFFLINEDATA_PO = "ACTION_OFFLINEDATA_PO";
35 private static final String OFFLINEDATA_PO = "OFFLINEDATA_PO";
36 private static final String MEASURE_DATE_PO = "MEASURE_DATE_PO";
37
38 private static final String ACTION_NO_OFFLINEDATA_PO = "ACTION_NO_OFFLINEDATA_PO";
39 private static final String ACTION_ERROR_PO = "ACTION_ERROR_PO";
40 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
41
42
43 public POProfileModule(ReactApplicationContext reactContext) {
44 super(reactContext);
45 }
46
47 @Override
48 public String getName() {
49 return modelName;
50 }
51
52 @Nullable
53 @Override
54 public Map<String, Object> getConstants() {
55 Map<String, Object> constants = new HashMap<>();
56 constants.put(ACTION_BATTERY_PO, PoProfile.ACTION_BATTERY_PO);
57 constants.put(BATTERY_PO, PoProfile.BATTERY_PO);
58
59 constants.put(ACTION_LIVEDA_PO, PoProfile.ACTION_LIVEDA_PO);
60 constants.put(PULSE_WAVE_PO, PoProfile.PULSE_WAVE_PO);
61 constants.put(PI_PO, PoProfile.PI_PO);
62 constants.put(PULSE_STRENGTH_PO, PoProfile.PULSE_STRENGTH_PO);
63 constants.put(BLOOD_OXYGEN_PO, PoProfile.BLOOD_OXYGEN_PO);
64 constants.put(PULSE_RATE_PO, PoProfile.PULSE_RATE_PO);
65
66 constants.put(ACTION_RESULTDATA_PO, PoProfile.ACTION_RESULTDATA_PO);
67 constants.put(DATAID, PoProfile.DATAID);
68
69 constants.put(ACTION_OFFLINEDATA_PO, PoProfile.ACTION_OFFLINEDATA_PO);
70 constants.put(OFFLINEDATA_PO, PoProfile.OFFLINEDATA_PO);
71 constants.put(MEASURE_DATE_PO, PoProfile.MEASURE_DATE_PO);
72
73 constants.put(ACTION_NO_OFFLINEDATA_PO, PoProfile.ACTION_NO_OFFLINEDATA_PO);
74 constants.put(ACTION_ERROR_PO, PoProfile.ACTION_ERROR_PO);
75 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
76 return constants;
77 }
78}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTModule.java
new file mode 100644
index 0000000..cefb077
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTModule.java
@@ -0,0 +1,152 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.Pt3sbtControl;
12import com.ihealth.communication.control.Pt3sbtProfile;
13import com.ihealth.communication.control.TS28BControl;
14import com.ihealth.communication.manager.iHealthDevicesManager;
15
16import java.util.HashMap;
17import java.util.List;
18import java.util.Map;
19
20@ReactModule(name = "PT3SBTModule")
21public class PT3SBTModule extends iHealthBaseModule {
22
23 private static final String modelName = PT3SBTModule.class.getSimpleName();
24 private static final String TAG = PT3SBTModule.class.getSimpleName();
25
26 private static final String EVENT_NOTIFY = "event_notify_pt3sbt";
27
28 public PT3SBTModule(ReactApplicationContext reactContext) {
29 super(TAG, reactContext);
30 }
31
32 @Override
33 public String getName() {
34 return modelName;
35 }
36
37 @Override
38 public Map<String, Object> getConstants() {
39 Map<String, Object> map = new HashMap<>();
40 map.put("Event_Notify", EVENT_NOTIFY);
41 return map;
42 }
43
44 @ReactMethod
45 public void setTime(String mac) {
46 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
47 if (pt3sbtControl != null) {
48 pt3sbtControl.setTime();
49 }
50 }
51
52 @ReactMethod
53 public void getBattery(String mac) {
54 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
55 if (pt3sbtControl != null) {
56 pt3sbtControl.getBattery();
57 }
58 }
59
60 @ReactMethod
61 public void setUnit(String mac, int unit) {
62 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
63 if (pt3sbtControl != null) {
64 if (unit == 1) {
65 pt3sbtControl.setUnit(Pt3sbtProfile.PT3SBT_UNIT.Centigrade);
66 } else {
67 pt3sbtControl.setUnit(Pt3sbtProfile.PT3SBT_UNIT.Fahrenheit);
68 }
69 }
70 }
71
72 @ReactMethod
73 public void getUnit(String mac) {
74 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
75 if (pt3sbtControl != null) {
76 pt3sbtControl.getUnit();
77 }
78 }
79
80 @ReactMethod
81 public void getHistoryCount(String mac) {
82 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
83 if (pt3sbtControl != null) {
84 pt3sbtControl.getHistoryCount();
85 }
86 }
87
88 @ReactMethod
89 public void getHistoryData(String mac) {
90 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
91 if (pt3sbtControl != null) {
92 pt3sbtControl.getHistoryData();
93 }
94 }
95
96 @ReactMethod
97 public void deleteHistory(String mac) {
98 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
99 if (pt3sbtControl != null) {
100 pt3sbtControl.deleteHistory();
101 }
102 }
103
104 @ReactMethod
105 public void disconnect(String mac) {
106 Pt3sbtControl pt3sbtControl = getPt3sbtControl(mac);
107 if (pt3sbtControl != null) {
108 pt3sbtControl.disconnect();
109 }
110 }
111
112 private Pt3sbtControl getPt3sbtControl(String mac) {
113 Pt3sbtControl pt3sbtControl = iHealthDevicesManager.getInstance().getPt3sbtDevice(mac);
114 if (pt3sbtControl == null) {
115 senErrMessage(400);
116 }
117 return pt3sbtControl;
118 }
119
120 private void senErrMessage(int errId) {
121 WritableMap params = Arguments.createMap();
122 params.putInt("errorid", errId);
123 sendEvent(EVENT_NOTIFY, params);
124 }
125
126 @Override
127 public void handleNotify(String mac, String deviceType, String action, String message) {
128 WritableMap params = Arguments.createMap();
129 params.putString("action", action);
130 params.putString("mac", mac);
131 params.putString("type", deviceType);
132 if (!TextUtils.isEmpty(message)) {
133 Utils.jsonToMap(message, params);
134 }
135 sendEvent(EVENT_NOTIFY, params);
136 }
137
138 @ReactMethod
139 public void getAllConnectedDevices() {
140 List<String> devices = iHealthDevicesManager.getInstance().getPt3Devices();
141 WritableMap params = Arguments.createMap();
142 if (devices.size() > 0) {
143 WritableArray array = Arguments.createArray();
144 for (String device : devices) {
145 array.pushString(device);
146 }
147 params.putArray("devices", array);
148 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
149 }
150 sendEvent(EVENT_NOTIFY, params);
151 }
152}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTProfileModule.java
new file mode 100644
index 0000000..7ef1282
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/PT3SBTProfileModule.java
@@ -0,0 +1,73 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.Pt3sbtProfile;
7import com.ihealth.communication.control.TS28BProfile;
8
9import java.util.HashMap;
10import java.util.Map;
11
12import javax.annotation.Nullable;
13
14@ReactModule(name = "PT3SBTProfileModule")
15public class PT3SBTProfileModule extends ReactContextBaseJavaModule {
16
17 private static final String modelName = PT3SBTProfileModule.class.getSimpleName();
18 private static final String TAG = PT3SBTProfileModule.class.getSimpleName();
19
20 private static final String ACTION_SET_TIME = "ACTION_SET_TIME";
21 private static final String ACTION_GET_BATTERY = "ACTION_GET_BATTERY";
22 private static final String ACTION_SET_UNIT = "ACTION_SET_UNIT";
23 private static final String ACTION_GET_UNIT = "ACTION_GET_UNIT";
24 private static final String ACTION_GET_HISTORY_COUNT = "ACTION_GET_HISTORY_COUNT";
25 private static final String ACTION_GET_HISTORY_DATA = "ACTION_GET_HISTORY_DATA";
26 private static final String ACTION_DELETE_HISTORY_DATA = "ACTION_DELETE_HISTORY_DATA";
27 private static final String ACTION_TEMPERATURE_MEASUREMENT = "ACTION_TEMPERATURE_MEASUREMENT";
28 private static final String ACTION_PUB_UNIT = "ACTION_PUB_UNIT";
29 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
30
31 private static final String STATUS = "STATUS";
32 private static final String BATTERY = "BATTERY";
33 private static final String UNIT = "UNIT";
34 private static final String COUNT = "COUNT";
35 private static final String TEMPERATURE = "TEMPERATURE";
36 private static final String TS = "TS";
37 private static final String HISTORY = "HISTORY";
38
39 public PT3SBTProfileModule(ReactApplicationContext reactContext) {
40 super(reactContext);
41 }
42
43 @Override
44 public String getName() {
45 return modelName;
46 }
47
48 @Nullable
49 @Override
50 public Map<String, Object> getConstants() {
51 Map<String, Object> constants = new HashMap<>();
52 constants.put(ACTION_SET_TIME, Pt3sbtProfile.ACTION_SET_TIME);
53 constants.put(ACTION_GET_BATTERY, Pt3sbtProfile.ACTION_GET_BATTERY);
54 constants.put(ACTION_SET_UNIT, Pt3sbtProfile.ACTION_SET_UNIT);
55 constants.put(ACTION_GET_UNIT, Pt3sbtProfile.ACTION_GET_UNIT);
56 constants.put(ACTION_GET_HISTORY_COUNT, Pt3sbtProfile.ACTION_GET_HISTORY_COUNT);
57 constants.put(ACTION_GET_HISTORY_DATA, Pt3sbtProfile.ACTION_GET_HISTORY_DATA);
58 constants.put(ACTION_DELETE_HISTORY_DATA, Pt3sbtProfile.ACTION_DELETE_HISTORY_DATA);
59 constants.put(ACTION_TEMPERATURE_MEASUREMENT, Pt3sbtProfile.ACTION_TEMPERATURE_MEASUREMENT);
60 constants.put(ACTION_PUB_UNIT, Pt3sbtProfile.ACTION_PUB_UNIT);
61 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
62
63 constants.put(STATUS, Pt3sbtProfile.STATUS);
64 constants.put(BATTERY, Pt3sbtProfile.BATTERY);
65 constants.put(UNIT, Pt3sbtProfile.UNIT);
66 constants.put(TS, Pt3sbtProfile.TS);
67 constants.put(COUNT, Pt3sbtProfile.COUNT);
68 constants.put(TEMPERATURE, Pt3sbtProfile.TEMPERATURE);
69 constants.put(HISTORY, Pt3sbtProfile.HISTORY);
70
71 return constants;
72 }
73}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BModule.java
new file mode 100644
index 0000000..a6c2ed5
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BModule.java
@@ -0,0 +1,98 @@
1package com.ihealth.ihealthlibrary;
2
3import android.text.TextUtils;
4
5import com.facebook.react.bridge.Arguments;
6import com.facebook.react.bridge.ReactApplicationContext;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10import com.facebook.react.module.annotations.ReactModule;
11import com.ihealth.communication.control.TS28BControl;
12import com.ihealth.communication.manager.iHealthDevicesManager;
13
14import java.util.HashMap;
15import java.util.List;
16import java.util.Map;
17
18@ReactModule(name = "TS28BModule")
19public class TS28BModule extends iHealthBaseModule {
20
21 private static final String modelName = "TS28BModule";
22 private static final String TAG = "TS28BModule";
23
24 private static final String EVENT_NOTIFY = "event_notify_ts28b";
25
26 public TS28BModule(ReactApplicationContext reactContext) {
27 super(TAG, reactContext);
28 }
29
30 @Override
31 public String getName() {
32 return modelName;
33 }
34
35 @Override
36 public Map<String, Object> getConstants() {
37 Map<String, Object> map = new HashMap<>();
38 map.put("Event_Notify", EVENT_NOTIFY);
39 return map;
40 }
41
42 @ReactMethod
43 public void measure(String mac) {
44 TS28BControl ts28bControl = getTs28bControl(mac);
45 if (ts28bControl != null) {
46 ts28bControl.getMeasurement();
47 }
48 }
49
50 @ReactMethod
51 public void disconnect(String mac) {
52 TS28BControl ts28bControl = getTs28bControl(mac);
53 if (ts28bControl != null) {
54 ts28bControl.disconnect();
55 }
56 }
57
58 private TS28BControl getTs28bControl(String mac) {
59 TS28BControl ts28bControl = iHealthDevicesManager.getInstance().getTS28BControl(mac);
60 if (ts28bControl == null) {
61 senErrMessage(400);
62 }
63 return ts28bControl;
64 }
65
66 private void senErrMessage(int errId) {
67 WritableMap params = Arguments.createMap();
68 params.putInt("errorid", errId);
69 sendEvent(EVENT_NOTIFY, params);
70 }
71
72 @Override
73 public void handleNotify(String mac, String deviceType, String action, String message) {
74 WritableMap params = Arguments.createMap();
75 params.putString("action", action);
76 params.putString("mac", mac);
77 params.putString("type", deviceType);
78 if (!TextUtils.isEmpty(message)) {
79 Utils.jsonToMap(message, params);
80 }
81 sendEvent(EVENT_NOTIFY, params);
82 }
83
84 @ReactMethod
85 public void getAllConnectedDevices() {
86 List<String> devices = iHealthDevicesManager.getInstance().getTS28BDevices();
87 WritableMap params = Arguments.createMap();
88 if (devices.size() > 0) {
89 WritableArray array = Arguments.createArray();
90 for (String device : devices) {
91 array.pushString(device);
92 }
93 params.putArray("devices", array);
94 params.putString("action", ACTION_GET_ALL_CONNECTED_DEVICES);
95 }
96 sendEvent(EVENT_NOTIFY, params);
97 }
98}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BProfileModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BProfileModule.java
new file mode 100644
index 0000000..4becc24
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/TS28BProfileModule.java
@@ -0,0 +1,52 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.bridge.ReactApplicationContext;
4import com.facebook.react.bridge.ReactContextBaseJavaModule;
5import com.facebook.react.module.annotations.ReactModule;
6import com.ihealth.communication.control.TS28BProfile;
7
8import java.util.HashMap;
9import java.util.Map;
10
11import javax.annotation.Nullable;
12
13@ReactModule(name = "TS28BProfileModule")
14public class TS28BProfileModule extends ReactContextBaseJavaModule {
15
16 private static final String modelName = "TS28BProfileModule";
17 private static final String TAG = "TS28BProfileModule";
18
19 private static final String ACTION_MEASUREMENT_RESULT = "ACTION_MEASUREMENT_RESULT";
20 private static final String UNIT_FLAG = "unit_flag";
21 private static final String RESULT = "result";
22 private static final String TS_FLAG = "ts_flag";
23 private static final String TS = "ts";
24 private static final String THERMOMETER_TYPE_FLAG = "thermometer_type_flag";
25 private static final String THERMOMETER_TYPE = "thermometer_type";
26
27 private static final String ACTION_GET_ALL_CONNECTED_DEVICES = "ACTION_GET_ALL_CONNECTED_DEVICES";
28
29 public TS28BProfileModule(ReactApplicationContext reactContext) {
30 super(reactContext);
31 }
32
33 @Override
34 public String getName() {
35 return modelName;
36 }
37
38 @Nullable
39 @Override
40 public Map<String, Object> getConstants() {
41 Map<String, Object> constants = new HashMap<>();
42 constants.put(ACTION_MEASUREMENT_RESULT, TS28BProfile.ACTION_MEASUREMENT_RESULT);
43 constants.put(UNIT_FLAG, TS28BProfile.UNIT_FLAG);
44 constants.put(RESULT, TS28BProfile.RESULT);
45 constants.put(TS_FLAG, TS28BProfile.TS_FLAG);
46 constants.put(TS, TS28BProfile.TS);
47 constants.put(THERMOMETER_TYPE_FLAG, TS28BProfile.THERMOMETER_TYPE_FLAG);
48 constants.put(THERMOMETER_TYPE, TS28BProfile.THERMOMETER_TYPE);
49 constants.put(ACTION_GET_ALL_CONNECTED_DEVICES, iHealthBaseModule.ACTION_GET_ALL_CONNECTED_DEVICES);
50 return constants;
51 }
52}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/Utils.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/Utils.java
new file mode 100755
index 0000000..8d95011
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/Utils.java
@@ -0,0 +1,123 @@
1package com.ihealth.ihealthlibrary;
2
3
4
5import android.util.Log;
6
7import com.facebook.react.bridge.Arguments;
8import com.facebook.react.bridge.WritableArray;
9import com.facebook.react.bridge.WritableMap;
10
11import org.json.JSONArray;
12import org.json.JSONException;
13import org.json.JSONObject;
14
15
16import java.util.Iterator;
17
18
19/**
20 * Created by jing on 16/11/10.
21 */
22
23
24public class Utils {
25
26 private static final String TAG = "Utils";
27
28
29 public static void jsonToMap(String jsonString, WritableMap writableMap) {
30 JSONObject jsonObject = null;
31 try {
32 jsonObject = new JSONObject(jsonString);
33
34 if (jsonObject.length()>0) {
35 for (Iterator<String> keys=jsonObject.keys(); keys.hasNext();) {
36 String key = keys.next();
37 try {
38 Object object = jsonObject.get(key);
39 if (object instanceof JSONObject) {
40 writableMap.putMap(key, getMapFromJSONObject((JSONObject) object));
41 } else if (object instanceof JSONArray) {
42 writableMap.putArray(key, getWritableArrayFromJSONArray((JSONArray) object));
43 } else {
44 objectToMap(object, writableMap, key);
45 }
46 } catch (JSONException e) {
47 e.printStackTrace();
48 }
49 }
50 }
51
52 } catch (JSONException e) {
53 e.printStackTrace();
54 }
55 }
56
57 public static WritableMap getMapFromJSONObject(JSONObject object) {
58 WritableMap map = Arguments.createMap();
59 Iterator<String> keyIterator = object.keys();
60 while (keyIterator.hasNext()) {
61 String key = keyIterator.next();
62 try {
63 Object value = object.get(key);
64 if (value instanceof JSONObject) {
65 // value is JSONObject case
66 map.putMap(key, getMapFromJSONObject((JSONObject) value));
67 } else if (value instanceof JSONArray) {
68 // value is JSONArray case
69 map.putArray(key, getWritableArrayFromJSONArray((JSONArray) value));
70 } else {
71 // Normal object case
72 objectToMap(value, map, key);
73 }
74 } catch (JSONException e) {
75 e.printStackTrace();
76 }
77 }
78 return map;
79 }
80
81 public static WritableArray getWritableArrayFromJSONArray(JSONArray array) {
82 WritableArray writableArray = Arguments.createArray();
83 for (int i = 0; i < array.length(); i++) {
84 try {
85 Object objectInArray = array.get(i);
86 if (objectInArray instanceof JSONObject) {
87 writableArray.pushMap(getMapFromJSONObject((JSONObject) objectInArray));
88 } else if (objectInArray instanceof Boolean) {
89 writableArray.pushBoolean((Boolean) objectInArray);
90 } else if(objectInArray instanceof Integer) {
91 writableArray.pushInt((Integer) objectInArray);
92 } else if(objectInArray instanceof Double) {
93 writableArray.pushDouble((Double) objectInArray);
94 } else if(objectInArray instanceof String) {
95 writableArray.pushString((String) objectInArray);
96 } else if(objectInArray instanceof Long) {
97 writableArray.pushDouble((Long) objectInArray);
98 } else {
99 Log.e(TAG, "Unknown type : " + objectInArray.getClass().getSimpleName());
100 }
101 } catch (JSONException e) {
102 e.printStackTrace();
103 }
104 }
105 return writableArray;
106 }
107
108 private static void objectToMap(Object object, WritableMap writableMap, String key) {
109 if (object instanceof Boolean) {
110 writableMap.putBoolean(key, (Boolean) object);
111 } else if(object instanceof Integer) {
112 writableMap.putInt(key, (Integer) object);
113 } else if(object instanceof Double) {
114 writableMap.putDouble(key, (Double) object);
115 } else if(object instanceof String) {
116 writableMap.putString(key, (String) object);
117 } else if(object instanceof Long) {
118 writableMap.putDouble(key, (Long) object);
119 } else {
120 Log.e(TAG, "Unknown type : " + object.getClass().getSimpleName());
121 }
122 }
123}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthBaseModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthBaseModule.java
new file mode 100755
index 0000000..3b41d55
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthBaseModule.java
@@ -0,0 +1,40 @@
1package com.ihealth.ihealthlibrary;
2
3import android.util.Log;
4
5import com.facebook.react.bridge.ReactApplicationContext;
6import com.facebook.react.bridge.ReactContextBaseJavaModule;
7import com.facebook.react.bridge.ReactMethod;
8import com.facebook.react.bridge.WritableMap;
9import com.facebook.react.module.annotations.ReactModule;
10import com.facebook.react.modules.core.DeviceEventManagerModule;
11
12/**
13 * Created by Jeepend on 21/11/2016.
14 * Base class for iHealth Modules, provide sendEvent method for you.
15 */
16@ReactModule(name = "iHealthBaseModule")
17public abstract class iHealthBaseModule extends ReactContextBaseJavaModule {
18
19 private final String TAG;
20 private DeviceEventManagerModule.RCTDeviceEventEmitter mEmitter = null;
21 public static final String ACTION_GET_ALL_CONNECTED_DEVICES = "action_get_all_connected_devices";
22
23 public iHealthBaseModule(String tag, ReactApplicationContext reactContext) {
24 super(reactContext);
25 TAG = tag;
26 }
27
28 void sendEvent(String eventName, WritableMap data) {
29 if (mEmitter == null) {
30 mEmitter = getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
31 }
32 if (mEmitter != null) {
33 mEmitter.emit(eventName, data);
34 } else {
35 Log.e(TAG, "mEmitter is null, can't send event.");
36 }
37 }
38
39 public abstract void handleNotify(String mac, String deviceType, String action, String message);
40}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerModule.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerModule.java
new file mode 100644
index 0000000..b752d27
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerModule.java
@@ -0,0 +1,734 @@
1package com.ihealth.ihealthlibrary;
2
3import android.content.BroadcastReceiver;
4import android.content.Context;
5import android.content.Intent;
6import android.content.IntentFilter;
7import android.text.TextUtils;
8import android.util.Log;
9
10import com.facebook.react.bridge.Arguments;
11import com.facebook.react.bridge.Callback;
12import com.facebook.react.bridge.LifecycleEventListener;
13import com.facebook.react.bridge.ReactApplicationContext;
14import com.facebook.react.bridge.ReactMethod;
15import com.facebook.react.bridge.WritableMap;
16import com.facebook.react.module.annotations.ReactModule;
17import com.ihealth.communication.control.Bg1Control;
18import com.ihealth.communication.control.Bg1Profile;
19import com.ihealth.communication.manager.DiscoveryTypeEnum;
20import com.ihealth.communication.manager.iHealthDevicesCallback;
21import com.ihealth.communication.manager.iHealthDevicesManager;
22
23import org.json.JSONArray;
24import org.json.JSONException;
25import org.json.JSONObject;
26
27import java.io.FileNotFoundException;
28import java.io.IOException;
29import java.io.InputStream;
30import java.util.HashMap;
31import java.util.Map;
32
33import javax.annotation.Nullable;
34
35/**
36 * Created by jing on 16/10/20.
37 */
38@ReactModule(name = "iHealthDeviceManagerModule")
39public class iHealthDeviceManagerModule extends iHealthBaseModule implements LifecycleEventListener {
40
41 private static final String modelName = "iHealthDeviceManagerModule";
42 private static final String TAG = "iHealthModel";
43
44 private final static String AM3S = "AM3S";
45 private final static String AM4 = "AM4";
46 private final static String AM5 = "AM5";
47 private final static String PO3 = "PO3";
48 private final static String BP5 = "BP5";
49 private final static String BP5S = "BP5S";
50 private final static String BP3L = "BP3L";
51 private final static String BP7 = "BP7";
52 private final static String BP7S = "BP7S";
53 private final static String KN550 = "KN550";
54 private final static String HS2 = "HS2";
55 private final static String HS2S = "HS2S";
56 private final static String HS4 = "HS4";
57 private final static String HS4S = "HS4S";
58 // private final static String HS6 = "HS6";
59 private final static String BG1 = "BG1";
60 private final static String BG1S = "BG1S";
61 private final static String BG5 = "BG5";
62 private final static String BG5S = "BG5S";
63 private final static String BG5L = "BG5L";
64 private final static String BTM = "BTM";
65 private final static String ECG3 = "ECG3";
66 private final static String ECG3USB = "ECG3USB";
67
68 private final static String PT3SBT = "PT3SBT";
69 private final static String TS28B = "TS28B";
70 private final static String NT13B = "NT13B";
71 private final static String PO1 = "PO1";
72
73
74 private final static String Event_Scan_Device = "event_scan_device";
75 private final static String Event_Scan_Finish = "event_scan_finish";
76 private final static String Event_Device_Connected = "event_device_connected";
77 private final static String Event_Device_Connect_Failed = "event_device_connect_failed";
78 private final static String Event_Device_Disconnect = "event_device_disconnect";
79 private final static String Event_Authenticate_Result = "event_authenticate_result";
80
81 private static int callbackId;
82 private ReactApplicationContext mContext;
83 private String userName;
84 private String mac = "";//macAddressForBg1
85 private static final String DESCRIPTION = "description";
86 private static final String IDPS = "idps";
87 private String idps = "";
88
89 public iHealthDeviceManagerModule(ReactApplicationContext reactContext) {
90 super(TAG, reactContext);
91 mContext = reactContext;
92 reactContext.addLifecycleEventListener(this);
93
94 // SDK init deferred to ensureInitialized() — called lazily on first startDiscovery
95 }
96
97 private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
98
99 @Override
100 public void onScanDevice(String mac, String deviceType, int rssi, Map manufactorData) {
101 WritableMap params = Arguments.createMap();
102 params.putString("mac", mac);
103 if (deviceType.equals("ECGUSB")) {
104 params.putString("type", "ECG3USB");
105
106 } else if (deviceType.equals("KN-550BT")) {
107 params.putString("type", "KN550");
108
109 } else {
110 params.putString("type", deviceType);
111 }
112 params.putInt("rssi", rssi);
113 sendEvent(Event_Scan_Device, params);
114 }
115
116 @Override
117 public void onDeviceConnectionStateChange(String mac, String deviceType, int status, int errorID, Map manufactorData) {
118 String eventName = null;
119 if (status == iHealthDevicesManager.DEVICE_STATE_CONNECTED) {
120 eventName = Event_Device_Connected;
121 } else if (status == iHealthDevicesManager.DEVICE_STATE_CONNECTIONFAIL) {
122 eventName = Event_Device_Connect_Failed;
123 } else if (status == iHealthDevicesManager.DEVICE_STATE_DISCONNECTED) {
124 eventName = Event_Device_Disconnect;
125 }
126 if (eventName != null) {
127 WritableMap params = Arguments.createMap();
128 params.putString("mac", mac);
129 if (deviceType.equals("ECGUSB")) {
130 params.putString("type", "ECG3USB");
131
132 } else if (deviceType.equals("KN-550BT")) {
133 params.putString("type", "KN550");
134
135 } else {
136 params.putString("type", deviceType);
137 }
138 params.putInt("errorid", errorID);
139 sendEvent(eventName, params);
140 }
141 }
142
143 @Override
144 public void onUserStatus(String username, int userStatus) {
145 WritableMap params = Arguments.createMap();
146 params.putInt("authen", userStatus);
147 sendEvent(Event_Authenticate_Result, params);
148 }
149
150 @Override
151 public void onDeviceNotify(String mac, String deviceType, String action, String message) {
152 commandHandleDeviceNotify(mac, deviceType, action, message);
153 }
154
155 @Override
156 public void onScanFinish() {
157 sendEvent(Event_Scan_Finish, null);
158 }
159
160 };
161
162 private void commandHandleDeviceNotify(String mac, String deviceType, String action, String message) {
163 //为了与iOS返回值保持一致,需要进行二次加工
164 iHealthBaseModule module = null;
165 switch (deviceType) {
166 case iHealthDevicesManager.TYPE_BP5:
167 module = getReactApplicationContext().getNativeModule(BP5Module.class);
168 break;
169
170 case iHealthDevicesManager.TYPE_BP5S:
171 module = getReactApplicationContext().getNativeModule(BP5SModule.class);
172 break;
173
174 case iHealthDevicesManager.TYPE_BP3L:
175 module = getReactApplicationContext().getNativeModule(BP3LModule.class);
176 break;
177
178 case iHealthDevicesManager.TYPE_550BT:
179 module = getReactApplicationContext().getNativeModule(BP550BTModule.class);
180 break;
181
182 case iHealthDevicesManager.TYPE_BP7:
183 module = getReactApplicationContext().getNativeModule(BP7Module.class);
184 break;
185
186 case iHealthDevicesManager.TYPE_BP7S:
187 module = getReactApplicationContext().getNativeModule(BP7SModule.class);
188 break;
189
190 case iHealthDevicesManager.TYPE_AM3S:
191 module = getReactApplicationContext().getNativeModule(AM3SModule.class);
192 break;
193
194 case iHealthDevicesManager.TYPE_AM4:
195 module = getReactApplicationContext().getNativeModule(AM4Module.class);
196 break;
197
198 case iHealthDevicesManager.TYPE_AM5:
199 module = getReactApplicationContext().getNativeModule(AM5Module.class);
200 break;
201
202 case iHealthDevicesManager.TYPE_PO3:
203 module = getReactApplicationContext().getNativeModule(PO3Module.class);
204 break;
205
206 case iHealthDevicesManager.TYPE_HS2:
207 module = getReactApplicationContext().getNativeModule(HS2Module.class);
208 break;
209
210 case iHealthDevicesManager.TYPE_HS2S:
211 case iHealthDevicesManager.TYPE_HS2S_PRO:
212 module = getReactApplicationContext().getNativeModule(HS2SModule.class);
213 break;
214
215 case iHealthDevicesManager.TYPE_HS4:
216 case iHealthDevicesManager.TYPE_HS4S:
217 module = getReactApplicationContext().getNativeModule(HS4SModule.class);
218 break;
219
220 case iHealthDevicesManager.TYPE_HS6:
221 break;
222
223 case iHealthDevicesManager.TYPE_BG1:
224 break;
225
226 case iHealthDevicesManager.TYPE_BG1S:
227 module = getReactApplicationContext().getNativeModule(BG1SModule.class);
228 break;
229
230 case iHealthDevicesManager.TYPE_BG5:
231 module = getReactApplicationContext().getNativeModule(BG5Module.class);
232 break;
233
234 case iHealthDevicesManager.TYPE_BG5S:
235 module = getReactApplicationContext().getNativeModule(BG5SModule.class);
236 break;
237
238 case iHealthDevicesManager.TYPE_FDIR_V3:
239 module = getReactApplicationContext().getNativeModule(BTMModule.class);
240 break;
241
242 case iHealthDevicesManager.TYPE_ECG3:
243 module = getReactApplicationContext().getNativeModule(ECGModule.class);
244 break;
245
246 case iHealthDevicesManager.TYPE_ECG3_USB:
247 module = getReactApplicationContext().getNativeModule(ECGUSBModule.class);
248 break;
249
250 case iHealthDevicesManager.TYPE_PT3SBT:
251 module = getReactApplicationContext().getNativeModule(PT3SBTModule.class);
252 break;
253
254 case iHealthDevicesManager.TYPE_TS28B:
255 module = getReactApplicationContext().getNativeModule(TS28BModule.class);
256 break;
257
258 case iHealthDevicesManager.TYPE_NT13B:
259 module = getReactApplicationContext().getNativeModule(NT13BModule.class);
260 break;
261
262 case iHealthDevicesManager.TYPE_PO1:
263 module = getReactApplicationContext().getNativeModule(PO1Module.class);
264 break;
265
266 default:
267 module = null;
268 break;
269 }
270 if (module != null) {
271 module.handleNotify(mac, deviceType, action, message);
272 } else {
273 Log.e(TAG, "We do not support this type: " + deviceType);
274 }
275 }
276
277 @Nullable
278 @Override
279 public Map<String, Object> getConstants() {
280 final Map<String, Object> constants = new HashMap<>();
281 constants.put(AM3S, iHealthDevicesManager.DISCOVERY_AM3S);
282 constants.put(AM4, iHealthDevicesManager.DISCOVERY_AM4);
283 constants.put(AM5, iHealthDevicesManager.DISCOVERY_AM5);
284 constants.put(PO3, iHealthDevicesManager.DISCOVERY_PO3);
285 constants.put(BP5, iHealthDevicesManager.DISCOVERY_BP5);
286 constants.put(BP5S, iHealthDevicesManager.DISCOVERY_BP5S);
287 constants.put(BP3L, iHealthDevicesManager.DISCOVERY_BP3L);
288 constants.put(BP7, iHealthDevicesManager.DISCOVERY_BP7);
289 constants.put(BP7S, iHealthDevicesManager.DISCOVERY_BP7S);
290 constants.put(KN550, iHealthDevicesManager.DISCOVERY_BP550BT);
291 constants.put(HS2, iHealthDevicesManager.DISCOVERY_HS2);
292 constants.put(HS2S, iHealthDevicesManager.DISCOVERY_HS2S);
293 constants.put(HS4, iHealthDevicesManager.DISCOVERY_HS4);
294 constants.put(HS4S, iHealthDevicesManager.DISCOVERY_HS4S);
295 constants.put(BG1, (double) 110);
296 constants.put(BG1S, iHealthDevicesManager.DISCOVERY_BG1S);
297 constants.put(BG5, iHealthDevicesManager.DISCOVERY_BG5);
298 constants.put(BG5S, iHealthDevicesManager.DISCOVERY_BG5S);
299 constants.put(BTM, iHealthDevicesManager.DISCOVERY_FDIR_V3);
300 constants.put(ECG3, iHealthDevicesManager.DISCOVERY_ECG3);
301 constants.put(ECG3USB, iHealthDevicesManager.DISCOVERY_ECG3_USB);
302 constants.put(PT3SBT, iHealthDevicesManager.DISCOVERY_PT3SBT);
303 constants.put(TS28B, iHealthDevicesManager.DISCOVERY_TS28B);
304 constants.put(NT13B, iHealthDevicesManager.DISCOVERY_NT13B);
305 constants.put(PO1, iHealthDevicesManager.DISCOVERY_PO1);
306 constants.put(PO3, iHealthDevicesManager.DISCOVERY_PO3);
307
308 constants.put("Event_Scan_Device", Event_Scan_Device);
309 constants.put("Event_Scan_Finish", Event_Scan_Finish);
310 constants.put("Event_Device_Connected", Event_Device_Connected);
311 constants.put("Event_Device_Connect_Failed", Event_Device_Connect_Failed);
312 constants.put("Event_Device_Disconnect", Event_Device_Disconnect);
313 constants.put("Event_Authenticate_Result", Event_Authenticate_Result);
314
315 return constants;
316 }
317
318 @Override
319 public String getName() {
320 return modelName;
321 }
322
323
324 @Override
325 public void onHostResume() {
326 if (callbackId == 0) {
327 android.app.Activity activity = getCurrentActivity();
328 android.app.Application app = activity != null ? activity.getApplication() : (android.app.Application) mContext.getApplicationContext();
329 iHealthDevicesManager.getInstance().init(app, Log.VERBOSE, Log.VERBOSE);
330 Bg1Control.getInstance().init(mContext, "", 0, true);
331 callbackId = iHealthDevicesManager.getInstance().registerClientCallback(miHealthDevicesCallback);
332 }
333 }
334
335 @Override
336 public void onHostPause() {
337 Log.i(TAG, "onHostPause");
338 }
339
340 @Override
341 public void onHostDestroy() {
342 Log.e(TAG, "onHostDestroy");
343
344 if (mBroadcastReceiverRegistered) {
345 unRegisterReceiver();
346 }
347 callbackId = 0;
348 iHealthDevicesManager.getInstance().unRegisterClientCallback(callbackId);
349 iHealthDevicesManager.getInstance().destroy();
350 }
351
352 private DiscoveryTypeEnum getDiscoveryType(String type) {
353
354 switch (type) {
355 case "AM3S":
356 return DiscoveryTypeEnum.AM3S;
357
358 case "AM4":
359 return DiscoveryTypeEnum.AM4;
360
361 case "AM5":
362 return DiscoveryTypeEnum.AM5;
363
364 case "BG1S":
365 return DiscoveryTypeEnum.BG1S;
366
367 case "BG5":
368 return DiscoveryTypeEnum.BG5;
369
370 case "BG5S":
371 return DiscoveryTypeEnum.BG5S;
372
373 case "BP3L":
374 return DiscoveryTypeEnum.BP3L;
375
376 case "BP5":
377 return DiscoveryTypeEnum.BP5;
378
379 case "BP5S":
380 return DiscoveryTypeEnum.BP5S;
381
382 case "BP7":
383 return DiscoveryTypeEnum.BP7;
384
385 case "KN550":
386 return DiscoveryTypeEnum.BP550BT;
387
388 case "HS2":
389 return DiscoveryTypeEnum.HS2;
390
391 case "HS2S":
392 return DiscoveryTypeEnum.HS2S;
393
394 case "HS4":
395 return DiscoveryTypeEnum.HS4;
396
397 case "HS4S":
398 return DiscoveryTypeEnum.HS4S;
399
400 case "PO1":
401 return DiscoveryTypeEnum.PO1;
402
403 case "PO3":
404 return DiscoveryTypeEnum.PO3;
405
406 case "PT3SBT":
407 return DiscoveryTypeEnum.PT3SBT;
408
409 case "NT13B":
410 return DiscoveryTypeEnum.NT13B;
411
412 case "TS28B":
413 return DiscoveryTypeEnum.TS28B;
414
415 default:
416 return DiscoveryTypeEnum.All;
417
418 }
419 }
420
421 private void ensureInitialized() {
422 if (callbackId == 0) {
423 android.app.Activity activity = getCurrentActivity();
424 if (activity != null) {
425 iHealthDevicesManager.getInstance().init(activity.getApplication(), Log.VERBOSE, Log.VERBOSE);
426 } else {
427 iHealthDevicesManager.getInstance().init((android.app.Application) mContext.getApplicationContext(), Log.VERBOSE, Log.VERBOSE);
428 }
429 Bg1Control.getInstance().init(mContext, "", 0, true);
430 callbackId = iHealthDevicesManager.getInstance().registerClientCallback(miHealthDevicesCallback);
431 android.util.Log.e("iHealthScanner", "=== SDK initialized from ensureInitialized, callbackId=" + callbackId + " ===");
432 }
433 }
434
435 @ReactMethod
436 public void startDiscovery(String type) {
437 ensureInitialized();
438 if (type.equals("BG1")) {
439 registerReceiver();//scan BG1
440 } else {
441 iHealthDevicesManager.getInstance().startDiscovery(getDiscoveryType(type));
442 }
443 }
444
445 @ReactMethod
446 public void stopDiscovery() {
447 iHealthDevicesManager.getInstance().stopDiscovery();
448 }
449
450 @ReactMethod
451 public void connectDevice(String mac, String type) {
452 if (type.equals(BG1)) {
453 Bg1Control.getInstance().connect();
454 } else if (type.equals(iHealthDevicesManager.TYPE_FDIR_V3)) {
455 connectTherm(this.userName, mac, type, 1, 1, 2, 0, 1, 0);
456 } else {
457 if (type.equals("KN550")) {
458 iHealthDevicesManager.getInstance().connectDevice(this.userName, mac, iHealthDevicesManager.TYPE_550BT);
459 } else {
460 iHealthDevicesManager.getInstance().connectDevice(this.userName, mac, type);
461 }
462
463 }
464 }
465
466 @ReactMethod
467 public void connectTherm(String userName, String mac, String type, int unit, int measureTarget,
468 int functionTarget, int hour, int minute, int second) {
469 iHealthDevicesManager.getInstance().connectTherm(userName, mac, type,
470 unit, measureTarget, functionTarget, hour, minute, second);
471 }
472
473 @ReactMethod
474 public void authenConfigureInfo(String userName, String clientID, String clientSecret) {
475 this.userName = userName;
476 iHealthDevicesManager.getInstance().sdkUserInAuthor(mContext, userName, clientID, clientSecret, callbackId);
477 }
478
479 @ReactMethod
480 public void authenAppSecret(String appSecret, Callback callback) {
481 boolean authenResult = iHealthDevicesManager.getInstance().sdkAuthWithAppSecret(mContext, appSecret);
482 callback.invoke(authenResult);
483 }
484
485 @ReactMethod
486 public void getDevicesIDPS(String mac, Callback callback) {
487 String idpsInfo = iHealthDevicesManager.getInstance().getDevicesIDPS(mac);
488 WritableMap writableMap = Arguments.createMap();
489 Utils.jsonToMap(idpsInfo, writableMap);
490 callback.invoke(writableMap);
491 }
492
493 @Override
494 public void handleNotify(String mac, String deviceType, String action, String message) {
495 //Do nothing
496 }
497
498
499 private void registerReceiver() {
500 IntentFilter intentFilter = new IntentFilter();
501 intentFilter.addAction(Intent.ACTION_HEADSET_PLUG);
502 intentFilter.addAction(Bg1Profile.ACTION_BG1_CONNECT_RESULT);
503 intentFilter.addAction(Bg1Profile.ACTION_BG1_SENDCODE_RESULT);
504 intentFilter.addAction(Bg1Profile.ACTION_BG1_MEASURE_ERROR);
505 intentFilter.addAction(Bg1Profile.ACTION_BG1_MEASURE_STANDBY);
506 intentFilter.addAction(Bg1Profile.ACTION_BG1_MEASURE_RESULT);
507 intentFilter.addAction(Bg1Profile.ACTION_BG1_MEASURE_STRIP_IN);
508 intentFilter.addAction(Bg1Profile.ACTION_BG1_MEASURE_GET_BLOOD);
509 intentFilter.addAction(Bg1Profile.ACTION_BG1_MEASURE_STRIP_OUT);
510 intentFilter.addAction(Bg1Profile.ACTION_BG1_IDPS);
511 mContext.registerReceiver(broadcastReceiver, intentFilter);
512 mBroadcastReceiverRegistered = true;
513 }
514
515 synchronized private void unRegisterReceiver() {
516 mContext.unregisterReceiver(broadcastReceiver);
517 mBroadcastReceiverRegistered = false;
518 }
519
520 private boolean mBroadcastReceiverRegistered = false;
521 private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
522 @Override
523 public void onReceive(Context context, Intent intent) {
524 if (!TextUtils.isEmpty(intent.getAction())) {
525 iHealthBaseModule module = getReactApplicationContext().getNativeModule(BG1Module.class);
526 WritableMap params = Arguments.createMap();
527 params.putString("action", intent.getAction());
528 params.putString("mac", mac);
529 params.putString("type", BG1);
530 try {
531 JSONObject jsonObject = new JSONObject();
532 switch (intent.getAction()) {
533 case Intent.ACTION_HEADSET_PLUG:
534 Log.e(TAG, "headset state -----> " + intent.getExtras().getInt("state"));
535 Log.e(TAG, "has microphone ----> " + intent.getExtras().getInt("microphone"));
536 Log.e(TAG, "headset name ------> " + intent.getExtras().getString("name"));
537
538 jsonObject.put("state", intent.getExtras().getInt("state"));
539 Utils.jsonToMap(jsonObject.toString(), params);
540
541 if (intent.getExtras().getInt("state") == 1) {
542 if (intent.getExtras().getInt("microphone") == 1) {//1 if headset has a microphone, 0 otherwise
543 sendEvent(Event_Scan_Device, params);
544 } else {
545 Log.e(TAG, "headSet has no microphone");
546 }
547
548 } else {
549 sendEvent(Event_Device_Disconnect, params);
550 Bg1Control.getInstance().disconnect();
551 module.handleNotify(mac, BG1, Event_Device_Disconnect, jsonObject.toString());
552
553 }
554 sendEvent(Event_Scan_Finish, null);
555
556 break;
557 case Bg1Profile.ACTION_BG1_CONNECT_RESULT:
558 int connectFlag = intent.getIntExtra(Bg1Profile.BG1_CONNECT_RESULT, -1);
559 jsonObject.put(Bg1Profile.BG1_CONNECT_RESULT, connectFlag);
560 jsonObject.put(DESCRIPTION, getErrorDescription(Bg1Profile.ACTION_BG1_CONNECT_RESULT, connectFlag));
561 if (formatIdps(idps) != null) {
562 jsonObject.put(IDPS, formatIdps(idps));
563 }
564 Utils.jsonToMap(jsonObject.toString(), params);
565 if (connectFlag == 0) {
566 sendEvent(Event_Device_Connected, params);
567 } else {
568 sendEvent(Event_Device_Connect_Failed, params);
569 }
570 break;
571 case Bg1Profile.ACTION_BG1_SENDCODE_RESULT:
572 int sendCodeFlag = intent.getIntExtra(Bg1Profile.BG1_SENDCODE_RESULT, -1);
573 jsonObject.put(Bg1Profile.BG1_SENDCODE_RESULT, sendCodeFlag);
574 jsonObject.put(DESCRIPTION, getErrorDescription(Bg1Profile.ACTION_BG1_SENDCODE_RESULT, sendCodeFlag));
575 //Utils.jsonToMap(jsonObject.toString(), params);
576
577 module.handleNotify(mac, BG1, Bg1Profile.ACTION_BG1_SENDCODE_RESULT, jsonObject.toString());
578 break;
579 case Bg1Profile.ACTION_BG1_MEASURE_ERROR:
580 int errorNumber = intent.getIntExtra(Bg1Profile.BG1_MEASURE_ERROR, -1);
581 jsonObject.put(Bg1Profile.BG1_MEASURE_ERROR, errorNumber);
582 jsonObject.put(DESCRIPTION, getErrorDescription(Bg1Profile.ACTION_BG1_MEASURE_ERROR, errorNumber));
583 module.handleNotify(mac, BG1, Bg1Profile.ACTION_BG1_MEASURE_ERROR, jsonObject.toString());
584 break;
585
586 case Bg1Profile.ACTION_BG1_MEASURE_RESULT:
587 int measureResult = intent.getIntExtra(Bg1Profile.BG1_MEASURE_RESULT, -1);
588 jsonObject.put(Bg1Profile.BG1_MEASURE_RESULT, measureResult);
589 module.handleNotify(mac, BG1, Bg1Profile.ACTION_BG1_MEASURE_RESULT, jsonObject.toString());
590 break;
591 case Bg1Profile.ACTION_BG1_IDPS:
592 idps = intent.getStringExtra(Bg1Profile.BG1_IDPS);
593 mac = getMacFromIdps(idps);
594 // module.handleNotify(mac, BG1, Bg1Profile.ACTION_BG1_IDPS, intent.getStringExtra(Bg1Profile.BG1_IDPS));
595 break;
596 default:
597 module.handleNotify(mac, BG1, intent.getAction(), jsonObject.toString());
598 break;
599
600 }
601 } catch (JSONException e) {
602 e.printStackTrace();
603 }
604 }
605 }
606
607 String getMacFromIdps(String idps) {
608 //{"IDPS":[{"DeviceId":"9D300A5682","FirmWare":"13.5.0","HardWare":"13.6.0"}]}
609 try {
610 JSONObject sourceObject = new JSONObject(idps);
611 JSONArray array = sourceObject.getJSONArray("IDPS");
612 JSONObject object = (JSONObject) array.get(0);
613 return object.getString("DeviceId");
614 } catch (Exception e) {
615
616 }
617 return "";
618 }
619
620 JSONObject formatIdps(String idps) {
621 try {
622 JSONObject sourceObject = new JSONObject(idps);
623 JSONArray array = sourceObject.getJSONArray("IDPS");
624 return (JSONObject) array.get(0);
625 } catch (Exception e) {
626
627 }
628 return null;
629 }
630
631
632 String getErrorDescription(String action, int err_num) {
633 switch (action) {
634 case Bg1Profile.ACTION_BG1_CONNECT_RESULT:
635 case Bg1Profile.ACTION_BG1_SENDCODE_RESULT:
636 if ((err_num >= 6 && err_num <= 13) || (err_num >= 19 && err_num <= 28)) {
637 return "Send code failed.";
638 }
639 switch (err_num) {
640 case 0:
641 return "Success.";
642 case 1:
643 return "Hand shake timeout.";
644 case 2:
645 case 16://1307
646 return "Get idps failed.";
647 case 3:
648 return "Register clientId failed.";
649 case 5:
650 case 17://1307
651 return "Identify failed.";
652 case 32:
653 return "Connect timeout";
654 case 18:
655 return "Set bottleId failed.";
656 default:
657 return "Unknown.";
658 }
659
660 case Bg1Profile.ACTION_BG1_MEASURE_ERROR:
661 switch (err_num) {
662 case 0:
663 return "Battery is low.";
664 case 1:
665 return "Glucose test result is out of the measurement range.";
666 case 2:
667 return "Unknown interference detected, please repeat the test.";
668 case 3:
669 return "Strip is used or unknown moisture detected, discard the test strip and repeat the test with a new strip.";
670 case 4:
671 return "Communication error,resend the code to repeat the test.";
672 case 5:
673 case 6:
674 return "The environmental temperature is beyond normal range, place the meter at room temperature for at least 30 minutes, then repeat the test.";
675 case 7:
676 return "Authentication failed more than 10 times.";
677 case 8:
678 return "Communication error, please repeat the test.";
679 case 9:
680 case 10:
681 case 11:
682 return "Communication error, please repeat the test. If the problem persists, contact iHealth customer service for assistance.";
683 case 12:
684 return "Glucose test result is low.";
685 case 13:
686 return "Glucose test result is high.";
687 case 400:
688 return "Parameters out of range.";
689 case 401:
690 return "Dolby is on, please turn it off.";
691 default:
692 return "Unknown.";
693 }
694 default:
695 return "Unknown.";
696 }
697 }
698 };
699
700 @ReactMethod
701 public void disconnectDevice(String mac, String type) {
702 if (type.equals(BG1)) {
703 Bg1Control.getInstance().disconnect();
704 } else {
705 iHealthDevicesManager.getInstance().disconnectDevice(mac, type);
706 }
707 }
708
709 @ReactMethod
710 public void sdkAuthWithLicense(String license) {
711 boolean result = false;
712 try {
713 InputStream ins = mContext.getAssets().open(license);
714 byte[] licenseBuffer = new byte[ins.available()];
715 ins.read(licenseBuffer);
716 ins.close();
717 result = iHealthDevicesManager.getInstance().sdkAuthWithLicense(licenseBuffer);
718 } catch (FileNotFoundException e) {
719 e.printStackTrace();
720 } catch (IOException e) {
721 e.printStackTrace();
722 }
723 WritableMap writableMap = Arguments.createMap();
724 writableMap.putBoolean("access", result);
725 sendEvent(Event_Authenticate_Result, writableMap);
726 }
727
728 @ReactMethod
729 public void isSupportOTG(Callback callback) {
730 boolean isSupportOTG = iHealthDevicesManager.getInstance().checkSupportOTG();
731 callback.invoke(isSupportOTG);
732 }
733
734}
diff --git a/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerPackage.java b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerPackage.java
new file mode 100644
index 0000000..79bfcb6
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/java/com/ihealth/ihealthlibrary/iHealthDeviceManagerPackage.java
@@ -0,0 +1,70 @@
1package com.ihealth.ihealthlibrary;
2
3import com.facebook.react.ReactPackage;
4import com.facebook.react.bridge.NativeModule;
5import com.facebook.react.bridge.ReactApplicationContext;
6import com.facebook.react.uimanager.ViewManager;
7
8import java.util.ArrayList;
9import java.util.Collections;
10import java.util.List;
11
12/**
13 * Created by jing on 16/10/20.
14 */
15
16public class iHealthDeviceManagerPackage implements ReactPackage {
17 @Override
18 public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
19 List<NativeModule> modules = new ArrayList<>();
20 modules.add(new iHealthDeviceManagerModule(reactContext));
21 modules.add(new AM3SModule(reactContext));
22 modules.add(new AM4Module(reactContext));
23 modules.add(new AMProfileModule(reactContext));
24 modules.add(new AM5Module(reactContext));
25 modules.add(new AM5ProfileModule(reactContext));
26 modules.add(new BP5Module(reactContext));
27 modules.add(new BP5SModule(reactContext));
28 modules.add(new BP3LModule(reactContext));
29 modules.add(new BP550BTModule(reactContext));
30 modules.add(new BP7Module(reactContext));
31 modules.add(new BP7SModule(reactContext));
32 modules.add(new BPProfileModule(reactContext));
33 modules.add(new POProfileModule(reactContext));
34 modules.add(new PO3Module(reactContext));
35 modules.add(new HS2Module(reactContext));
36 modules.add(new HS2SModule(reactContext));
37 modules.add(new HS4SModule(reactContext));
38 modules.add(new HSProfileModule(reactContext));
39 modules.add(new HS2SProfileModule(reactContext));
40 modules.add(new BG1Module(reactContext));
41 modules.add(new BG1SModule(reactContext));
42 modules.add(new BG1ProfileModule(reactContext));
43 modules.add(new BG1SProfileModule(reactContext));
44 modules.add(new BG5Module(reactContext));
45 modules.add(new BG5SModule(reactContext));
46 modules.add(new BG5SProfileModule(reactContext));
47 modules.add(new BGProfileModule(reactContext));
48 modules.add(new HS6Module(reactContext));
49 modules.add(new HS6ProfileModule(reactContext));
50 modules.add(new BTMModule(reactContext));
51 modules.add(new BTMProfileModule(reactContext));
52 modules.add(new ECGModule(reactContext));
53 modules.add(new ECGProfileModule(reactContext));
54 modules.add(new ECGUSBModule(reactContext));
55 modules.add(new TS28BModule(reactContext));
56 modules.add(new TS28BProfileModule(reactContext));
57 modules.add(new NT13BModule(reactContext));
58 modules.add(new NT13BProfileModule(reactContext));
59 modules.add(new PO1Module(reactContext));
60 modules.add(new PO1ProfileModule(reactContext));
61 modules.add(new PT3SBTModule(reactContext));
62 modules.add(new PT3SBTProfileModule(reactContext));
63 return modules;
64 }
65
66 @Override
67 public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
68 return Collections.emptyList();
69 }
70}
diff --git a/libs/ihealth-sdk/android/src/main/res/values/strings.xml b/libs/ihealth-sdk/android/src/main/res/values/strings.xml
new file mode 100755
index 0000000..827d429
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
1<resources>
2 <string name="app_name">iHealthLibrary</string>
3</resources>
diff --git a/libs/ihealth-sdk/android/src/test/java/com/example/jing/ihealthlibrary/ExampleUnitTest.java b/libs/ihealth-sdk/android/src/test/java/com/example/jing/ihealthlibrary/ExampleUnitTest.java
new file mode 100755
index 0000000..84a3f08
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/test/java/com/example/jing/ihealthlibrary/ExampleUnitTest.java
@@ -0,0 +1,17 @@
1package com.example.jing.ihealthlibrary;
2
3import org.junit.Test;
4
5import static org.junit.Assert.*;
6
7/**
8 * Example local unit test, which will execute on the development machine (host).
9 *
10 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11 */
12public class ExampleUnitTest {
13 @Test
14 public void addition_isCorrect() throws Exception {
15 assertEquals(4, 2 + 2);
16 }
17} \ No newline at end of file
diff --git a/libs/ihealth-sdk/android/src/test/java/com/ihealth/ihealthlibrary/ExampleUnitTest.java b/libs/ihealth-sdk/android/src/test/java/com/ihealth/ihealthlibrary/ExampleUnitTest.java
new file mode 100755
index 0000000..ee64f09
--- /dev/null
+++ b/libs/ihealth-sdk/android/src/test/java/com/ihealth/ihealthlibrary/ExampleUnitTest.java
@@ -0,0 +1,17 @@
1package com.ihealth.ihealthlibrary;
2
3import org.junit.Test;
4
5import static org.junit.Assert.*;
6
7/**
8 * Example local unit test, which will execute on the development machine (host).
9 *
10 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11 */
12public class ExampleUnitTest {
13 @Test
14 public void addition_isCorrect() throws Exception {
15 assertEquals(4, 2 + 2);
16 }
17} \ No newline at end of file