diff --git a/android/app/build.gradle b/android/app/build.gradle
index f911635e..66a7f0cd 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -135,6 +135,7 @@ dependencies {
// Native Dependency
implementation "org.jetbrains.anko:anko-commons:0.10.4"
implementation 'com.github.kittinunf.fuel:fuel:2.3.0' //for JVM
+ implementation project(':blesdk_2301')
implementation 'com.github.kittinunf.fuel:fuel-android:2.3.0'
implementation 'com.google.android.gms:play-services-location:17.1.0'//for Android
implementation 'com.google.android.gms:play-services-basement:17.5.0'
diff --git a/android/blesdk_2301/build.gradle b/android/blesdk_2301/build.gradle
new file mode 100644
index 00000000..1177acf0
--- /dev/null
+++ b/android/blesdk_2301/build.gradle
@@ -0,0 +1,52 @@
+apply plugin: 'com.android.library'
+
+
+android {
+ compileSdkVersion 33
+
+ lintOptions{
+ abortOnError false
+ }
+
+ defaultConfig {
+
+ minSdkVersion 18
+ targetSdkVersion 33
+ versionCode 3
+ versionName "3.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ consumerProguardFiles 'proguard-rules.pro'
+ }
+ debug {
+ minifyEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ consumerProguardFiles 'proguard-rules.pro'
+ }
+ }
+ task makejar(type: Jar) {
+ from file('build/intermediates/javac/debug/classes')
+ archiveName = '2301sdk' + defaultConfig.versionName + '.jar'
+ destinationDir = file('build/libs')
+ include "com/jstyle/blesdk2301/**"
+
+
+ }
+ makejar.dependsOn(build)
+
+}
+
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
+
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
diff --git a/android/blesdk_2301/java_pid10828.hprof b/android/blesdk_2301/java_pid10828.hprof
new file mode 100644
index 00000000..506d22d2
Binary files /dev/null and b/android/blesdk_2301/java_pid10828.hprof differ
diff --git a/android/blesdk_2301/src/androidTest/java/com/jstyle/blesdk2301/ExampleInstrumentedTest.java b/android/blesdk_2301/src/androidTest/java/com/jstyle/blesdk2301/ExampleInstrumentedTest.java
new file mode 100644
index 00000000..84547b8a
--- /dev/null
+++ b/android/blesdk_2301/src/androidTest/java/com/jstyle/blesdk2301/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.jstyle.blesdk2301;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.jstyle.blesdk.test", appContext.getPackageName());
+ }
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/Util/BleSDK.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/Util/BleSDK.java
new file mode 100644
index 00000000..3ab7053e
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/Util/BleSDK.java
@@ -0,0 +1,1006 @@
+package com.jstyle.blesdk2301.Util;
+
+import android.text.TextUtils;
+
+import com.jstyle.blesdk2301.callback.DataListener2301;
+import com.jstyle.blesdk2301.constant.BleConst;
+import com.jstyle.blesdk2301.constant.DeviceConst;
+
+import com.jstyle.blesdk2301.constant.DeviceKey;
+import com.jstyle.blesdk2301.model.AutoMode;
+import com.jstyle.blesdk2301.model.AutoTestMode;
+import com.jstyle.blesdk2301.model.MyAutomaticHRMonitoring;
+import com.jstyle.blesdk2301.model.MyPersonalInfo;
+import com.jstyle.blesdk2301.model.MyDeviceTime;
+import com.jstyle.blesdk2301.other.ResolveUtil;
+
+import java.io.UnsupportedEncodingException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Created by Administrator on 2018/4/9.
+ */
+
+public class BleSDK {
+ public static final int DATA_READ_START = 0;
+ public static final int DATA_READ_CONTINUE = 2;
+ public static final int DATA_DELETE = 99;
+ public static final byte DistanceMode_MILE = (byte) 0x81;
+ public static final byte DistanceMode_KM = (byte) 0x80;
+ public static final byte TimeMode_12h = (byte) 0x81;
+ public static final byte TimeMode_24h = (byte) 0x80;
+ public static final byte WristOn_Enable = (byte) 0x81;
+ public static final byte WristOn_DisEnable = (byte) 0x80;
+ public static final byte TempUnit_C = (byte) 0x80;
+ public static final byte TempUnit_F = (byte) 0x81;
+
+ public static final String TAG = "BleSDK";
+ public static boolean isruning = false;
+
+ private static byte[] getByteArray(float f) {
+ int intbits = Float.floatToIntBits(f);//将float里面的二进制串解释为int整数
+ return getByteArrays(intbits);
+ }
+
+ public static byte[] getByteArrays(int i) {
+ byte[] b = new byte[4];
+ b[3] = (byte) ((i & 0xff000000) >> 24);
+ b[2] = (byte) ((i & 0x00ff0000) >> 16);
+ b[1] = (byte) ((i & 0x0000ff00) >> 8);
+ b[0] = (byte) (i & 0x000000ff);
+ return b;
+ }
+
+
+ public static void DataParsingWithData(byte[] value, final DataListener2301 dataListener) {
+ Map map = new HashMap<>();
+ switch (value[0]) {
+
+ case DeviceConst.CMD_Set_UseInfo:
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.SetPersonalInfo));
+ break;
+ case DeviceConst.CMD_Set_Auto:
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.SetAutomatic));
+ break;
+ case DeviceConst.CMD_Set_DeviceID:
+ dataListener.dataCallback(ResolveUtil.setMacSuccessful());
+ break;
+ case DeviceConst.CMD_SET_TIME:
+ dataListener.dataCallback(ResolveUtil.setTimeSuccessful(value));
+ break;
+
+ case DeviceConst.CMD_GET_TIME:
+ dataListener.dataCallback(ResolveUtil.getDeviceTime(value));
+ break;
+ case DeviceConst.CMD_GET_USERINFO:
+ dataListener.dataCallback(ResolveUtil.getUserInfo(value));
+ break;
+ case DeviceConst.CMD_Enable_Activity:
+ dataListener.dataCallback(ResolveUtil.getActivityData(value));
+ break;
+ case DeviceConst.CMD_Get_BatteryLevel:
+ dataListener.dataCallback(ResolveUtil.getDeviceBattery(value));
+ break;
+ case DeviceConst.CMD_Get_Address:
+ dataListener.dataCallback(ResolveUtil.getDeviceAddress(value));
+ break;
+ case DeviceConst.CMD_Get_Version:
+ dataListener.dataCallback(ResolveUtil.getDeviceVersion(value));
+ break;
+ case DeviceConst.CMD_Get_Auto:
+ dataListener.dataCallback(ResolveUtil.getAutoHeart(value));
+ break;
+ case DeviceConst.CMD_Reset:
+ dataListener.dataCallback(ResolveUtil.Reset());
+ break;
+ case DeviceConst.CMD_Mcu_Reset:
+ dataListener.dataCallback(ResolveUtil.MCUReset());
+ break;
+ case DeviceConst.CMD_Get_TotalData:
+ if (GetTotalActivityDataWithMode) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.Delete_GetTotalActivityData));
+ } else {
+ dataListener.dataCallback(ResolveUtil.getTotalStepData(value));
+ }
+ break;
+ case DeviceConst.CMD_Get_DetailData:
+ if (GetDetailActivityDataWithMode) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.deleteGetDetailActivityDataWithMode));
+ } else {
+ dataListener.dataCallback(ResolveUtil.getDetailData(value));
+ }
+ break;
+ case DeviceConst.CMD_Get_SleepData:
+ if (Delete_GetDetailSleepData) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.Delete_GetDetailSleepData));
+ } else {
+ dataListener.dataCallback(ResolveUtil.getSleepData(value));
+ }
+ break;
+ case DeviceConst.CMD_Get_HeartData:
+ if (GetDynamicHRWithMode) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.Delete_GetDynamicHR));
+ } else {
+ dataListener.dataCallback(ResolveUtil.getHeartData(value));
+ }
+
+ break;
+ case DeviceConst.CMD_Get_OnceHeartData:
+ if (GetStaticHRWithMode) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.Delete_GetStaticHR));
+ } else {
+ dataListener.dataCallback(ResolveUtil.getOnceHeartData(value));
+ }
+
+ break;
+ case DeviceConst.CMD_Get_HrvTestData:
+ if (readhrv) {
+ dataListener.dataCallback(ResolveUtil.getHrvTestData(value));
+ } else {
+ dataListener.dataCallback(ResolveUtil.DeleteHrv());
+ }
+ break;
+ case DeviceConst.ReadTempHisrory:
+ if (GetTemperature_historyDataWithMode) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.deleteGetTemperature_historyDataWithMode));
+ } else {
+ dataListener.dataCallback(ResolveUtil.getTempData(value));
+ }
+ break;
+ case DeviceConst.Oxygen_data:
+ if (Obtain_The_data_of_manual_blood_oxygen_test) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.Delete_Obtain_The_data_of_manual_blood_oxygen_test));
+ } else {
+ dataListener.dataCallback(ResolveUtil.GetAutomaticSpo2Monitoring(value));
+ }
+ break;
+ case DeviceConst.CMD_HeartPackageFromDevice:
+ dataListener.dataCallback(ResolveUtil.getActivityExerciseData(value));
+ break;
+ case DeviceConst.CMD_Set_Name:
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.CMD_Set_Name));
+ break;
+ case DeviceConst.CMD_Get_Name:
+ dataListener.dataCallback(ResolveUtil.getDeviceName(value));
+ break;
+ case DeviceConst.CMD_Get_SPORTData:
+ if (GetActivityModeDataWithMode) {
+ dataListener.dataCallback(ResolveUtil.setMethodSuccessful(BleConst.Delete_ActivityModeData));
+ } else {
+ dataListener.dataCallback(ResolveUtil.getExerciseData(value));
+ }
+ break;
+ case DeviceConst.MeasurementWithType:
+ if (StartDeviceMeasurementWithType) {
+ Map vv = new HashMap<>();
+ switch (value[1]) {
+ case 1://hrv
+ vv.put(DeviceKey.DataType, BleConst.MeasurementHrvCallback);
+ vv.put(DeviceKey.End, true);
+ Map lm = new HashMap<>();
+ lm.put(DeviceKey.Type, ResolveUtil.getValue(value[1], 0) + "");
+ lm.put(DeviceKey.HeartRate, ResolveUtil.getValue(value[2], 0) + "");
+ lm.put(DeviceKey.Blood_oxygen, ResolveUtil.getValue(value[3], 0) + "");
+ lm.put(DeviceKey.HRV, ResolveUtil.getValue(value[4], 0) + "");
+ lm.put(DeviceKey.Stress, ResolveUtil.getValue(value[5], 0) + "");
+ lm.put(DeviceKey.HighPressure, ResolveUtil.getValue(value[6], 0) + "");
+ lm.put(DeviceKey.LowPressure, ResolveUtil.getValue(value[7], 0) + "");
+ vv.put(DeviceKey.Data, lm);
+ dataListener.dataCallback(vv);
+ break;
+ case 2://heart
+ vv.put(DeviceKey.DataType, BleConst.MeasurementHeartCallback);
+ vv.put(DeviceKey.End, true);
+ Map lmB = new HashMap<>();
+ lmB.put(DeviceKey.Type, ResolveUtil.getValue(value[1], 0) + "");
+ lmB.put(DeviceKey.HeartRate, ResolveUtil.getValue(value[2], 0) + "");
+ lmB.put(DeviceKey.Blood_oxygen, ResolveUtil.getValue(value[3], 0) + "");
+ lmB.put(DeviceKey.HRV, ResolveUtil.getValue(value[4], 0) + "");
+ lmB.put(DeviceKey.Stress, ResolveUtil.getValue(value[5], 0) + "");
+ lmB.put(DeviceKey.HighPressure, ResolveUtil.getValue(value[6], 0) + "");
+ lmB.put(DeviceKey.LowPressure, ResolveUtil.getValue(value[7], 0) + "");
+ vv.put(DeviceKey.Data, lmB);
+ dataListener.dataCallback(vv);
+ break;
+ case 3://0xy
+ vv.put(DeviceKey.DataType, BleConst.MeasurementOxygenCallback);
+ vv.put(DeviceKey.End, true);
+ Map lmC = new HashMap<>();
+ lmC.put(DeviceKey.Type, ResolveUtil.getValue(value[1], 0) + "");
+ lmC.put(DeviceKey.HeartRate, ResolveUtil.getValue(value[2], 0) + "");
+ lmC.put(DeviceKey.Blood_oxygen, ResolveUtil.getValue(value[3], 0) + "");
+ lmC.put(DeviceKey.HRV, ResolveUtil.getValue(value[4], 0) + "");
+ lmC.put(DeviceKey.Stress, ResolveUtil.getValue(value[5], 0) + "");
+ lmC.put(DeviceKey.HighPressure, ResolveUtil.getValue(value[6], 0) + "");
+ lmC.put(DeviceKey.LowPressure, ResolveUtil.getValue(value[7], 0) + "");
+ vv.put(DeviceKey.Data, lmC);
+ dataListener.dataCallback(vv);
+ break;
+ }
+ } else {
+ Map vv = new HashMap<>();
+ switch (value[1]) {
+ case 1://hrv
+ vv.put(DeviceKey.DataType, BleConst.StopMeasurementHrvCallback);
+ vv.put(DeviceKey.End, true);
+ vv.put(DeviceKey.Data, new HashMap<>());
+ dataListener.dataCallback(vv);
+ break;
+ case 2://heart
+ vv.put(DeviceKey.DataType, BleConst.StopMeasurementHeartCallback);
+ vv.put(DeviceKey.End, true);
+ vv.put(DeviceKey.Data, new HashMap<>());
+ dataListener.dataCallback(vv);
+ break;
+ case 3://0xy
+ vv.put(DeviceKey.DataType, BleConst.StopMeasurementOxygenCallback);
+ vv.put(DeviceKey.End, true);
+ vv.put(DeviceKey.Data, new HashMap<>());
+ dataListener.dataCallback(vv);
+ break;
+ }
+ }
+ break;
+ case DeviceConst.CMD_Get_Bloodsugar:
+ if (startBloodsugar) {//只有开始测量才返回状态
+ Map vv = new HashMap<>();
+ vv.put(DeviceKey.DataType, BleConst.Blood_glucose_status);
+ vv.put(DeviceKey.End, true);
+ Map lm = new HashMap<>();
+ lm.put(DeviceKey.Type, ResolveUtil.getValue(value[1], 0) + "");
+ vv.put(DeviceKey.Data, lm);
+ dataListener.dataCallback(vv);
+ }
+ break;
+ case DeviceConst.Bloodsugar_data:
+ Map vv = new HashMap<>();
+ vv.put(DeviceKey.DataType, BleConst.Blood_glucose_data);
+ vv.put(DeviceKey.End, false);
+ Map lm = new HashMap<>();
+ lm.put(DeviceKey.Time, getFormatTimeString(System.currentTimeMillis(), "yyyy.MM.dd HH:mm:ss"));
+ List simplePpg = new ArrayList<>();
+ if (value.length == 153) {//新血糖解析
+ byte[] valueer = new byte[value.length - 3];
+ System.arraycopy(value, 3, valueer, 0, valueer.length);
+ for (int i = 0; i < valueer.length / 3; i++) {
+ int valuedata = ResolveUtil.getValue(valueer[3 * i], 2)
+ + ResolveUtil.getValue(valueer[3 * i + 1], 1)
+ + ResolveUtil.getValue(valueer[3 * i + 2], 0);
+ simplePpg.add(valuedata);
+ }
+ lm.put(DeviceKey.PPG, Arrays.toString(simplePpg.toArray()));
+ }
+ vv.put(DeviceKey.Data, lm);
+ dataListener.dataCallback(vv);
+ break;
+
+ case DeviceConst.CMD_Start_EXERCISE:
+ if(FindActivityMode){
+ Map mapEXERCISE = new HashMap<>();
+ mapEXERCISE.put(DeviceKey.DataType, BleConst.FindActivityMode);
+ mapEXERCISE.put(DeviceKey.End, true);
+ Map mapsx = new HashMap<>();
+ mapsx.put(DeviceKey.Type, ResolveUtil.getValue(value[1], 0) + "");
+ mapsx.put(DeviceKey.Status, ResolveUtil.getValue(value[2], 0) + "");
+ mapEXERCISE.put(DeviceKey.Data, mapsx);
+ dataListener.dataCallback(mapEXERCISE);
+ }else{
+ Map mapEXERCISE = new HashMap<>();
+ mapEXERCISE.put(DeviceKey.DataType, BleConst.EnterActivityMode);
+ mapEXERCISE.put(DeviceKey.End, true);
+ Map mapsx = new HashMap<>();
+ mapsx.put(DeviceKey.enterActivityModeSuccess, ResolveUtil.getValue(value[1], 0) + "");
+ mapEXERCISE.put(DeviceKey.Data, mapsx);
+ dataListener.dataCallback(mapEXERCISE);
+ }
+ break;
+
+
+ }
+ // return map;
+ }
+
+ protected static boolean Delete_GetDetailSleepData = false;
+
+ public static byte[] GetDetailSleepDataWithMode(byte mode, String dateOfLastData) {
+ Delete_GetDetailSleepData = ((byte) 0x99 == mode);
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_SleepData;
+ value[1] = mode;
+ insertDateValue(value, dateOfLastData);
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 开始实时计步
+ *
+ * @return
+ */
+ public static byte[] RealTimeStep(boolean enable, boolean tempEnable) {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Enable_Activity;
+ value[1] = (byte) (enable ? 1 : 0);
+ value[2] = (byte) (tempEnable ? 1 : 0);
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 设置个人信息
+ *
+ * @param
+ * @return
+ */
+ public static byte[] SetPersonalInfo(MyPersonalInfo info) {
+ byte[] value = new byte[16];
+ int male = info.getSex();
+ int age = info.getAge();
+ int height = info.getHeight();
+ int weight = info.getWeight();
+ int stepLength = info.getStepLength();
+ value[0] = DeviceConst.CMD_Set_UseInfo;
+ value[1] = (byte) male;
+ value[2] = (byte) age;
+ value[3] = (byte) height;
+ value[4] = (byte) weight;
+ value[5] = (byte) stepLength;
+ crcValue(value);
+
+ return value;
+ }
+
+
+ /**
+ * 获取个人信息
+ *
+ * @return
+ */
+ public static byte[] GetPersonalInfo() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_GET_USERINFO;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 设置设备时间
+ *
+ * @param
+ * @return
+ */
+ public static byte[] SetDeviceTime(MyDeviceTime time) {
+ byte[] value = new byte[16];
+ String timeZone = ResolveUtil.getCurrentTimeZone();
+ String zone = timeZone.substring(3);
+ byte zoneValue = 0;
+ if (zone.contains("-")) {
+ zone = zone.replace("-", "");
+ zoneValue = Byte.valueOf(String.valueOf(zone));
+ } else {
+ zoneValue = (byte) (Byte.valueOf(zone) + 0x80);
+ }
+ int year = time.getYear();
+ int month = time.getMonth();
+ int day = time.getDay();
+ int hour = time.getHour();
+ int min = time.getMinute();
+ int second = time.getSecond();
+ value[0] = DeviceConst.CMD_SET_TIME;
+ value[1] = ResolveUtil.getTimeValue(year);
+ value[2] = ResolveUtil.getTimeValue(month);
+ value[3] = ResolveUtil.getTimeValue(day);
+ value[4] = ResolveUtil.getTimeValue(hour);
+ value[5] = ResolveUtil.getTimeValue(min);
+ value[6] = ResolveUtil.getTimeValue(second);
+ value[8] = zoneValue;
+ crcValue(value);
+
+ return value;
+ }
+
+
+ /**
+ * 获取设备时间
+ *
+ * @return
+ */
+ public static byte[] GetDeviceTime() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_GET_TIME;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 99: 删除步数详细数据 ,
+ * 0:读最近的步数详细数据。
+ * 1:读指定位置的步数详细数据。
+ * 2:继续上次读的位置下一段数据
+ *
+ * @param
+ * @return * dateOfLastData "yyyy-MM-dd HH:mm:ss or yyyy.MM.dd HH:mm:ss"
+ */
+ private static boolean GetDetailActivityDataWithMode = false;
+
+ public static byte[] GetDetailActivityDataWithMode(byte mode, String dateOfLastData) {
+ GetDetailActivityDataWithMode = ((byte) 0x99 == mode);
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_DetailData;
+ value[1] = (byte) mode;
+ insertDateValue(value, dateOfLastData);
+ crcValue(value);
+ return value;
+ }
+
+ /**
+ * 99: 删除温度数据 ,
+ * 0:读最近的温度详细数据。
+ * 1:读指定位置的步数详细数据。
+ * 2:继续上次读的位置下一段数据
+ *
+ * @param
+ * @return
+ */
+ protected static boolean GetTemperature_historyDataWithMode;
+
+ public static byte[] GetTemperature_historyData(byte mode, String dateOfLastData) {
+ GetTemperature_historyDataWithMode = ((byte) 0x99 == mode);
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.ReadTempHisrory;
+ value[1] = mode;
+ insertDateValue(value, dateOfLastData);
+ crcValue(value);
+ return value;
+ }
+
+ public static boolean StartDeviceMeasurementWithType = false;
+
+ public static byte[] SetDeviceMeasurementWithType(AutoTestMode dataType, long second, boolean open) {
+ StartDeviceMeasurementWithType = open;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.MeasurementWithType;
+ switch (dataType) {
+ case AutoHeartRate:
+ value[1] = (byte) 0x02;
+ break;
+ case AutoSpo2:
+ value[1] = (byte) 0x03;
+ break;
+
+ }
+ value[2] = open ? (byte) 0x01 : (byte) 0x00;
+ value[3] = (byte) ((second) & 0xff);
+ value[4] = (byte) ((second >> 8) & 0xff);
+ crcValue(value);
+ return value;
+ }
+
+ public static byte[] SetAutomaticHRMonitoring(MyAutomaticHRMonitoring autoHeart, AutoMode type) {
+ byte[] value = new byte[16];
+ int time = autoHeart.getTime();
+ value[0] = DeviceConst.CMD_Set_Auto;
+ value[1] = (byte) autoHeart.getOpen();
+ value[2] = ResolveUtil.getTimeValue(autoHeart.getStartHour());
+ value[3] = ResolveUtil.getTimeValue(autoHeart.getStartMinute());
+ value[4] = ResolveUtil.getTimeValue(autoHeart.getEndHour());
+ value[5] = ResolveUtil.getTimeValue(autoHeart.getEndMinute());
+ value[6] = (byte) autoHeart.getWeek();
+ value[7] = (byte) (time & 0xff);
+ value[8] = (byte) ((time >> 8) & 0xff);
+ if (null == type) {
+ value[9] = (byte) 0x01;
+ } else {
+ switch (type) {
+ case AutoHeartRate:
+ value[9] = (byte) 0x01;
+ break;
+ case AutoSpo2:
+ value[9] = (byte) 0x02;
+ break;
+ case AutoTemp:
+ value[9] = (byte) 0x03;
+ break;
+ case AutoHrv:
+ value[9] = (byte) 0x04;
+ break;
+ }
+ }
+ crcValue(value);
+ return value;
+ }
+
+
+ public static byte[] GetAutomatic(AutoMode type) {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Auto;
+ if (null == type) {
+ value[1] = (byte) 0x01;
+ } else {
+ switch (type) {
+ case AutoHeartRate:
+ value[1] = (byte) 0x01;
+ break;
+ case AutoSpo2:
+ value[1] = (byte) 0x02;
+ break;
+ case AutoTemp:
+ value[1] = (byte) 0x03;
+ break;
+ case AutoHrv:
+ value[1] = (byte) 0x04;
+ break;
+ }
+ }
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 获取某天总数据
+ * 0
+ *
+ * @param mode 0:表⽰是从最新的位置开始读取(最多50组数据) 2:表⽰接着读取(当数据总数⼤于50的时候) 0x99:表⽰删除所有运
+ * 动数据
+ * @return
+ */
+ protected static boolean GetTotalActivityDataWithMode;
+
+ public static byte[] GetTotalActivityDataWithMode(byte mode, String dateOfLastData) {
+ GetTotalActivityDataWithMode = (byte) 0x99 == mode;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_TotalData;
+ value[1] = mode;
+ insertDateValueNoH(value, dateOfLastData);
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 获取设备版本号
+ *
+ * @return
+ */
+ public static byte[] GetDeviceVersion() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Version;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 恢复出厂设置
+ *
+ * @return
+ */
+ public static byte[] Reset() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Reset;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 获取设备mac地址
+ *
+ * @return
+ */
+ public static byte[] GetDeviceMacAddress() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Address;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 获取设备电量
+ *
+ * @return
+ */
+ public static byte[] GetDeviceBatteryLevel() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_BatteryLevel;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 重启设备
+ *
+ * @return
+ */
+ public static byte[] MCUReset() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Mcu_Reset;
+ crcValue(value);
+ return value;
+ }
+
+
+ private static boolean readhrv = false;
+
+ public static byte[] GetHRVDataWithMode(byte mode, String dateOfLastData) {
+ readhrv = (byte) 0x99 != mode;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_HrvTestData;
+ value[1] = mode;
+ insertDateValue(value, dateOfLastData);
+ crcValue(value);
+ return value;
+ }
+
+
+ protected static boolean GetStaticHRWithMode;
+
+ public static byte[] GetStaticHRWithMode(byte mode, String dateOfLastData) {
+ GetStaticHRWithMode = ((byte) 0x99 == mode);
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_OnceHeartData;
+ value[1] = mode;
+ insertDateValue(value, dateOfLastData);
+ crcValue(value);
+ return value;
+ }
+
+
+ protected static boolean GetDynamicHRWithMode;
+
+ public static byte[] GetDynamicHRWithMode(byte Number, String dateOfLastData) {
+ GetDynamicHRWithMode = (byte) 0x99 == Number;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_HeartData;
+ value[1] = (byte) Number;
+ insertDateValue(value, dateOfLastData);
+ crcValue(value);
+ return value;
+ }
+
+
+ public static byte[] SetDeviceID(String deviceId) {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Set_DeviceID;
+ for (int i = 0; i < 6; i++) {
+ value[i + 1] = (byte) deviceId.charAt(i);
+ }
+ crcValue(value);
+ return value;
+ }
+
+
+ public static byte[] intTobyte(int num) {
+ return new byte[]{(byte) ((num >> 8) & 0xff), (byte) (num & 0xff)};
+ }
+
+ public static int byteArrayToInt(byte[] arr) {
+ short targets = (short) ((arr[1] & 0xff) | ((arr[0] << 8) & 0xff00));
+
+ return targets;
+ }
+
+
+ public static byte[] getInfoValue(String info, int maxLength) {
+ byte[] nameBytes = null;
+ try {
+ nameBytes = info.getBytes("UTF-8");
+ if (nameBytes.length >= maxLength) {//两条命令总共32个字节,内容只占24个字节(32-2*(1cmd+1消息类型+1长度+1校验))
+ byte[] real = new byte[maxLength];
+ char[] chars = info.toCharArray();
+ int length = 0;
+ for (int i = 0; i < chars.length; i++) {
+ String s = String.valueOf(chars[i]);
+ byte[] nameB = s.getBytes("UTF-8");
+ ;
+ if (length + nameB.length == maxLength) {
+ System.arraycopy(nameBytes, 0, real, 0, real.length);
+ return real;
+ } else if (length + nameB.length > maxLength) {//大于24会导致有个字节发不到下位机导致乱码
+ System.arraycopy(nameBytes, 0, real, 0, length);
+ return real;
+ }
+ length += nameB.length;
+ }
+ }
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return nameBytes;
+ }
+
+ public static void crcValue(byte[] value) {
+ byte crc = 0;
+ for (int i = 0; i < value.length - 1; i++) {
+ crc += value[i];
+ }
+ value[value.length - 1] = (byte) (crc & 0xff);
+ }
+
+
+ public static void insertDateValue(byte[] value, String time) {
+ if (!TextUtils.isEmpty(time) && time.length() > 8) {
+ String[] timeArray = time.split(" ");
+ String INDEX;
+ if (time.contains("-")) {
+ INDEX = "-";
+ } else {
+ INDEX = "\\.";
+ }
+ int year = Integer.parseInt(timeArray[0].split(INDEX)[0]);
+ int month = Integer.parseInt(timeArray[0].split(INDEX)[1]);
+ int day = Integer.parseInt(timeArray[0].split(INDEX)[2]);
+ int hour = Integer.parseInt(timeArray[1].split(":")[0]);
+ int min = Integer.parseInt(timeArray[1].split(":")[1]);
+ int second = Integer.parseInt(timeArray[1].split(":")[2]);
+ value[4] = ResolveUtil.getTimeValue(year);
+ value[5] = ResolveUtil.getTimeValue(month);
+ value[6] = ResolveUtil.getTimeValue(day);
+ value[7] = ResolveUtil.getTimeValue(hour);
+ value[8] = ResolveUtil.getTimeValue(min);
+ value[9] = ResolveUtil.getTimeValue(second);
+ }
+
+ }
+
+
+ public static void insertDateValueNoH(byte[] value, String time) {
+ if (!TextUtils.isEmpty(time) && time.contains("-")) {
+ String[] timeArray = time.split(" ");
+ String INDEX;
+ if (time.contains("-")) {
+ INDEX = "-";
+ } else {
+ INDEX = "\\.";
+ }
+ int year = Integer.parseInt(timeArray[0].split(INDEX)[0]);
+ int month = Integer.parseInt(timeArray[0].split(INDEX)[1]);
+ int day = Integer.parseInt(timeArray[0].split(INDEX)[2]);
+ value[4] = ResolveUtil.getTimeValue(year);
+ value[5] = ResolveUtil.getTimeValue(month);
+ value[6] = ResolveUtil.getTimeValue(day);
+ }
+
+
+ }
+
+
+ /**
+ * 转十六进制字符串
+ *
+ * @param data
+ * @return
+ */
+ public static String byte2Hex(byte[] data) {
+ if (data != null && data.length > 0) {
+ StringBuilder sb = new StringBuilder(data.length);
+ for (byte tmp : data) {
+ sb.append(String.format("%02X ", tmp));
+ }
+ return sb.toString();
+ }
+ return "no data";
+ }
+
+
+ /**
+ * OObtain automated test oximetry data
+ * 获得自动测试血氧数据
+ */
+ protected static boolean Obtain_The_data_of_manual_blood_oxygen_test;
+
+ public static byte[] Oxygen_data(byte Number) {
+ Obtain_The_data_of_manual_blood_oxygen_test = ((byte) 0x99 == Number);
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.Oxygen_data;
+ value[1] = (byte) Number;
+ crcValue(value);
+ return value;
+ }
+
+ public static byte[] EnterActivityMode(int time, int activityMode, int WorkMode) {
+ FindActivityMode=false;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Start_EXERCISE;
+ value[1] = (byte) WorkMode;
+ value[2] = (byte) activityMode;
+ value[4] = (byte) time;
+ crcValue(value);
+ return value;
+ }
+
+ private static boolean FindActivityMode=false;
+ public static byte[] FindActivityMode() {
+ FindActivityMode=true;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Start_EXERCISE;
+ value[1] = (byte) 0x05;
+ crcValue(value);
+ return value;
+ }
+
+ /**
+ * @param status 级别 0,1,2
+ * @param time 分钟
+ * @param WorkMode START=1;PAUSE=2;CONTUINE=3;FINISH=4;
+ * @return
+ */
+ public static byte[] setExerciseModeByBreath(int status, int time, int WorkMode) {
+ FindActivityMode=false;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Start_EXERCISE;
+ value[1] = (byte) WorkMode;
+ value[2] = (byte) 0x06;
+ value[3] = (byte) status;
+ value[4] = (byte) time;
+ crcValue(value);
+ return value;
+ }
+
+ public static byte[] sendHeartPackage(float distance, int space, int rssi) {
+ byte[] value = new byte[16];
+ byte[] distanceValue = getByteArray(distance);
+ int min = space / 60;
+ int second = space % 60;
+ value[0] = DeviceConst.CMD_heart_package;
+ System.arraycopy(distanceValue, 0, value, 1, distanceValue.length);
+ value[5] = (byte) min;
+ value[6] = (byte) second;
+ value[7] = (byte) rssi;
+ crcValue(value);
+ return value;
+ }
+
+ /**
+ * 设置设备名字
+ *
+ * @param
+ * @return
+ */
+ public static byte[] SetDeviceName(String strDeviceName) {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Set_Name;
+ int length = strDeviceName.length() > 14 ? 14 : strDeviceName.length();
+ for (int i = 0; i < length; i++) {
+ value[i + 1] = (byte) strDeviceName.charAt(i);
+ }
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 获取设备名字
+ *
+ * @return
+ */
+ public static byte[] GetDeviceName() {
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Name;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 获取多模式运动数据
+ *
+ * @param mode 0:表⽰是从最新的位置开始读取(最多50组数据) 2:表⽰接着读取(当数据总数⼤于50的时候) 0x99:表⽰删除所有
+ * GPS数据
+ * @return
+ */
+ protected static boolean GetActivityModeDataWithMode;
+
+ public static byte[] GetActivityModeDataWithMode(byte mode) {
+ GetActivityModeDataWithMode = ((byte) 0x99 == mode);
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_SPORTData;
+ value[1] = mode;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 开始血氧测量
+ * Start blood oxygen measurement
+ */
+ public static boolean startBloodsugar = false;
+
+ public static byte[] startBloodsugar() {
+ startBloodsugar = true;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Bloodsugar;
+ value[1] = (byte) 0x01;
+ crcValue(value);
+ return value;
+ }
+
+ /**
+ * 停止血氧测量
+ * Stop blood oxygen measurement
+ */
+ public static byte[] BloodsugarStop() {
+ startBloodsugar = false;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Bloodsugar;
+ value[1] = (byte) 0x05;
+ crcValue(value);
+ return value;
+ }
+
+ /**
+ * 血氧测量停止信号采集
+ * Blood oxygen measurement stop signal acquisition
+ */
+ public static byte[] BloodsugarStopSiss() {
+ startBloodsugar = false;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Bloodsugar;
+ value[1] = (byte) 0x03;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 血氧测量进度更新
+ * Blood oxygen measurement progress update
+ */
+ public static byte[] BloodsugarProgress(int Progress) {
+ startBloodsugar = false;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Bloodsugar;
+ value[1] = (byte) 0x04;
+ value[2] = (byte) Progress;//0-100
+ crcValue(value);
+ return value;
+ }
+
+ /**
+ * 血氧测量结果
+ * Send blood glucose results to the device
+ * status 1低 2中 3高 0测试失败
+ * Status 1 low 2 3 high 0 test failed
+ */
+ public static byte[] SendBloodGlucoseResultsToTheDevice(int status) {
+ startBloodsugar = false;
+ byte[] value = new byte[16];
+ value[0] = DeviceConst.CMD_Get_Bloodsugar;
+ value[1] = (byte) 0x02;
+ value[2] = (byte) status;
+ crcValue(value);
+ return value;
+ }
+
+
+ /**
+ * 获取指定格式的日期字符串
+ */
+ public static synchronized String getFormatTimeString(long time, String formatString) {
+ SimpleDateFormat format = new SimpleDateFormat(formatString);
+ String data = "";
+ try {
+ data = format.format(new Date(time));
+ } catch (Exception E) {
+ E.printStackTrace();
+ }
+ return data;
+ }
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/Util/PDFCreate.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/Util/PDFCreate.java
new file mode 100644
index 00000000..72307c52
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/Util/PDFCreate.java
@@ -0,0 +1,244 @@
+package com.jstyle.blesdk2301.Util;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.Rect;
+import android.graphics.pdf.PdfDocument;
+import android.text.TextUtils;
+
+import com.jstyle.blesdk2301.model.UserInfo;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+public class PDFCreate {
+ private static final String TAG = "PDFCreate";
+ final static int maxXSize = 5120;
+ static float length = 20;
+ static float totalWidth = 1070;
+ static int startX = 35;
+ static float endX = startX + 1000;
+ static float startY ;
+ private static float endY;
+ private static float height ;
+ private static float width ;
+ private static int strokeWidthTime;
+ private static int strokeWidthLine;
+ private static float totalHeight;
+
+ public static void createPdf(String path, Context context, List data, UserInfo userInfo) {
+ int size = data.size();
+ float col = size % maxXSize == 0 ? size / maxXSize : size / maxXSize + 1;//一次画5120个点,分多少次画
+ length=dip2px(context,10);
+ height=length;
+ width=length;
+ startX=dip2px(context,20);
+ endX=startX+50*length;
+ totalWidth=endX+startX;
+ totalHeight = col * height * 5 + dip2px(context,130);//一次需要5个高度
+ PdfDocument pdfDocument = new PdfDocument();
+
+ PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder((int) totalWidth, (int) totalHeight, 1)
+ // .setContentRect(new Rect(0,0,(int)totalWidth,(int)totalHeight))
+ .create();
+
+ PdfDocument.Page page = pdfDocument.startPage(pageInfo);
+ Canvas canvas = page.getCanvas();
+ Paint paint = new Paint();
+ strokeWidthTime = dip2px(context, 1.5f);
+ strokeWidthLine = dip2px(context, 0.5f);
+ drawReportInfo(context, canvas, paint,userInfo);
+ Path pathCanvas = new Path();
+ endY = startY + col * height * 5;
+ paint.setTextSize(dip2px(context, 15));
+ drawAxes(pathCanvas, canvas, paint, col);
+ drawTimeLine(pathCanvas, canvas, paint);
+ drawDataLine(context,pathCanvas, canvas, paint, col, data);
+ pdfDocument.finishPage(page);
+ File file = new File(path);
+ FileOutputStream outputStream = null;
+ try {
+ outputStream = new FileOutputStream(file);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ try {
+ pdfDocument.writeTo(outputStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**用户信息
+ * @param context
+ * @param canvas
+ * @param paint
+ * @param
+ */
+ private static void drawReportInfo(Context context, Canvas canvas, Paint paint,UserInfo userInfo) {
+ paint.setTextSize(dip2px(context,15));
+ paint.setColor(Color.BLACK);
+ paint.setStyle(Paint.Style.FILL);
+ if(null!=userInfo){
+ if(!TextUtils.isEmpty(userInfo.getEcgTitle())){
+ String title=userInfo.getEcgTitle();
+ Rect rect = new Rect();
+ paint.getTextBounds(title, 0, title.length(), rect);
+ int heightTitle = rect.height();
+ float startTextY=heightTitle+dip2px(context,8);
+ float marginTop=dip2px(context,4);
+ float marginRight=dip2px(context,8);
+ //标题
+ canvas.drawText(title, totalWidth / 2 - 150, startTextY, paint);
+ //提醒
+ paint.setTextSize(dip2px(context, 12));
+ int widthTips = rect.width();
+ int heightTips = rect.height();
+ if(!TextUtils.isEmpty(userInfo.getEcgReportTips())) {
+
+ String tips = userInfo.getEcgReportTips();
+ float tipsTextY = startTextY + heightTitle + marginTop;
+ paint.getTextBounds(tips, 0, tips.length(), rect);
+ canvas.drawText(tips, totalWidth - widthTips - marginRight, tipsTextY, paint);
+ }
+
+ float tipsTextY=startTextY+heightTitle+marginTop;
+
+
+ String name = userInfo.getName();
+ String genderString = userInfo.getGender();
+ String age = userInfo.getAge();
+
+
+ String userWeight = userInfo.getWeight();
+ String userHeight = userInfo.getHeight();
+ //个人信息
+ float infoTextY=tipsTextY+heightTips+marginTop;
+ @SuppressLint("StringFormatMatches")
+ String info=name+" "+genderString+" "+age+" "+ userHeight+" "+userWeight;
+ paint.getTextBounds(info, 0, info.length(), rect);
+ int heightInfo = rect.height();
+ int widthInfo = rect.width();
+ canvas.drawText(info, totalWidth / 2 - (widthInfo >> 1), infoTextY, paint);
+ //时间
+ float dateTextY=infoTextY+heightInfo+marginTop;
+ String dateString=userInfo.getDate();
+ paint.getTextBounds(dateString, 0, dateString.length(), rect);
+ int widthDate=rect.width();
+ int heightDate=rect.height();
+ canvas.drawText(dateString, totalWidth - widthDate-marginRight, dateTextY, paint);
+ startY=dateTextY+heightDate+marginTop;
+ }
+
+
+
+
+ }
+
+ }
+
+ /**
+ * 画网格
+ *
+ * @param pathCanvas
+ * @param canvas
+ * @param paint
+ * @param col
+ */
+ private static void drawAxes(Path pathCanvas, Canvas canvas, Paint paint, float col) {
+ //画网格竖线
+ int colorLine = Color.rgb(243, 119, 99);
+ paint.setColor(colorLine);
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeWidth(strokeWidthLine);
+ paint.setAlpha(200);
+ for (int i = 0; i <51; i++) {
+ pathCanvas.moveTo(i * width + startX, startY);
+ pathCanvas.lineTo(i * width + startX, endY);
+ }
+ //画网格横线
+ for (int i = 0; i <= col * 5; i++) {
+ pathCanvas.moveTo(startX - (strokeWidthTime >> 1), i * height + startY);
+ pathCanvas.lineTo(endX + (strokeWidthTime >> 1), i * height + startY);
+ }
+ canvas.drawPath(pathCanvas, paint);
+ pathCanvas.reset();
+ }
+
+ /**
+ * 加粗时间线
+ *
+ * @param pathCanvas
+ * @param canvas
+ * @param paint
+ */
+ private static void drawTimeLine(Path pathCanvas, Canvas canvas, Paint paint) {
+ paint.setColor(Color.BLACK);
+ paint.setStrokeWidth(strokeWidthTime);
+ paint.setStyle(Paint.Style.FILL);
+ Rect rect=new Rect();
+ for (int i = 0; i < 11; i++) {
+ pathCanvas.moveTo(i * 5 * width + startX, startY);
+ pathCanvas.lineTo(i * 5 * width + startX, endY + 20);
+ String time=i+"s";
+ paint.getTextBounds(time, 0, time.length(), rect);
+ int widthTime=rect.width();
+ canvas.drawText(time, i * 5 * width + startX - (widthTime >> 1), endY + 50, paint);
+ }
+ int colorS = Color.rgb(255, 119, 99);
+ paint.setColor(colorS);
+ paint.setAlpha(255);
+ paint.setStyle(Paint.Style.STROKE);
+ canvas.drawPath(pathCanvas, paint);
+ pathCanvas.reset();
+ }
+
+ /**
+ * 画数据
+ *
+ * @param pathCanvas
+ * @param canvas
+ * @param paint
+ * @param col
+ * @param data
+ */
+ private static void drawDataLine(Context context,Path pathCanvas, Canvas canvas, Paint paint, float col, List data) {
+ int size = data.size();
+ paint.setStrokeWidth(strokeWidthLine);
+ paint.setColor(Color.BLACK);
+ out:
+ for (int i = 0; i < col; i++) {
+ int startPoint = i * maxXSize;
+ in: for (int j = 0; j = size) break out;
+ Integer y = data.get(startPoint + j);
+ if (j == 0) pathCanvas.moveTo(startX, i * height * 5 + getCanvasY(y,context));
+ pathCanvas.lineTo(startX + x * (endX - startX) / maxXSize, i * height * 5 + getCanvasY(y,context));
+ }
+ }
+
+ canvas.drawPath(pathCanvas, paint);
+ }
+
+ private static float getCanvasY(double value,Context context) {
+ double height = 5 * 10 / 16000f;
+ return dip2px (context,(float) (height * (8000 - value))) + startY;
+ }
+
+ /**
+ * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
+ */
+ public static int dip2px(Context context, float dpValue) {
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (dpValue * scale + 0.5f);
+ }
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/BleConnectionListener.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/BleConnectionListener.java
new file mode 100644
index 00000000..ee6db91d
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/BleConnectionListener.java
@@ -0,0 +1,10 @@
+package com.jstyle.blesdk2301.callback;
+
+public interface BleConnectionListener {
+ void BleStatus(int status,int newState);//蓝牙4.0连接状态 Bluetooth 4.0 connection status
+ void ConnectionSucceeded();//连接设备成功 Successfully connected the device
+ void Connecting();//设备连接中 Device is connected
+ void ConnectionFailed();//设备连接失败 Device connection failed
+ void OnReconnect();//重新连接中 Reconnecting
+ void BluetoothSwitchIsTurnedOff();//蓝牙开关被关闭 Bluetooth switch is turned off
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/DataListener2301.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/DataListener2301.java
new file mode 100644
index 00000000..bb8a8920
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/DataListener2301.java
@@ -0,0 +1,13 @@
+package com.jstyle.blesdk2301.callback;
+
+import java.util.Map;
+
+/**
+ * Created by Administrator on 2018/4/10.
+ */
+
+public interface DataListener2301 {
+ void dataCallback(Map maps);
+ void dataCallback(byte[] value);
+
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/OnScanResults.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/OnScanResults.java
new file mode 100644
index 00000000..98a00c64
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/callback/OnScanResults.java
@@ -0,0 +1,9 @@
+package com.jstyle.blesdk2301.callback;
+
+
+import com.jstyle.blesdk2301.model.Device;
+
+public interface OnScanResults {
+ void Success(Device date);
+ void Fail(int code);
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/cmdenum/YhDeviceData.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/cmdenum/YhDeviceData.java
new file mode 100644
index 00000000..47e53161
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/cmdenum/YhDeviceData.java
@@ -0,0 +1,42 @@
+package com.jstyle.blesdk2301.cmdenum;
+
+import java.io.Serializable;
+
+public class YhDeviceData implements Serializable {
+ int dataType;// is index
+ String data="";//data object
+ boolean dataEnd=false; //Is it over?
+
+ public boolean isDataEnd() {
+ return dataEnd;
+ }
+
+ public void setDataEnd(boolean dataEnd) {
+ this.dataEnd = dataEnd;
+ }
+
+ public int getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(int dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getData() {
+ return data==null?"":data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ return "YhDeviceData{" +
+ "dataType=" + dataType +
+ ", data=" + data +
+ ", dataEnd=" + dataEnd +
+ '}';
+ }
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/BleConst.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/BleConst.java
new file mode 100644
index 00000000..567e0fa5
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/BleConst.java
@@ -0,0 +1,135 @@
+package com.jstyle.blesdk2301.constant;
+
+/**
+ * Created by Administrator on 2020/4/9.
+ */
+
+public class BleConst {
+ public static final String GetDeviceTime="0";
+ public static final String SetDeviceTime="1";
+ public static final String GetPersonalInfo="2";
+ public static final String SetPersonalInfo="3";
+ public static final String GetDeviceInfo="4";
+ public static final String SetDeviceInfo="5";//设置手环基本参数
+ public static final String CMD_Set_Mac="6";
+ public static final String GetStepGoal="7";
+ public static final String SetStepGoal="8";
+ public static final String GetDeviceBatteryLevel="9";
+ public static final String GetDeviceMacAddress="10";
+ public static final String GetDeviceVersion="11";
+ public static final String CMD_Reset="12";
+ public static final String CMD_MCUReset="13";
+ public static final String SetMotorVibrationWithTimes ="14";
+ public static final String GetDeviceName="15";
+ public static final String GetAutomatic="16";
+ public static final String SetAutomatic="17";
+ public static final String GetAlarmClock="18";
+ public static final String SetAlarmClockWithAllClock="19";
+ public static final String Notify="20";
+ public static final String GetSedentaryReminder="21";
+ public static final String SetSedentaryReminder="22";
+ public static final String RealTimeStep="23";
+ public static final String GetTotalActivityData="24";
+ public static final String GetDetailActivityData="25";
+ public static final String GetDetailSleepData="26";
+ public static final String GetDynamicHR="27";
+ public static final String GetStaticHR="28";
+ public static final String GetActivityModeData="29";
+ public static final String EnterActivityMode="30";
+ public static final String DeviceSendDataToAPP="31";
+ public static final String BackHomeView="35";
+ public static final String GetTempHistoryData="36";
+ public static final String ECGDATA="37";
+ public static final String EcgppGstatus="38";
+ public static final String EcgppG="39";
+ public static final String GPSControlCommand="40";
+ public static final String Gps="41";//手环发送给app
+ public static final String GetHRVData="42";
+ public static final String CMD_Set_TemperatureCorrection="43";
+ public static final String Weather="44";
+ public static final String Braceletdial="45";
+ public static final String Braceletdialok="46";
+ public static final String SportMode="47";
+ public static final String GetSportMode="48";
+ public static final String CMD_Set_WorkOutReminder="49";
+ public static final String CMD_Get_WorkOutReminder="50";
+ public static final String ReadSerialNumber="51";
+ public static final String ECG="53";
+ public static final String Clear_Bracelet_data="54";
+ public static final String Blood_oxygen="55";
+ public static final String SocialdistanceGetting="56";
+ public static final String SocialdistanceSetting="57";
+ public static final String Sos="58";
+ public static final String Temperature_history="59";
+ public static final String SetDialinterface="60";
+ public static final String HeartBeatpacket="61";
+ public static final String GetAxillaryTemperatureDataWithMode="62";
+ public static final String GetMAC="63";
+ public static final String Getppg="64";
+ public static final String CloseECGPPG="65";
+ public static final String GetEcgPpgStatus="66";
+ public static final String ECGdata="67";
+ public static final String GetAutomaticSpo2Monitoring="68";
+ public static final String SetSpo2="69";
+ public static final String GEtSpo2="70";
+ public static final String DeleteECGdata="71";
+ public static final String DeleteHrv="72";
+ public static final String MeasurementHrvCallback="73";
+ public static final String MeasurementHeartCallback="74";
+ public static final String MeasurementOxygenCallback="75";
+ public static final String StopMeasurementHrvCallback="76";
+ public static final String StopMeasurementHeartCallback="77";
+ public static final String StopMeasurementOxygenCallback="78";
+ public static final String ExitQRcode="79";
+ public static final String EnterQRcode="80";
+ public static final String QRcodebandBack="81";
+ public static final String SportData="82";
+ public static final String Delete_Obtain_The_data_of_manual_blood_oxygen_test="83";
+ public static final String Delete_Blood_oxygen="84";
+ public static final String Delete_GetTotalActivityData="85";
+ public static final String Delete_AlarmClock="87";
+ public static final String Delete_ActivityModeData="88";
+ public static final String Delete_GetStaticHR="89";
+ public static final String Delete_GetDynamicHR="90";
+ public static final String deleteGetTemperature_historyDataWithMode="91";
+ public static final String deleteGetAxillaryTemperatureDataWithMode="92";
+ public static final String deleteGetDetailActivityDataWithMode="93";
+ public static final String Delete_GetDetailSleepData="94";
+ public static final String Enter_photo_mode="95";
+ public static final String openRRInterval="96";
+ public static final String closeRRInterval="97";
+ public static final String realtimeRRIntervalData="98";
+ public static final String realtimePPGData="99";
+ public static final String realtimePPIData="100";
+
+ public static final String ppgWithMode="101";
+ public static final String ppgStartSucessed="102";
+ public static final String ppgStartFailed="103";
+ public static final String ppgStop="104";
+ public static final String ppgQuit="105";
+ public static final String ppgMeasurementProgress="106";
+ public static final String ppgResult="107";
+ public static final String SetBloodpressure_calibration="108";
+ public static final String GetBloodpressure_calibration="109";
+ public static final String SetWomenHealth="110";
+ public static final String GetWomenHealth="111";
+
+ public static final String SetPregnancyCycle="112";
+ public static final String GetPregnancyCycle="113";
+ public static final String Getpeisu="114";
+ public static final String GetpeisuER="115";
+ public static final String CMD_Set_Name="116";
+ public static final String CMD_Get_Name="117";
+ public static final String Blood_glucose_status="118";
+ public static final String Blood_glucose_data="119";
+ public static final String FindActivityMode="120";
+
+
+
+ public static final String FindMobilePhoneMode="FindMobilePhoneMode";
+ public static final String RejectTelMode ="RejectTelMode";
+ public static final String TelMode ="TelMode";
+ public static final String ECGResult="ECGResult";
+ public static final String ENTERECG="ENTERECG";
+
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/DeviceConst.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/DeviceConst.java
new file mode 100644
index 00000000..0f09b9be
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/DeviceConst.java
@@ -0,0 +1,41 @@
+package com.jstyle.blesdk2301.constant;
+
+/**
+ * Created by Administrator on 2018/1/17.
+ */
+
+public class DeviceConst {
+ public static final byte CMD_SET_TIME = (byte)0x01;
+ public static final byte CMD_GET_TIME = (byte)0x41;
+ public static final byte CMD_Set_UseInfo = (byte)0x02;
+ public static final byte CMD_GET_USERINFO = (byte) 0x42;
+ public static final byte CMD_Set_DeviceID = (byte)0x05;
+ public static final byte CMD_Enable_Activity = (byte)0x09;//
+ public static final byte CMD_Get_BatteryLevel = (byte)0x13;//
+ public static final byte CMD_Get_Address = (byte)0x22;
+ public static final byte CMD_Get_Version = (byte)0x27;
+ public static final byte CMD_Reset = (byte)0x12;
+ public static final byte CMD_Mcu_Reset = (byte)0x2e;
+ public static final byte CMD_Set_Auto = (byte)0x2a;
+ public static final byte CMD_Get_Auto = (byte)0x2b;
+ public static final byte CMD_Get_TotalData = (byte)0x51;//
+ public static final byte CMD_Get_DetailData = (byte)0x52;
+ public static final byte CMD_Get_SleepData = (byte)0x53;
+ public static final byte CMD_Get_HeartData = (byte)0x54;
+ public static final byte CMD_Get_OnceHeartData = (byte)0x55;
+ public static final byte CMD_Get_HrvTestData = (byte)0x56;//
+ public static final byte ReadTempHisrory= (byte)0x62;
+ public static final byte MeasurementWithType= (byte)0x28;
+ public static final byte Oxygen_data= (byte)0x66;
+
+ public static final byte CMD_Start_EXERCISE = (byte)0x19;
+ public static final byte CMD_heart_package= (byte)0x17;
+ public static final byte CMD_HeartPackageFromDevice = (byte)0x18;//
+ public static final byte CMD_Set_Name = (byte)0x3d;
+ public static final byte CMD_Get_Name = (byte)0x3e;
+
+ public static final byte CMD_Get_SPORTData = (byte)0x5C;
+
+ public static final byte CMD_Get_Bloodsugar = (byte)0x78;
+ public static final byte Bloodsugar_data=(byte)0x3a;//血糖数据
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/DeviceKey.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/DeviceKey.java
new file mode 100644
index 00000000..3bcdbcf1
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/constant/DeviceKey.java
@@ -0,0 +1,413 @@
+package com.jstyle.blesdk2301.constant;
+
+/**
+ * Created by Administrator on 2018/4/10.
+ */
+
+public class DeviceKey {
+ public static final String heartValue = "heartValue";
+ public static final String hrvValue = "hrvValue";
+ public static final String Quality = "Quality";
+
+ public static final String HangUp = "HangUp";
+ public static final String Telephone = "Telephone";
+ public static final String Photograph = "Photograph";
+ public static final String CanclePhotograph = "CanclePhotograph";
+ public static final String type = "type";
+ public static final String Play = "Play";
+ public static final String Suspend = "Suspend";
+ public static final String LastSong = "LastSong";
+ public static final String NextSong = "NextSong";
+ public static final String VolumeReduction = "VolumeReduction";
+ public static final String VolumeUp = "VolumeUp";
+ public static final String FindYourPhone = "FindYourPhone";
+ public static final String Cancle_FindPhone = "Cancle_FindPhone";
+ public static final String SOS = "SOS";
+ public static final String DataType = "dataType";
+ public static final String enterActivityModeSuccess = "enterActivityModeSuccess";
+ public static final String Type = "Type";
+ public static final String Status = "Status";
+ public static final String RRIntervalData = "RRIntervalData";
+ public static final String Manual = "Manual";
+ public static final String automatic = "automatic";
+ public static final String Data = "dicData";
+ public static final String End = "dataEnd";
+ public static final String index = "index";
+ public static final String scanInterval = "scanInterval";
+ public static final String scanTime = "scanTime";
+ public static final String signalStrength = "signalStrength";
+ public static final String arrayX = "arrayX";
+ public static final String arrayY = "arrayY";
+ public static final String arrayZ = "arrayZ";
+ public static final String arrayPpgRawData = "arrayPpgRawData";
+ public static final String KGpsResCheck0 = "KGpsResCheck0"; // 设备时间 GET_DEVICE_Time
+ public static final String KGpsResCheck1 = "KGpsResCheck1"; // 设备时间
+ public static final String Band = "Band";
+ public static final String KFinishFlag = "finish";
+ public static final String DeviceTime = "strDeviceTime"; // 设备时间 GET_DEVICE_Time
+ public static final String GPSTime = "gpsExpirationTime"; // 设备时间 GET_DEVICE_Time
+ public static final String TimeZone = "TimeZone"; // 设备时间 GET_DEVICE_Time
+
+
+ public static final String KHrvBloodHighPressure = "KHrvBloodHighPressure";
+ public static final String KHrvBloodLowPressure = "KHrvBloodLowPressure";
+ /*
+ * GET_PERSONAL_INFO
+ * sex 性别
+ * Age 年龄
+ * Height 身高
+ * Weight 体重
+ * stepLength 步长
+ * deviceId 设备ID
+ */
+ public static final String Gender = "MyGender";
+ public static final String Age = "MyAge";
+ public static final String Height = "MyHeight";
+ public static final String Weight = "MyWeight";
+ public static final String Stride = "MyStride";
+ public static final String KUserDeviceId = "deviceId";
+
+
+ /*
+ * GET_DEVICE_INFO
+ * distanceUnit 距离单位
+ * hourState 12小时24小时显示
+ * handleEnable 抬手检查使能标志
+ * handleSign 抬手检测左右手标志
+ * screenState 横竖屏显示
+ * anceEnable ANCS使能开关
+ */
+ public static final String DistanceUnit = "distancUnit";
+ public static final String TimeUnit = "timeUnit";
+ public static final String TempUnit = "temperatureUnit";
+ public static final String WristOn = "wristOn";
+ public static final String TemperatureUnit = "TemperatureUnit";
+ public static final String NightMode = "NightMode";
+ public static final String LeftOrRight = "handleSign";
+ //public static final String ScreenShow = "screenState";
+ public static final String Dialinterface = "dialinterface";
+ public static final String SocialDistancedwitch = "SocialDistancedwitch";
+ public static final String ChineseOrEnglish= "ChineseOrEnglish";
+ public static final String Lauage= "Lauage";
+ public static final String ScreenBrightness = "dcreenBrightness";
+ public static final String KBaseHeart = "baseHeartRate";
+ public static final String isHorizontalScreen = "isHorizontalScreen";
+
+ public static final String Year = "Year";
+ public static final String Month = "Month";
+ public static final String Day = "Day";
+ public static final String MenstrualPeriod_Lenth = "MenstrualPeriod_Lenth";
+ public static final String MenstrualPeriod_Period = "MenstrualPeriod_Period";
+
+ /*
+ * SET_STEP_MODEL
+ *totalSteps 总步数
+ *calories 卡路里
+ *distance 距离
+ *time 时间
+ *heartValue 心率值
+ */
+
+ public static final String Step = "step";
+ public static final String Calories = "calories";
+ public static final String Distance = "distance";
+ public static final String ExerciseMinutes = "exerciseMinutes";
+ public static final String HeartRate = "heartRate";
+ public static final String ActiveMinutes = "ExerciseTime";
+ public static final String TempData = "TempData";
+ public static final String StepGoal = "stepGoal"; // 目标步数值 GET_GOAL
+ public static final String BatteryLevel = "batteryLevel"; // 电量级别 READ_DEVICE_BATTERY
+ public static final String Chargingstate = "Chargingstate"; // 充电状态
+ public static final String Voltage_value = "VoltageValue"; // 电压值
+ public static final String MacAddress = "macAddress"; // MAC地址 READ_MAC_ADDRESS
+ public static final String DeviceVersion = "deviceVersion"; // 版本号 READ_VERSION
+ public static final String DeviceName = "deviceName"; // 设备名称 GET_DEVICE_NAME
+ public static final String TemperatureCorrectionValue = "TemperatureCorrectionValue"; // 设备名称 GET_DEVICE_NAME
+
+ /*
+ * GET_AUTOMIC_HEART
+ *workModel 工作模式
+ *heartStartHour 开始运动时间的小时
+ *heartStartMinter 开始运动时间的分钟
+ *heartEndHour 结束运动时间的小时
+ *heartEndMinter 结束运动时间的分钟
+ *heartWeek 星期使能
+ *workTime 工作模式时间
+ */
+ public static final String WorkMode = "workModel";
+ public static final String StartTime = "heartStartHour";
+ public static final String KHeartStartMinter = "heartStartMinter";
+ public static final String EndTime = "heartEndHour";
+ public static final String KHeartEndMinter = "heartEndMinter";
+ public static final String Weeks = "weekValue";
+ public static final String IntervalTime = "intervalTime";
+ public static final String Time = "Time";
+ public static final String PPG = "PPG";
+
+
+ /*
+ * READ_SPORT_PERIOD
+ *StartTimeHour 开始运动时间的小时
+ *StartTimeMin 开始运动时间的分钟
+ *EndTimeHour 结束运动时间的小时
+ *EndTimeMin 结束运动时间的分钟
+ *Week 星期使能
+ *KSportNotifierTime 运动提醒周期
+ */
+ public static final String StartTimeHour = "sportStartHour";
+ public static final String StartTimeMin = "sportStartMinter";
+ public static final String EndTimeHour = "sportEndHour";
+ public static final String EndTimeMin = "sportEndMinter";
+
+ public static final String LeastSteps = "leastSteps";
+
+ /*
+ * GET_STEP_DATA
+ *historyDate 日期:年月日
+ *historySteps 步数
+ *historyTime 运动时间
+ *historyDistance 距离
+ *Calories 卡路里
+ *historyGoal 目标
+ */
+ public static final String Date = "date";
+ public static final String Size = "size";
+ public static final String Goal = "goal";
+
+
+
+ /*
+ * GET_STEP_DETAIL
+ *Date 日期:年月日时分秒
+ *ArraySteps 步数
+ *Calories 卡路里
+ *Distance 距离
+ *KDetailMinterStep 10分钟内每一分钟的步数
+ */
+
+ public static final String ArraySteps = "arraySteps";
+
+ public static final String KDetailMinterStep = "detailMinterStep";
+ public static final String temperature = "temperature";
+ public static final String axillaryTemperature = "axillaryTemperature";
+
+ /*
+ * GET_SLEEP_DETAIL
+ *Date 日期:年月日时分秒
+ *KSleepLength 睡眠数据的长度
+ *ArraySleep 5分钟的睡眠质量 (总共24个数据,每一个数据代表五分钟)
+ */
+
+ public static final String KSleepLength = "sleepLength";
+ public static final String ArraySleep = "arraySleepQuality";
+ public static final String sleepUnitLength = "sleepUnitLength";//是不是一分钟的睡眠数据 1为1分钟数据 0为5分钟数据
+
+ /*
+ * GET_HEART_DATA
+ *Date 日期:年月日时分秒
+ *ArrayDynamicHR 10秒一个心率值,总共12个心率值
+ */
+
+ public static final String ArrayDynamicHR = "arrayDynamicHR";
+ public static final String Blood_oxygen = "Blood_oxygen";
+
+
+
+ /*
+ * GET_ONCE_HEARTDATA
+ *Date 日期:年月日时分秒
+ *StaticHR 心率值
+ */
+
+ public static final String StaticHR = "onceHeartValue";
+
+ /*
+ * GET_HRV_DATA
+ *Date 日期:年月日时分秒
+ *HRV HRV值
+ *VascularAging 血管老化度值
+ *HeartRate 心率值
+ *Stress 疲劳度
+ */
+
+ public static final String HRV = "hrv";
+ public static final String VascularAging = "vascularAging";
+ public static final String Fatiguedegree = "fatigueDegree";
+
+ public static final String Stress = "stress";
+ public static final String HighPressure = "highPressure";
+ public static final String LowPressure = "lowPressure";
+ public static final String highBP = "highBP";
+ public static final String lowBP = "lowBP";
+
+ /*
+ *GET_ALARM
+ *KAlarmId 0到4闹钟编号
+ *ClockType 闹钟类型
+ *ClockTime 闹钟时间的小时
+ *KAlarmMinter 闹钟时间的分钟
+ *Week 星期使能
+ *KAlarmLength 长度
+ *KAlarmContent 文本的内容
+ */
+ public static final String KAlarmId = "alarmId";
+ public static final String OpenOrClose = "clockOpenOrClose";
+ public static final String ClockType = "clockType";
+ public static final String ClockTime = "alarmHour";
+ public static final String KAlarmMinter = "alarmMinter";
+ public static final String Week = "weekValue";
+ public static final String KAlarmLength = "alarmLength";
+ public static final String KAlarmContent = "dicClock";
+
+
+ /***********************GET_HRV_TESTDATA***************************************************/
+ /*
+ *KBloodTestLength 数据长度
+ *KBloodTestProgress 进度
+ *KBloodTestValue 本次PPG获得的值
+ *KBolldTestCurve 本次波型的高度
+ */
+ public static final String KBloodTestLength = "bloodTestLength";
+ public static final String KBloodTestProgress = "bloodTestProgress";
+ public static final String KBloodTestValue = "bloodTestValue";
+ public static final String KBloodTestCurve = "bloodTestCurve";
+
+ /*
+ *KBloodResultPercent 反弹的百分比
+ *KBloodResultRebound 平均反弹高度
+ *KBloodResultMax 最大高度
+ *KBloodResultRank 结果级别(1到6)
+ */
+ public static final String KBloodResultPercent = "bloodPercent";
+ public static final String KBloodResultRebound = "bloodRebound";
+ public static final String KBloodResultMax = "bloodResultMax";
+ public static final String KBloodResultRank = "bloodResultRank";
+
+
+ /*
+ *KHrvTestProgress 进度
+ *KHrvTestWidth 本次心跳的宽度
+ *KHrvTestValue 心率值
+ */
+ public static final String KHrvTestProgress = "hrvTestProgress";
+ public static final String KHrvTestWidth = "hrvTestWidth";
+ public static final String KHrvTestValue = "hrvTestValue";
+
+ /*
+ *KHrvResultState SDNN结果 如果是0,说明检测失败
+ *KHrvResultAvg SDNN平均值
+ *KHrvResultTotal 总SDNN结果
+ *KHrvResultCount 有效数据个数
+ *KHrvResultTired 疲劳指数据
+ *KHrvResultValue 心率值
+ */
+ public static final String KHrvResultState = "hrvResultState";
+ public static final String KHrvResultAvg = "hrvResultAvg";
+ public static final String KHrvResultTotal = "hrvResultTotal";
+ public static final String KHrvResultCount = "hrvResultCount";
+ public static final String KHrvResultTired = "hrvResultTired";
+ public static final String KHrvResultValue = "hrvResultValue";
+
+
+ /*
+ *KDisturbState 1:开始运动 0:停止运动
+ *KSlipHand 1: 带在手上 0;脱手。
+ *KPPGData PPG的波型值
+ */
+ public static final String KDisturbState = "disturbState";
+ public static final String KSlipHand = "slipHand";
+ public static final String KPPGData = "ppgData";
+ public static final String KPPIData = "ppiData";
+
+ public static final String ppgResult = "ppgResult";
+
+ public static final String ppgStartSucessed="ppgStartSucessed";
+ public static final String ppgStartFailed="ppgStartFailed";
+ public static final String ppgStop="ppgStop";
+ public static final String ppgQuit="ppgQuit";
+ public static final String ppgMeasurementProgress="ppgMeasurementProgress";
+
+
+
+
+
+ /*
+ *@param Date 时间:年月日时分秒
+ *@param Latitude 纬度数据
+ *@param Longitude 经度数据
+ */
+
+
+ public static final String Latitude = "locationLatitude";
+ public static final String Longitude = "locationLongitude";
+
+ public static final String KActivityLocationTime = "ActivityLocationTIme";
+ public static final String KActivityLocationLatitude = "ActivityLocationLatitude";
+ public static final String KActivityLocationLongitude = "ActivityLocationLongitude";
+ public static final String KActivityLocationCount = "KActivityLocationCount";
+/*
+ * GET_SPORTMODEL_DATA
+ *@param Date 时间:年月日时分秒
+ *@param ActivityMode 运动类型
+ 0=Run,
+ 1=Cycling,
+ 2=Swimming,
+ 3=Badminton,
+ 4=Football,
+ 5=Tennis,
+ 6=Yoga,
+ 7=Medication,
+ 8=Dance
+
+ *@param HeartRate 心率
+ *@param ActiveMinutes 运动时间
+ *@param Step 运动步数
+ *@param Pace 运动速度
+ *@param Calories 卡路里
+ *@param Distance 距离
+ */
+
+
+ public static final String ActivityMode = "sportModel";
+ public static final String Pace = "sportModelSpeed";
+
+ public static final String KDataID = "KDataID";
+ public static final String KPhoneDataLength = "KPhoneDataLength";
+ public static final String KClockLast = "KClockLast";
+
+
+ public static final String TakePhotoMode = "TakePhotoMode";
+ public static final String KFunction_tel = "TelMode";
+ public static final String KFunction_reject_tel = "RejectTelMode";
+
+ public static final String FindMobilePhoneMode = "FindMobilePhoneMode";
+ public static final String KEnable_exercise = "KEnable_exercise";
+ public static final String ECGQualityValue = "ECGQualityValue";
+
+ public static final String ECGResultValue = "ECGResultVALUE";
+ public static final String ECGHrvValue = "ECGHrvValue";
+ public static final String ECGAvBlockValue = "ECGAvBlockValue";
+ public static final String ECGHrValue = "ECGHrValue";
+ public static final String PPGHrValue = "PPGHrValue";
+ public static final String ECGStreesValue = "ECGStreesValue";
+ public static final String ECGhighBpValue = "ECGhighBpValue";
+ public static final String ECGLowBpValue = "ECGLowBpValue";
+ public static final String ECGMoodValue = "ECGMoodValue";
+ public static final String ECGBreathValue = "ECGBreathValue";
+ public static final String KEcgDataString = "KEcgDataString"; // ecg
+ public static final String ECGValue = "ECGValue";
+ public static final String PPGValue = "PPGValue";
+ public static final String EcgStatus = "EcgStatus";
+ public static final String EcgSBP = "PPGSBP";
+ public static final String EcgDBP = "PPGDBP";
+ public static final String EcgHR = "PPGHR";
+ public static final String WaveformDownTime = "WaveformDownTime";
+ public static final String WaveformRiseTime = "WaveformRiseTime";
+
+ public static final String EcgGender = "Gender";
+ public static final String EcgAge = "Age";
+ public static final String EcgHeight = "Height";
+ public static final String EcgWeight = "Weight";
+
+
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/AutoMode.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/AutoMode.java
new file mode 100644
index 00000000..63ab1b1a
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/AutoMode.java
@@ -0,0 +1,5 @@
+package com.jstyle.blesdk2301.model;
+
+public enum AutoMode {
+ AutoHeartRate, AutoSpo2,AutoTemp,AutoHrv
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/AutoTestMode.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/AutoTestMode.java
new file mode 100644
index 00000000..a5dfae77
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/AutoTestMode.java
@@ -0,0 +1,5 @@
+package com.jstyle.blesdk2301.model;
+
+public enum AutoTestMode {
+ AutoHeartRate, AutoSpo2,
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/Clock.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/Clock.java
new file mode 100644
index 00000000..cc98963b
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/Clock.java
@@ -0,0 +1,87 @@
+package com.jstyle.blesdk2301.model;
+
+import java.io.Serializable;
+
+/**
+ * Created by Administrator on 2018/1/16.
+ */
+
+public class Clock extends SendData implements Serializable {
+
+ int number;
+ int type;
+ int hour;
+ int minute;
+ byte week;
+ String content;
+ boolean enable;
+
+ public boolean isEnable() {
+ return enable;
+ }
+
+ public void setEnable(boolean enable) {
+ this.enable = enable;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public int getHour() {
+ return hour;
+ }
+
+ public void setHour(int hour) {
+ this.hour = hour;
+ }
+
+ public int getMinute() {
+ return minute;
+ }
+
+ public void setMinute(int minute) {
+ this.minute = minute;
+ }
+
+ public int getWeek() {
+ return week;
+ }
+
+ public void setWeek(byte week) {
+ this.week = week;
+ }
+
+ @Override
+ public String toString() {
+ return "Clock{" +
+ "number=" + number +
+ ", type=" + type +
+ ", hour=" + hour +
+ ", minute=" + minute +
+ ", week=" + week +
+ ", content='" + content + '\'' +
+ ", enable=" + enable +
+ '}';
+ }
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/Device.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/Device.java
new file mode 100644
index 00000000..451a61d2
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/Device.java
@@ -0,0 +1,103 @@
+package com.jstyle.blesdk2301.model;
+
+import android.bluetooth.BluetoothDevice;
+
+import java.io.Serializable;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+
+
+public class Device implements Serializable{
+ String name;//设备名字
+ String mac;//设备的mac
+ int productID;//产品id,预留
+ BluetoothDevice getBluetoothDevice;//蓝牙
+ boolean isconted=false;//蓝牙是否连接
+ boolean IsPaired=false;//是否是配对设备
+ boolean isdfu=false;//是否直接升级
+ int riss=100;
+
+ public int getRiss() {
+ return riss;
+ }
+
+ public void setRiss(int riss) {
+ this.riss = riss;
+ }
+
+ ScheduledThreadPoolExecutor time=null;//每一个设备轮询器
+
+ public boolean isIsdfu() {
+ return isdfu;
+ }
+
+ public void setIsdfu(boolean isdfu) {
+ this.isdfu = isdfu;
+ }
+
+ public ScheduledThreadPoolExecutor getTime() {
+ return time;
+ }
+
+ public void setTime(ScheduledThreadPoolExecutor time) {
+ this.time = time;
+ }
+ public boolean isPaired() {
+ return IsPaired;
+ }
+
+ public void setPaired(boolean paired) {
+ IsPaired = paired;
+ }
+
+ public boolean isIsconted() {
+ return isconted;
+ }
+
+ public void setIsconted(boolean isconted) {
+ this.isconted = isconted;
+ }
+
+ public String getName() {
+ return name==null?"":this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getMac() {
+ return mac==null?"":this.mac;
+ }
+
+ public void setMac(String mac) {
+ this.mac = mac;
+ }
+
+ public int getProductID() {
+ return productID;
+ }
+
+ public void setProductID(int productID) {
+ this.productID = productID;
+ }
+
+ public BluetoothDevice getBluetoothDevice() {
+ return getBluetoothDevice;
+ }
+
+ public void setBluetoothDevice(BluetoothDevice bluetoothDevice) {
+ this.getBluetoothDevice = bluetoothDevice;
+ }
+
+
+ @Override
+ public String toString() {
+ return "Device{" +
+ "name='" + name + '\'' +
+ ", mac='" + mac + '\'' +
+ ", productID=" + productID +
+ ", getBluetoothDevice=" + getBluetoothDevice +
+ ", isconted=" + isconted +
+ '}';
+ }
+}
diff --git a/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/DeviceBean.java b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/DeviceBean.java
new file mode 100644
index 00000000..a761263e
--- /dev/null
+++ b/android/blesdk_2301/src/main/java/com/jstyle/blesdk2301/model/DeviceBean.java
@@ -0,0 +1,29 @@
+package com.jstyle.blesdk2301.model;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by Administrator on 2018/4/28.
+ */
+
+public class DeviceBean {
+ List