bee home 添加了BP46指令,远程拍照
authorTrillGates <williamtrillgates@gmail.com>
Thu, 17 Feb 2022 03:18:48 +0000 (11:18 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Thu, 17 Feb 2022 03:18:48 +0000 (11:18 +0800)
app/release/ICSer_V947_2201072010_release.apk [moved from app/release/ICSer_V946_2112311616_release.apk with 77% similarity]
app/release/output.json
app/src/main/java/com/ic/protocols/protocol_beehome.java
app/src/main/java/com/ic/protocols/protocol_s123.java
app/version_code.properties

similarity index 77%
rename from app/release/ICSer_V946_2112311616_release.apk
rename to app/release/ICSer_V947_2201072010_release.apk
index 24a7fd7..e08b909 100644 (file)
Binary files a/app/release/ICSer_V946_2112311616_release.apk and b/app/release/ICSer_V947_2201072010_release.apk differ
index a2bdeaa..465d093 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":946,"versionName":"2112311616","enabled":true,"outputFile":"ICSer_V946_2112311616_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V946_2112311616_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":947,"versionName":"2201072010","enabled":true,"outputFile":"ICSer_V947_2201072010_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V947_2201072010_release.apk","properties":{}}]
\ No newline at end of file
index 6e76db9..c18f162 100644 (file)
@@ -4,10 +4,13 @@ import android.Manifest;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.ContentValues;
+import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Environment;
+import android.os.Handler;
+import android.os.HandlerThread;
 import android.support.v4.app.ActivityCompat;
 import android.text.TextUtils;
 
@@ -28,6 +31,7 @@ import com.enqualcomm.support.provider.ICMembersProvider;
 import com.enqualcomm.support.provider.WeTalkMessageProvider;
 import com.enqualcomm.support.service.HeartRateManager;
 import com.enqualcomm.support.service.SilentManager;
+import com.enqualcomm.support.utils.CameraUtil;
 import com.enqualcomm.support.utils.CellInfoUtil;
 import com.enqualcomm.support.utils.Connection;
 import com.enqualcomm.support.utils.DeviceInfoUtil;
@@ -47,6 +51,7 @@ import java.util.HashMap;
 import java.util.List;
 
 import static com.enqualcomm.support.Constants.ACTION_ALARM_ALARM_CHANGE;
+import static com.enqualcomm.support.Constants.DIALOG_ACTION;
 import static com.enqualcomm.support.Constants.FROM_SERVER;
 import static com.enqualcomm.support.LocationClient.LOCATION_MODE;
 import static java.lang.Math.abs;
@@ -59,6 +64,7 @@ public class protocol_beehome {
     private static final String CMDSPLIT = ",";
     public static final String defaultServerIP = "en.beehome360.com";
     public static final int defaultServerPort = 5018;
+    private Handler mHandler = null;
 
 
     /**
@@ -197,6 +203,8 @@ public class protocol_beehome {
         BPTQ,//天气信息响应
         BP75,//闹钟数据下发
         AP75,//闹钟数据回复
+        AP46,//立即拍照
+        BP46,
     }
 
     private static HashMap<CMD_TYPE, String> cmdStrMap = null;
@@ -298,6 +306,8 @@ public class protocol_beehome {
         cmdStrMap.put(CMD_TYPE.BPTQ, "BPTQ");
         cmdStrMap.put(CMD_TYPE.BP75, "BP75");
         cmdStrMap.put(CMD_TYPE.AP75, "AP75");
+        cmdStrMap.put(CMD_TYPE.AP46, "AP46");
+        cmdStrMap.put(CMD_TYPE.BP46, "BP46");
         //
         cmdMap = new HashMap<>();
         cmdMap.put("AP00", CMD_TYPE.AP00);
@@ -392,6 +402,8 @@ public class protocol_beehome {
         cmdMap.put("APTQ", CMD_TYPE.APTQ);
         cmdMap.put("AP75", CMD_TYPE.AP75);
         cmdMap.put("BP75", CMD_TYPE.BP75);
+        cmdMap.put("BP46", CMD_TYPE.BP46);
+        cmdMap.put("AP46", CMD_TYPE.AP46);
     }
 
 
@@ -401,7 +413,11 @@ public class protocol_beehome {
     public protocol_beehome(Connection connect, Runtime runtime) {
         mConnection = connect;
         mRuntime = runtime;
-
+        if (mHandler == null) {
+            HandlerThread handlerThread = new HandlerThread("ic:protocol_s123-handler-thread");
+            handlerThread.start();
+            mHandler = new Handler(handlerThread.getLooper());
+        }
     }
 
     private StringBuffer cmdbuf = new StringBuffer();
@@ -492,6 +508,10 @@ public class protocol_beehome {
                 String cmdStr = cmdItem.substring(2, 6);
                 ICLogger.d("cmdStr ==> " + cmdStr);
                 CMD_TYPE key = cmdMap.get(cmdStr);
+                if (key == null) {
+                    ICLogger.d("不支持该指令==> " + cmdlist[i]);
+                    return false;
+                }
                 ICLogger.d("found cmd keyid=" + key + " ,keyname=" + cmdStrMap.get(key) + " ,  " + cmdlist[i]);
                 if (key == CMD_TYPE.BP28) {
                     //如果是BP28则 后面的数据是音频,需要保留
@@ -2654,6 +2674,70 @@ public class protocol_beehome {
     }
 
 
+    public void handleBP46(String cmd, Connection connection, Runtime runtime) {
+        /***
+         * IWBP46,353456789012345,080835,1,[参数]#
+         * 说明:
+         * IW:标识符
+         * BP46 : 命令字符
+         * 353456789012345:IMEI号,设备唯一ID
+         * 080835 :指令流水号
+         * 1: 表示立即拍照
+         * [参数]: 此为可选项。根据不同类型设备扩展
+         * #:结尾标识符
+         * 设备响应:     IWAP46,080835,1#
+         * 080835:指令流水号
+         * 1 成功 0失败
+         * # 结尾标识符
+         */
+        String[] cmdlist = cmd.split(CMDSPLIT);
+
+        if (cmdlist.length >= 4) {
+            String imei = cmdlist[1];
+            String id = cmdlist[2];
+            String cdd = cmdlist[3];
+            if (cmdlist.length == 5) {
+                String tmp = cmdlist[4];
+            }
+            connection.send(AP46(id, cdd));
+            Context context = mRuntime.getContextProxy().context.getApplicationContext();
+            if (cdd.equals("1")) {
+                //delay 启动
+
+//            Intent intent = new Intent(context, com.enqualcomm.support.CoreService.class);
+//            intent.setAction(ACTION_REMOTE_CAMERA);
+//            intent.putExtra("remote_number", id);
+//                context.startService(intent);
+//            runtime.getContextProxy().context.sendBroadcast(intent);
+                mHandler.post(new Runnable() {
+                    @Override
+                    public void run() {
+                        (new CameraUtil(context)).getPicture(id);
+                    }
+                });
+
+            } else if (cdd.equals("2")) {
+                Intent intent = new Intent();
+                intent.setAction(DIALOG_ACTION);
+                intent.putExtra("takephoto", "Take Photo !");
+                context.sendBroadcast(intent);
+            }
+        } else {
+            ICLogger.i(" BP46 Format error!");
+        }
+
+    }
+
+
+    public static StringMessage AP46(String id, String cmd) {
+        return genStringMessage(cmdStrMap.get(CMD_TYPE.AP46),
+                new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP46))
+                        .append(CMDSPLIT).append(id)
+                        .append(CMDSPLIT).append(cmd)
+                        .append(CMDEND).toString());
+    }
+
+
     public static StringMessage APHP(int ppg, int bph, int bpl, int spo2) {
         //IWAPHP,60,130,85,95,90, , , , , , , , #
         //IW:标识符
@@ -2906,6 +2990,11 @@ public class protocol_beehome {
                 ICLogger.d("收到服务器BP05");
                 handleBP05(cmd);
                 break;
+            case BP46: //立即拍照
+                ICLogger.i("立即拍照!");
+                handleBP46(cmd, mConnection, mRuntime);
+                break;
+
         }
         return ret;
     }
