修改了APH1的指令生成.
authorTrillGates <WilliamTrillGates@gmail.com>
Fri, 18 Mar 2022 03:46:48 +0000 (11:46 +0800)
committerTrillGates <WilliamTrillGates@gmail.com>
Fri, 18 Mar 2022 03:46:48 +0000 (11:46 +0800)
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

index f966a53..ab321b7 100644 (file)
@@ -1212,9 +1212,32 @@ public class DBHelper {
         ICLogger.i("Query1 cmdRecords " + where);
         Cursor cmdrecords = pcr.query(table, null, where.toString(), null, null);
         StringMessage msg = null;
-        if (cmdrecords != null) {
-            int score = 0;
-            if (cmdrecords.getCount() > 0) { //有警报则先发送警报
+        if (cmdrecords != null && cmdrecords.getCount() > 0) { //有警报则先发送警报
+            if (cmdrecords.moveToFirst()) {
+                String topic = cmdrecords.getString(cmdrecords.getColumnIndex("TOPIC"));
+                String cmd = cmdrecords.getString(cmdrecords.getColumnIndex("CMD"));
+                String date = cmdrecords.getString(cmdrecords.getColumnIndex("DATE"));
+                String time = cmdrecords.getString(cmdrecords.getColumnIndex("TIME"));
+                int flag = cmdrecords.getInt(cmdrecords.getColumnIndex("FLAG"));
+                int index = cmdrecords.getInt(cmdrecords.getColumnIndex("_id"));
+
+                msg = new StringMessage(new String[]{topic});
+                msg.refresh(cmd);
+                msg.setDate(date, time);
+                msg.setSentFlag(flag);
+                msg.setIndex(index);
+                ICLogger.i("get cmd Record not sent  _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
+            }
+            cmdrecords.close();
+        } else { //没有警报,就查询 UD 消息发送 //当前数据优先于 UD2数据
+            if (cmdrecords != null) {
+                cmdrecords.close();
+            }
+            where = new StringBuilder("FLAG=0 and ( TOPIC='AP01' or TOPIC='UD' ) ");
+            cmdrecords = pcr.query(table, null, where.toString(), null, null);
+            ICLogger.i("Query2 cmdRecords " + where);
+            msg = null;
+            if (cmdrecords != null && cmdrecords.getCount() > 0) {
                 if (cmdrecords.moveToFirst()) {
                     String topic = cmdrecords.getString(cmdrecords.getColumnIndex("TOPIC"));
                     String cmd = cmdrecords.getString(cmdrecords.getColumnIndex("CMD"));
@@ -1222,7 +1245,6 @@ public class DBHelper {
                     String time = cmdrecords.getString(cmdrecords.getColumnIndex("TIME"));
                     int flag = cmdrecords.getInt(cmdrecords.getColumnIndex("FLAG"));
                     int index = cmdrecords.getInt(cmdrecords.getColumnIndex("_id"));
-
                     msg = new StringMessage(new String[]{topic});
                     msg.refresh(cmd);
                     msg.setDate(date, time);
@@ -1231,11 +1253,13 @@ public class DBHelper {
                     ICLogger.i("get cmd Record not sent  _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
                 }
                 cmdrecords.close();
-            } else { //没有警报,就查询 UD 消息发送 //当前数据优先于 UD2数据
-                cmdrecords.close();
-                where = new StringBuilder("FLAG=0 and ( TOPIC='AP01' or TOPIC='UD' ) ");
+            } else {
+                if (cmdrecords != null) {
+                    cmdrecords.close();
+                }
+                where = new StringBuilder("FLAG=0 and ( TOPIC='APH1' or TOPIC='UD2' )");
                 cmdrecords = pcr.query(table, null, where.toString(), null, null);
-                ICLogger.i("Query2 cmdRecords " + where);
+                ICLogger.i("Query3 cmdRecords " + where);
                 msg = null;
                 if (cmdrecords != null && cmdrecords.getCount() > 0) {
                     if (cmdrecords.moveToFirst()) {
@@ -1254,10 +1278,12 @@ public class DBHelper {
                     }
                     cmdrecords.close();
                 } else {
-                    cmdrecords.close();
-                    where = new StringBuilder("FLAG=0 and ( TOPIC='APH1' or TOPIC='UD2' )");
+                    if (cmdrecords != null) {
+                        cmdrecords.close();
+                    }
+                    where = new StringBuilder("FLAG=0");
                     cmdrecords = pcr.query(table, null, where.toString(), null, null);
-                    ICLogger.i("Query3 cmdRecords " + where);
+                    ICLogger.i("Query4 cmdRecords " + where);
                     msg = null;
                     if (cmdrecords != null && cmdrecords.getCount() > 0) {
                         if (cmdrecords.moveToFirst()) {
@@ -1275,29 +1301,6 @@ public class DBHelper {
                             ICLogger.i("get cmd Record not sent  _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
                         }
                         cmdrecords.close();
-                    } else {
-                        cmdrecords.close();
-                        where = new StringBuilder("FLAG=0");
-                        cmdrecords = pcr.query(table, null, where.toString(), null, null);
-                        ICLogger.i("Query4 cmdRecords " + where);
-                        msg = null;
-                        if (cmdrecords != null && cmdrecords.getCount() > 0) {
-                            if (cmdrecords.moveToFirst()) {
-                                String topic = cmdrecords.getString(cmdrecords.getColumnIndex("TOPIC"));
-                                String cmd = cmdrecords.getString(cmdrecords.getColumnIndex("CMD"));
-                                String date = cmdrecords.getString(cmdrecords.getColumnIndex("DATE"));
-                                String time = cmdrecords.getString(cmdrecords.getColumnIndex("TIME"));
-                                int flag = cmdrecords.getInt(cmdrecords.getColumnIndex("FLAG"));
-                                int index = cmdrecords.getInt(cmdrecords.getColumnIndex("_id"));
-                                msg = new StringMessage(new String[]{topic});
-                                msg.refresh(cmd);
-                                msg.setDate(date, time);
-                                msg.setSentFlag(flag);
-                                msg.setIndex(index);
-                                ICLogger.i("get cmd Record not sent  _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
-                            }
-                            cmdrecords.close();
-                        }
                     }
                 }
             }
index feae43e..9ecec5f 100644 (file)
@@ -1210,7 +1210,6 @@ public class protocolAPIHelper {
                 break;
             case Config.PROTOCOL_BEEHOME:
                 ret = protocol_beehome.genUD2FromUD(msg);
-                ret = null;
                 break;
             case Config.PROTOCOL_IC:
                 ret = null;
index 01604bf..28dba4e 100644 (file)
@@ -85,10 +85,9 @@ public class protocol_beehome {
     }
 
     public static StringMessage genUD2FromUD(StringMessage ud) {
-        String cmd, data, tmp;
+        String data, tmp;
         tmp = ud.isFromCache();
         if (isCmdStr(tmp).equals("AP01")) {
-            cmd = ud.cmd().equals("AP01") ? "APH1 " : ud.cmd();
             tmp = ud.isFromCache().replace("]", "");
             int index = tmp.indexOf("AP01,");
             data = tmp.substring(index + 3);
index 5ed57e8..fcf7c3c 100644 (file)
@@ -1,2 +1,2 @@
-#Wed Mar 16 11:05:24 CST 2022\r
-VERSION_CODE=960\r
+#Thu Mar 17 17:43:41 CST 2022\r
+VERSION_CODE=962\r