指令数据库如果数据超过了100,那么就会把旧的数据删除掉
authorTrillGates <williamtrillgates@gmail.com>
Fri, 26 Nov 2021 02:23:37 +0000 (10:23 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Fri, 26 Nov 2021 02:23:37 +0000 (10:23 +0800)
app/release/ICSer_V922_2111241457_release.apk [moved from app/release/ICSer_V921_2111241057_release.apk with 77% similarity]
app/release/output.json
app/src/main/java/com/enqualcomm/support/service/HeartRateManager.java
app/src/main/java/com/enqualcomm/support/utils/DBHelper.java
app/src/main/java/com/ic/protocols/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_beehome.java
app/version_code.properties

similarity index 77%
rename from app/release/ICSer_V921_2111241057_release.apk
rename to app/release/ICSer_V922_2111241457_release.apk
index 5fc71a7..a86eda8 100644 (file)
Binary files a/app/release/ICSer_V921_2111241057_release.apk and b/app/release/ICSer_V922_2111241457_release.apk differ
index 1c6a370..ba8078d 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":921,"versionName":"2111241057","enabled":true,"outputFile":"ICSer_V921_2111241057_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V921_2111241057_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":922,"versionName":"2111241457","enabled":true,"outputFile":"ICSer_V922_2111241457_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V922_2111241457_release.apk","properties":{}}]
\ No newline at end of file
index 51a36c1..b3059de 100644 (file)
@@ -211,6 +211,15 @@ public class HeartRateManager extends AbstractInvokeHandlerService {
                 }
             } else {
                 StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(this.runtime);
+                if (PPGDATA != null) {
+                    Deliver.sendLocationMSG(PPGDATA);
+                    ICLogger.i("Send PPG " + PPGDATA.isFromCache());
+                }
+                PPGDATA = protocolAPIHelper.getJustBoodPresureMsg(this.runtime);
+                if (PPGDATA != null) {
+                    Deliver.sendLocationMSG(PPGDATA);
+                    ICLogger.i("Send PPG " + PPGDATA.isFromCache());
+                }
                 //发送给EQC服务器的
                 sendBroadcastPPGResult();
                 //因为协议中没有时间变量,所以只能实时传输,如果恰巧没有网络也只能丢弃,有时间变量的话,可以考虑通过deliver的buffer来进行缓存发送
@@ -223,8 +232,6 @@ public class HeartRateManager extends AbstractInvokeHandlerService {
                     Deliver.sendLocationMSG(oxd);
                     checkWarning();
                 } else {
-                    Deliver.sendLocationMSG(PPGDATA);
-                    ICLogger.i("Send PPG " + PPGDATA.isFromCache());
                     checkWarning();
                 }
             }
index 0c4e0c7..9c1f1c6 100644 (file)
@@ -5,6 +5,7 @@ import android.content.ContentResolver;
 import android.content.ContentUris;
 import android.content.ContentValues;
 import android.content.Context;
+import android.content.IClipboard;
 import android.content.Intent;
 import android.database.Cursor;
 import android.net.Uri;
@@ -1073,19 +1074,46 @@ public class DBHelper {
 
     }
 
+    private int insertCount = 0;
+
     public long insertCMDRecord(StringMessage msg) {
+        //判断命令数量,如果超出了100个,那么就删除后面的数据
+        //减少删除和查询的次数,10个里头再操作一次
+        if (insertCount == 0 || insertCount >= 10) {
+            Cursor query = cr.query(ICContentProvider.PROTOCOL_CMD_RECORDS_URI, new String[]{"_id"}, null, null, null);
+            if (query != null) {
+                int count = query.getCount();
+                ICLogger.d("count ==> " + count);
+                //超过100个,把后面的删除了,默认没有排序,先添加的会参前面
+                if (count > 100) {
+                    query.moveToFirst();
+                    while (query.moveToNext() && insertCount > 1) {
+                        ICLogger.d("insertCount ==> " + insertCount);
+                        int id = query.getInt(0);
+                        ICLogger.d("delete id ==> " + id);
+                        insertCount--;
+                        //删除数据
+                        cr.delete(ICContentProvider.PROTOCOL_CMD_RECORDS_URI, "_id=?",
+                                new String[]{String.valueOf(id)});
+                    }
+                }
+                query.close();
+            }
+        }
+        //以上代码,删除过多的数据,库里保持0~110条
         ContentValues values = new ContentValues();
         values.put("FLAG", msg.haveSent());
-        if (msg.getDate() == null || msg.getTime() == null)
+        if (msg.getDate() == null || msg.getTime() == null) {
             msg.setDate(TimeUtil.getSystemDateYYMMDD(), TimeUtil.getSystemTimeHHmmss());
+        }
         values.put("DATE", msg.getDate());
         values.put("TIME", msg.getTime());
         values.put("TOPIC", msg.cmd());
         values.put("CMD", msg.isFromCache());
         long raw_contactID = ContentUris.parseId(cr.insert(ICContentProvider.PROTOCOL_CMD_RECORDS_URI, values));
-        if (Config.LOG_TOFILE)
+        if (Config.LOG_TOFILE) {
             ICLogger.logToFile("APILog", " insert db " + raw_contactID + " " + msg.getDate() + msg.getTime() + " " + msg.cmd() + " " + msg.isFromCache());
-
+        }
         return raw_contactID;
     }
 
index 870ef69..5f0c901 100644 (file)
@@ -95,6 +95,22 @@ public class protocolAPIHelper {
         }
     }
 
+    public static StringMessage getJustBoodPresureMsg(Runtime runtime) {
+        if (is_protocol_not_Initialled()) return null;
+        StringMessage ret = null;
+
+        if (runtime == null || runtime.getHRS().getBPH() <= 0) {
+            ICLogger.d(" 血压 值 <=0 跳过异常数据!");
+            return null;
+        }
+        switch (Config.protocol_no) {
+            case Config.PROTOCOL_BEEHOME:
+                ret = protocol_beehome.APJK(1, runtime);
+                break;
+        }
+        return ret;
+    }
+
     /*
        返回true 表示 cmd 全部解析成功
        返回false表示 cmd至少有一条解析失败,失败的数据归入buffer,下一次识别接着使用
@@ -681,7 +697,6 @@ public class protocolAPIHelper {
                 ret = protocol_jiai.APHT(runtime);
                 break;
             case Config.PROTOCOL_BEEHOME:
-                ret = protocol_beehome.APJK(1, runtime);
                 ret = protocol_beehome.APJK(2, runtime);
                 break;
             case Config.PROTOCOL_IC:
index ec70a1b..dcade1b 100644 (file)
@@ -1928,7 +1928,7 @@ public class protocol_beehome {
             //心率
             sb.append(runtime.getHRS().getPPG());
         } else if (type == 3) {
-            sb.append(runtime.tempInfo.currentBodyTemp);
+            sb.append(String.format("%1$.2f", runtime.tempInfo.currentBodyTemp));
         }
         sb.append(CMDEND);
         String s = sb.toString();
index a12ccf8..1bffc9e 100644 (file)
@@ -1,2 +1,2 @@
-#Wed Nov 24 10:57:19 CST 2021\r
-VERSION_CODE=921\r
+#Wed Nov 24 14:57:35 CST 2021\r
+VERSION_CODE=922\r