index fa18c35..87be46d 100644 (file)
@@ -2358,21 +2358,21 @@ public class protocol_s123 {
     }
 
     public void handleBP46(String cmd, Connection connection, Runtime runtime) {
-/***
- * IWBP46,353456789012345,080835,1,[参数]#
- * 说明:
- * IW:标识符
- * BP46 : 命令字符
- * 353456789012345:IMEI号,设备唯一ID
- * 080835 :指令流水号
- * 1: 表示立即拍照
- * [参数]: 此为可选项。根据不同类型设备扩展
- * #:结尾标识符
- * 设备响应:     IWAP46,080835,1#
- * 080835:指令流水号
- * 1 成功 0失败
- * # 结尾标识符
- */
+        /***
+         * IWBP46,353456789012345,080835,1,[参数]#
+         * 说明:
+         * IW:标识符
+         * BP46 : 命令字符
+         * 353456789012345:IMEI号,设备唯一ID
+         * 080835 :指令流水号
+         * 1: 表示立即拍照
+         * [参数]: 此为可选项。根据不同类型设备扩展
+         * #:结尾标识符
+         * 设备响应:     IWAP46,080835,1#
+         * 080835:指令流水号
+         * 1 成功 0失败
+         * # 结尾标识符
+         */
         String[] cmdlist = cmd.split(CMDSPLIT);
 
         if (cmdlist.length >= 4) {
index 08bb99e..50d9cd6 100644 (file)
@@ -1,2 +1,2 @@
-#Fri Dec 31 16:16:36 CST 2021\r
-VERSION_CODE=946\r
+#Fri Jan 07 20:10:29 CST 2022\r
+VERSION_CODE=947\r