Browse Source

涂鸦so 调试

zhangshenjie 2 months ago
parent
commit
baf70ec573

+ 2 - 1
BusinessCommon/src/main/java/com/develop/common/food_sdk/FloatWindowManager.kt

@@ -145,6 +145,7 @@ object FloatWindowManager {
 
     fun hideStepFlowWindow() {
         if (EasyFloat.isShow()) {
+            modeType = ""
             EasyFloat.dismiss()
         }
     }
@@ -152,7 +153,7 @@ object FloatWindowManager {
         return  EasyFloat.isShow()
     }
     fun isModeDiyShow() :Boolean{
-        return  isMode && (modeType=="ADAPTED_COOKING"||modeType=="AF_DIY") && isStepShow()
+        return  isMode && modeType !="" && isStepShow()
     }
     @Subscribe
     fun onDevStateEvent(event: DevStatusEvent) {

+ 129 - 0
BusinessCommon/src/main/java/com/develop/common/utils/CommonTuyaSoUtils.kt

@@ -0,0 +1,129 @@
+package com.develop.common.utils
+
+import android.os.Bundle
+import android.util.Log
+import com.blankj.utilcode.util.ToastUtils
+import com.develop.base.ext.appGlobalScope
+import com.develop.base.ext.globalApp
+import com.develop.base.ext.navigateTo
+import com.develop.base.util.AppActivityManager
+import com.develop.base.util.TopResumedAtyHolder
+import com.develop.base.util.TuyaEventEntity
+import com.develop.common.R
+import com.develop.common.data_repo.FoodDataProvider
+import com.develop.common.food_sdk.FloatWindowManager
+import com.develop.common.router.Screens
+import com.develop.common.tag.MODE_TYPE
+import com.develop.common.tag.NUMBER_TAG
+import com.develop.common.tag.SOURCE_TAG
+import com.google.gson.Gson
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevModes
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.WorkModes
+import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import org.greenrobot.eventbus.EventBus
+
+object CommonTuyaSoUtils {
+    var gson = Gson()
+    fun navigateToRemoteRecipe(number: String) {
+
+        if (CofarSDK.devInfo().runningStatus != DevStatus.STOP) {
+            EventBus.getDefault().post(TuyaEventEntity(recipeNumber = number, isType = 1))
+            return
+        }
+
+        //需要关闭的页面
+        for (activity in AppActivityManager.getInstance().activityList()) {
+            if (activity.localClassName.contains("CookDetailActivity")
+                || activity.localClassName.contains("CookStepActivity")
+                || activity.localClassName.contains("ModesDetailActivity")
+            ) {
+                activity.finish()
+            }
+        }
+
+
+
+
+        FoodDataProvider.getDatabase().recipeDao().apply {
+            var recipeNumber = number
+            if (recipeNumber.contains("@")) {
+                var (numbers, language) = recipeNumber.split("@")
+                recipeNumber = numbers
+            }
+
+
+            val recipeBean = queryRecipe(recipeNumber)
+            if (recipeBean != null) {
+
+                TopResumedAtyHolder.getCurrentActivity()?.navigateTo(Screens.Cook.COOK_DETAIL) {
+                    withString(
+                        SOURCE_TAG, "local"
+                    )
+                    withString(NUMBER_TAG, number)
+                }
+            } else {
+                TopResumedAtyHolder.getCurrentActivity()?.navigateTo(Screens.Cook.COOK_DETAIL) {
+                    withString(
+                        SOURCE_TAG, "remote"
+                    )
+                    withString(NUMBER_TAG, number)
+                }
+
+            }
+
+        }
+
+
+    }
+
+
+    fun navigateToAdaptedCooking(modeType: String) {
+        //判断设备是否正在运行,而还判断是否有挂起程序,挂起程序是否自动程序且还要是diy模式才可以重新进入ModeDetail页面
+        if (CofarSDK.devInfo().runningStatus != DevStatus.STOP && !FloatWindowManager.isModeDiyShow()) {
+            EventBus.getDefault().post(TuyaEventEntity(recipeNumber = "", isType = 0))
+            return
+        }
+        //当时测试有个BUG,料理机点击diy以后,手机没识别,然后手机点击diy模式,会导致程序崩溃,具体日志没看到什么东西,估在这多一个判断
+        //当前模式是diy,且当前页面是ModesDetailActivity的时候,return方法
+
+        // 新版涂鸦,如果当前页面是模式页面,且 runningInstId 和 modeType 对应上的话,return方法
+        if (CofarSDK.devInfo().runningInstId == modeType && AppActivityManager.getInstance().topActivity.localClassName.contains(
+                "ModesDetailActivity"
+            )
+        ) {
+            return
+        }
+
+        //需要关闭的页面
+        for (activity in AppActivityManager.getInstance().activityList()) {
+            if (activity.localClassName.contains("CookDetailActivity") || activity.localClassName.contains(
+                    "CookStepActivity"
+                ) || activity.localClassName.contains("ModesDetailActivity")
+            ) {
+
+                activity.finish()
+
+            }
+        }
+
+        val bundle = Bundle()
+        bundle.putString(MODE_TYPE, modeType)
+        bundle.putString("OP_MODE", "APP")
+        TopResumedAtyHolder.getCurrentActivity()?.navigateTo(Screens.Cook.COOK_MODES) {
+            with(bundle)
+        }
+
+
+    }
+
+    fun devReady(): Boolean {
+
+        return !CofarSDK.devInfo().isWeightStatus && CofarSDK.devInfo().runningStatus == DevStatus.STOP
+    }
+
+
+}

+ 24 - 3
BusinessCommon/src/main/java/com/develop/common/utils/TuyaApi.java

@@ -31,8 +31,19 @@ public interface TuyaApi extends Library {
     // 声明释放内存的方法
     void free_memory(Pointer ptr);
 
-    //
-    int send_dp();
+    //上传指令的 value方法
+    int send_dp_value(int dpid,int value);
+
+    //上传指令的 emun方法
+    int send_dp_enum(int dpid,int value);
+
+    //上传指令的 bool方法
+    int send_dp_bool(int dpid,int value);
+
+    //上传指令的 str方法
+    int send_dp_str(int dpid,String value);
+
+
     //打印日志
     void log_message(String tag, String message);
 
@@ -51,13 +62,23 @@ public interface TuyaApi extends Library {
 
     // 定义回调接口
     interface DpCallback extends Callback {
-        void invoke(byte dpid, byte type,int intValue,int enumValue,String strValue,int boolValue,int bitmapValue);
+        void invoke(int dpid, byte type,int intValue,int enumValue,String strValue,int boolValue,int bitmapValue);
     }
 
     // 注册日志回调函数
     void register_dp_callback(DpCallback callback);
 
 
+    // 定义回调接口
+    interface RestartCallback extends Callback {
+        void invoke();
+    }
+    // 注册日志回调函数
+    void restart_cofa_callback(RestartCallback callback);
+
+
+
+
 
 
 

+ 44 - 0
BusinessCommon/src/main/java/com/develop/common/utils/TuyaSoDp.java

@@ -0,0 +1,44 @@
+package com.develop.common.utils;
+
+public class TuyaSoDp {
+    public static final int ON_OFF = 1; //开关
+    public static final int START_STOP = 2; //启动/停止
+    public static final int AUTOMATIC_PROGRAM = 3; //自动程序
+    public static final int WORK_STATE = 5; //工作状态 (只上报)
+    public static final int COOKING_TEMPERATURE = 6; //烹饪温度
+    public static final int CURRENT_TEMPERATURE = 7; //当前温度  (只上报)
+    public static final int COOKING_TIME = 10; //烹饪时间
+    public static final int REMAINING_TIME = 11; //剩余时间  (只上报)
+    public static final int STEP_EXECUTION = 12; //多步骤执行
+    public static final int FAULT_WARNING = 13; //故障警告  (只上报)
+    public static final int PAUSE = 18; //暂停
+    public static final int TUYA_RECIPE = 22; //云食谱
+    public static final int COOKING_HISTORY = 23; //烹饪历史
+    public static final int CITRUS_JUICER = 101; //扭橙功能  (只上报)
+    public static final int WEIGHT = 102; //称重功能
+    public static final int SPEED = 103; //速度
+    public static final int REVERSIBLE = 104; //正反转
+    public static final int WEIGHT_CLEAR = 105; //称重清零
+    public static final int POT_STATUS = 106;//锅状态  (只上报)
+    public static final int WEIGHT_NUMBER = 107; //称重数据  (只上报)
+    public static final int DEV_READY = 110; //机器是否准备就绪
+    public static final int POT_CLOVER_STATUS = 111; //开盖状态  (只上报)
+    public static final int DEVICE_FUNCTION_MODE = 114; //设备功能模式
+    public static final int MAX_TIME = 119; // 时间设置最大值  (只上报)
+    public static final int MIN_TIME = 120; //时间设置最小值  (只上报)
+    public static final int MAX_TEMP = 121;//温度设置最大值  (只上报)
+    public static final int MIN_TEMP = 122; //温度设置最小值  (只上报)
+    public static final int MAX_MOTOR_GEAR = 123;//转速设置最大值  (只上报)
+    public static final int MIN_MOTOR_GEAR = 124; //转速设置最小值  (只上报)
+    public static final int CURRENT_RECIPE_NUMBER = 127;//当前菜谱编号
+    public static final int CURRENT_RECIPE_STEP = 128; //当前菜谱步骤
+    public static final int STEAM_SIZE = 129; //蒸汽量大小
+
+
+
+
+
+
+
+
+}

+ 324 - 13
BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

@@ -1,12 +1,23 @@
 package com.develop.common.utils;
 
 import android.content.Context;
+import android.os.PowerManager;
 import android.util.Log;
 
+import com.develop.base.util.AppActivityManager;
 import com.develop.base.util.MMkvUtils;
+import com.develop.common.bean.TuyaEvent;
 import com.develop.common.tuya_bean.TuyaQRUrlBean;
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevModes;
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.HeatModes;
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.MotorDirections;
+import com.kuyuntech.cofarcooking.device.sdk.devmode.core.BaseDevMode;
+import com.kuyuntech.cofarcooking.device.sdk.eventbus.core.DevInfo;
+import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK;
 import com.sun.jna.Pointer;
+import com.tuya.smartai.iot_sdk.DPEvent;
 
+import org.greenrobot.eventbus.EventBus;
 import org.json.JSONObject;
 
 public class TuyaUtilsSo {
@@ -78,33 +89,225 @@ public class TuyaUtilsSo {
         tuyaDp();
         tuyaLog();
         tuyaInit(getmPid(), getmUid(), getmAk(), version);
+        tuyaRestart();
     }
 
     public void tuyaInit(String pid, String uuid, String authkey, String version) {
         getTuyaApi().init(0, new String[]{}, pid, uuid, authkey, version);
     }
 
-    public  int  sendDp(){
-        return  getTuyaApi().send_dp();
-    }
 
+    //注销设备
     public void tuyaRemove() {
         getTuyaApi().example_soc_device_remove(0, new String[]{});
     }
 
 
-        TuyaApi.DpCallback dpCallback = new TuyaApi.DpCallback() {
+    //dp回调
+    TuyaApi.DpCallback dpCallback = new TuyaApi.DpCallback() {
+        public void invoke(int dpid, byte type, int intValue, int enumValue, String strValue, int boolValue, int bitmapValue) {
+            /**
+             * type 类型 0 对应着 boolValue ; 1 对应 intValue ,2 对应 strValue ,3 对应 enumValue ,4对应 bitmapValue
+             * */
+
+            /**
+             * -> 启动/停止  dpid = 2 ; type = 0 ,dp_bool:   1启动, 0关闭
+             * -> 自动程序   dpid = 3 ; type = 3 , dp_enum:   0 DIY,1 和面(Knead) ,2 蒸汽(Steam), 3 低温慢煮(Sous_vide) ,4 煮米饭(Rice) ,
+             *       5 搅碎(Chop) , 6 奶昔(Smoothie),7 称重(Weight) ,8 切丁(Dive), 9 去皮(Peeling) ,10 烧水(Boil_water),11 切丝切片 (Food_processor)
+             *      12 自动清洁(Auto_clean) ,13 预加热 (Preheating) , 14 间接性搅拌 (Intermittent_Stir) 15 警告 (Warning)
+             * -> 工作状态  dpid = 5 (只上报)     {”5“:”Stop“}
+             * -> 烹饪温度  dpid = 6 ;type = 1, dp_value :   6   温度度数
+             * -> 当前温度 dpid = 7   (只上报)  {”7“:88}
+             * -> 烹饪时间 dpid = 10 ;type = 1, dp_value :   5  时间(分钟)
+             * -> 剩余时间 dpid = 11 (只上报)   {”11“:3}
+             * -> 多步骤执行  dpid = 12    __soc_dev_raw_dp_cmd_cb 这个回调 暂时没完善  {”12“:"22"}
+             * ->故障警告   dpid = 13   (只上报)  {"13":123456}  只能数字
+             * -> 暂停   dpid = 18 ; type:0 ,dp_bool:1暂停 ,0没暂停
+             * ->云食谱  dpid = 22   __soc_dev_raw_dp_cmd_cb 这个回调   {”22“:"551234"}
+             * ->烹饪历史 dpid = 23  __soc_dev_raw_dp_cmd_cb 这个回调   {”23“:"casd"}
+             * -> 扭橙功能 dpid = 101 (只上报)  {"101":true}
+             * -> 称重功能 dpid  = 102  ;type = 0, dp_bool = 1 打开  0 关闭
+             * -> 速度 dpid = 103;type = 1, dp_value :   2 速度
+             * -> 正反转  dpid  = 104  ;type = 0, dp_bool = 1 打开  0 关闭
+             * -> 称重清零  dpid = 105 ;type = 0, dp_bool = 1 打开  0 关闭
+             * -> 锅状态 dpid = 106  (只上报)  {"106":1}
+             * -> 称重数据 dpid =107  (只上报)  {"107":2200}
+             * -> 机器是否就绪 dpid = 110 ;type = 1  ;dp_value: 1  具体不知道什么回事,看之前代码就是调用就跳DIY
+             * -> 开盖状态  dpid = 111  (只上报)  {"111":1}  锅盖状态
+             * -> 设备功能模式 dpid = 114 ; type = 2 ; dp_str:巴拉克   随便输入的
+             * -> 时间设置最大值 dpid 119 (只上报)  {"119":1}
+             * -> 时间设置最小值 dpid 120 (只上报)  {"120":0}
+             * -> 温度设置最大值 dpid 121 (只上报)  {"121":1}
+             * -> 温度设置最小值 dpid 122 (只上报)  {"122":0}
+             * -> 转速设置最大值 dpid 123 (只上报)  {"123":1}
+             * -> 转速设置最小值 dpid 124 (只上报)  {"124":0}
+             * -> 当前菜谱编号 dpid = 127  ; type = 2 ; dp_str:21321231   随便输入的
+             * -> 当前菜谱步骤 dpid = 128  ; type = 2 ; dp_str:3   随便输入的
+             * -> 蒸汽量大小  dpid = 129  ; type = 3 ; dp_enum: 0 high   1 mid   2 low
+             *
+             *
+             *
+             * **/
+
+
+            Log.i("tuya_iot", "dpCallback  dpid:" + dpid
+                    + " type:" + type + "  dp_value:" + intValue
+                    + "  dp_enum: " + enumValue + "   dp_str:" + strValue + " dp_bool:" + boolValue + "  dp_bitmap:" + bitmapValue);
+//            Log.v("tuya_iot","dpCallback");
+            switch (dpid) {
+                case TuyaSoDp.ON_OFF:
+                    break;
+                case TuyaSoDp.START_STOP:
+                    //启动/停止
+                    String str = boolValue == 1 ? "start" : "stop";
+                    tuyaEvent(str);
+                    break;
+                case TuyaSoDp.AUTOMATIC_PROGRAM:
+                    //自动程序
+                    getModes(enumValue);
+                    break;
+                case TuyaSoDp.COOKING_TEMPERATURE:
+                    //烹饪温度
+                    CofarSDK.cfgHeat((short) (int) intValue, HeatModes.PU_TONG);
+                    tuyaEvent("change_temp");
+
+                    break;
+                case TuyaSoDp.PAUSE:
+                    // 暂停
+                    String aa = "";
+                    if (boolValue == 1) {
+                        aa = "pause";
+                    } else {
+                        aa = "start";
+                    }
+                    tuyaEvent(aa);
+                    break;
+                case TuyaSoDp.COOKING_TIME:
+                    //烹饪时间
+                    CofarSDK.cfgTime((int) intValue);
+                    tuyaEvent("change_time");
+
+
+                    break;
+                case TuyaSoDp.WEIGHT:
+                    //称重功能
+
+                    break;
+                case TuyaSoDp.SPEED:
+                    //速度
+                    CofarSDK.cfgMotorGear((byte) ((int) intValue & 0xFF));
+                    break;
+                case TuyaSoDp.REVERSIBLE:
+                    //正反转
+                    CofarSDK.cfgMotorDirection((int) boolValue == 0 ? MotorDirections.FORWARD : MotorDirections.REVERSE);
+                    //按照以前的涂鸦,上面修改转向没有图标没有变动,估在发送一个eventbus
+                    tuyaEvent("change_direction");
+                    break;
+                case TuyaSoDp.WEIGHT_CLEAR:
+                    //称重清零
+
+                    break;
+                case TuyaSoDp.DEV_READY:
+                    //机器是否准备就绪 按照之前做法,这个回调是跳DIY
+
+                    break;
+
+            }
+        }
+    };
+
+    private void tuyaEvent(String type) {
+        TuyaEvent tuya = new TuyaEvent();
+        tuya.setType(type);
+        EventBus.getDefault().post(tuya);
+    }
+
+
+    private void getModes(int enumValue) {
+        /**
+         * 0 DIY,1 和面(Knead) ,2 蒸汽(Steam), 3 低温慢煮(Sous_vide) ,4 煮米饭(Rice) ,
+         * 5 搅碎(Chop) , 6 奶昔(Smoothie),7 称重(Weight) ,8 切丁(Dive), 9 去皮(Peeling) ,10 烧水(Boil_water),11 切丝切片 (Food_processor)
+         * 12 自动清洁(Auto_clean) ,13 预加热 (Preheating) , 14 间接性搅拌 (Intermittent_Stir) 15 警告 (Warning)
+         * */
+        String type = "";
+        switch (enumValue) {
+            case 0:
+                type = "ADAPTED_COOKING";
+                break;
+            case 1:
+                type = "KNEAD_TOUGH";
+                break;
+            case 2:
+                type = "STEAM";
+                break;
+            case 3:
+                type = "SOVS_VIDE";
+                break;
+            case 4:
+                type = "COOK_RICE";
+                break;
+            case 5:
+                type = "CHOP";
+                break;
+            case 6:
+                type = "SMOOTHIE";
+                break;
+            case 7:
+                type = "WIGHT";
+                break;
+            case 8:
+                type = "DICING";
+                break;
+            case 9:
+                type = "POTATO_PEELER";
+                break;
+            case 10:
+                type = "BOIL_WATER";
+                break;
+            case 11:
+                type = "FOOD_PROCESSOR";
+                break;
+            case 12:
+                type = "AUTO_CLEAN";
+                break;
+            case 13:
+                type = "SPECIAL_DIY_MODE";
+                break;
+            case 14:
+                type = "ROAST";
+                break;
+            case 15:
+                type = "ADAPTED_COOKING";
+                break;
+            default:
+                type = "ADAPTED_COOKING";
+                break;
+        }
+
+        CommonTuyaSoUtils.INSTANCE.navigateToAdaptedCooking(type);
+
+
+    }
+
+
+    public void tuyaDp() {
+        getTuyaApi().register_dp_callback(dpCallback);
+    }
 
+    public void tuyaRestart() {
+        getTuyaApi().restart_cofa_callback(restartCallback);
+    }
 
+    TuyaApi.RestartCallback restartCallback = new TuyaApi.RestartCallback() {
         @Override
-        public void invoke(byte dpid, byte type, int intValue, int enumValue, String strValue, int boolValue, int bitmapValue) {
-//            Log.i("tuya_iot", "dpCallback  dpid:"+dpid
-//                    + " type:"+type+"  time_stamp:"+time_stamp + "  dp_value:"+dp_value
-//                    + "  dp_enum: "+dp_enum+"   dp_str:"+dp_str + " dp_bool:"+dp_bool +"  dp_bitmap:"+dp_bitmap );
-            Log.v("tuya_iot","dpCallback");
+        public void invoke() {
+            PowerManager pm = (PowerManager) AppActivityManager.getInstance().getTopActivity().getSystemService(Context.POWER_SERVICE);
+            pm.reboot("");
         }
     };
 
+
+    //日志回调
     TuyaApi.LogCallback logCallback = new TuyaApi.LogCallback() {
         @Override
         public void invoke(String tag, String message) {
@@ -135,10 +338,6 @@ public class TuyaUtilsSo {
     };
 
 
-    public void tuyaDp() {
-        getTuyaApi().register_dp_callback(dpCallback);
-    }
-
     public void tuyaLog() {
         getTuyaApi().register_log_callback(logCallback);
     }
@@ -177,6 +376,118 @@ public class TuyaUtilsSo {
     }
 
 
+    public void uploadData() {
+        if (!tuyaNetwork) {
+            return;
+        }
+
+
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+            DevInfo info = CofarSDK.devInfo();
+            BaseDevMode mode = info.getMode();
+            //getStatus    0 stop  1 start  2 pause
+            int start_stop = info.getStatus() == 0 ? 0 : 1;   // 这里有个暂停,个人认为,暂停算是运行的一部分
+            int pause = info.getStatus() == 2 ? 1 : 0;
+            int pot_status = 0;
+            if (info.getDevMode().equals("SOUP")) {
+                pot_status = 0;
+            } else if (info.getDevMode().equals("AIR_FRYER")) {
+                pot_status = 1;
+            } else if (info.getDevMode().equals("STAND_MIXER")) {
+                pot_status = 3;
+            } else {
+                pot_status = 0;
+            }
+
+            DPEvent[] dpEvents = new DPEvent[]{
+                    new DPEvent(TuyaSoDp.ON_OFF, (byte) DPEvent.Type.PROP_BOOL, 1, 0),
+                    new DPEvent(TuyaSoDp.START_STOP, (byte) DPEvent.Type.PROP_BOOL, start_stop, 0),
+                    new DPEvent(TuyaSoDp.WORK_STATE, (byte) DPEvent.Type.PROP_ENUM, info.getStatus(), 0),
+                    new DPEvent(TuyaSoDp.COOKING_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, (int) (info.getTargetTempBuffer() != -1 ? info.getTargetTempBuffer() : info.getTargetTemp()), 0),
+                    new DPEvent(TuyaSoDp.CURRENT_TEMPERATURE, (byte) DPEvent.Type.PROP_VALUE, (int) CofarUtils.parseTemp(info.getTemp()), 0),
+                    new DPEvent(TuyaSoDp.COOKING_TIME, (byte) DPEvent.Type.PROP_VALUE, info.getTargetTimeBuffer() != -1 ? info.getTargetTimeBuffer() : info.getTargetTime(), 0),
+                    new DPEvent(TuyaSoDp.REMAINING_TIME, (byte) DPEvent.Type.PROP_VALUE, info.getRemainTime(), 0),
+                    new DPEvent(TuyaSoDp.PAUSE, (byte) DPEvent.Type.PROP_BOOL, pause, 0),
+                    new DPEvent(TuyaSoDp.SPEED, (byte) DPEvent.Type.PROP_VALUE, (int) (info.getMotorGearBuffer() != -1 ? info.getMotorGearBuffer() : info.getMotorGear()), 0),
+                    new DPEvent(TuyaSoDp.REVERSIBLE, (byte) DPEvent.Type.PROP_BOOL, (int) (info.getMotorDirectionBuffer() != -1 ? info.getMotorDirectionBuffer() : info.getMotorDirection()), 0),
+                    new DPEvent(TuyaSoDp.POT_STATUS, (byte) DPEvent.Type.PROP_VALUE, pot_status, 0),
+                    new DPEvent(TuyaSoDp.WEIGHT_NUMBER, (byte) DPEvent.Type.PROP_VALUE, info.getWeight(), 0),
+                    new DPEvent(TuyaSoDp.POT_CLOVER_STATUS, (byte) DPEvent.Type.PROP_VALUE, (int) info.getPotCloverStatus(), 0),
+                    new DPEvent(TuyaSoDp.MAX_TIME, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxTime(), 0),
+                    new DPEvent(TuyaSoDp.MIN_TIME, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinTime(), 0),
+                    new DPEvent(TuyaSoDp.MAX_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxTemp(), 0),
+                    new DPEvent(TuyaSoDp.MIN_TEMP, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinTemp(), 0),
+                    new DPEvent(TuyaSoDp.MAX_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMaxMotorGear(), 0),
+                    new DPEvent(TuyaSoDp.MIN_MOTOR_GEAR, (byte) DPEvent.Type.PROP_VALUE, mode == null ? 0 : mode.getMinMotorGear(), 0)
+            };
+
+
+            //上报指令
+            for (DPEvent event : dpEvents) {
+                int value = -1;
+                Object eventValue = event.value;
+                if (eventValue instanceof Short) {
+                    Short shortValue = (Short) eventValue;
+                    value = shortValue.intValue();
+                } else if (eventValue instanceof Integer) {
+                    value = (int) eventValue;
+                } else if (eventValue instanceof Byte) {
+                    Byte byteValue = (Byte) eventValue;
+                    value = byteValue.intValue();
+                } else {
+                    value = (int) eventValue;
+                }
+
+                if (event.type == DPEvent.Type.PROP_BOOL) {
+                    getTuyaApi().send_dp_bool(event.dpid, value);
+                }
+                if (event.type == DPEvent.Type.PROP_VALUE) {
+                    getTuyaApi().send_dp_value(event.dpid, value);
+                }
+                if (event.type == DPEvent.Type.PROP_STR) {
+                    getTuyaApi().send_dp_str(event.dpid, String.valueOf(value));
+                }
+                if (event.type == DPEvent.Type.PROP_ENUM) {
+                    getTuyaApi().send_dp_enum(event.dpid, value);
+                }
+
+            }
+            }
+        });
+//        ioTSDKManager.sendDP(dpEvents);
+    }
+
+    public void sendDpEnum(int dpid,int value){
+        getTuyaApi().send_dp_enum(dpid, value);
+    }
+    public void sendDpStr(int dpid,String value){
+        getTuyaApi().send_dp_str(dpid, value);
+    }
+    public void sendDpValue(int dpid,int value){
+        getTuyaApi().send_dp_value(dpid, value);
+    }
+    public void sendDpBool(int dpid,int value){
+        getTuyaApi().send_dp_bool(dpid, value);
+    }
+
+
+
+    public Integer parse(int e) {
+
+        if (e <= 0) {
+            return 0;
+        }
+
+        StringBuilder a = new StringBuilder("1");
+        for (int i = 0; i < e - 1; i++) {
+            a.append("0");
+        }
+        return Integer.parseInt(a.toString(), 2);
+    }
+
+
     public void appendFile(String filename, String string) {
         getTuyaApi().append_log_to_file(filename, string);
 

+ 3 - 0
BusinessMain/src/main/java/com/develop/main/ui/ModesFragment.kt

@@ -401,6 +401,9 @@ class  ModesFragment : CommonBVMFragment<FragmentModesBinding, HomeViewModel>()
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     fun onDevStateEvent(event: DevStatusEvent) {
+        Log.d("TAG Fragment", "DevStateEvent:" + event.devInfo.toString())
+
+
         //当没有锅得时候,默认是汤锅模式 //切当前Fragment可见状态 // 只针对5037的处理 5067处理
         //potStatus 锅状态, 无锅 1 ,有锅 0
         if ((isModelNum == "5037"|| isModelNum == "5067") && isVisible&& isResumed && event.devInfo.potStatus.toInt() == 1) {

+ 37 - 9
BusinessSetting/src/main/java/com/develop/setting/ui/AboutActivity.kt

@@ -67,6 +67,7 @@ import com.develop.common.utils.AppVersionUtil
 import com.develop.common.utils.CommonUtils
 import com.develop.common.utils.GsonUtils
 import com.develop.common.utils.StringUtils
+import com.develop.common.utils.TuyaSoDp
 import com.develop.common.utils.TuyaUtils
 import com.develop.common.utils.TuyaUtilsSo
 import com.develop.common.utils.UpdateUtil
@@ -398,7 +399,7 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
 
 
         binding.ivLogo.setOnClickListener {
-
+            getSendDpValue()
 //            pageSize++
             getCook("2159212")
 
@@ -483,8 +484,9 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
         }
 
         binding.tvAppVersion.setOnClickListener {
+            getSendDpBool()
 
-            getCook("1894212")
+//            getCook("1894212")
 
 
             adbCount++
@@ -501,6 +503,8 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
         binding.tvFirmware.setOnClickListener {
 //            getappLog()
 
+            getSendDpStr()
+
             tpCount++
             if (tpCount >= 7) {
                 tpCount = 0
@@ -518,7 +522,10 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
 
 
         binding.devSn.setOnClickListener {
-            getCook("1891512")
+
+            getSendDpEmun()
+
+//            getCook("1891512")
 
 
             testCount++
@@ -575,12 +582,6 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
 
     }
     fun getCook(number : String){
-
-       var sd =  TuyaUtilsSo.getInstance().sendDp();
-
-
-        return
-
         var lang = MMkvUtils.getString(CURRENT_LANGUAGE) ?: "en"
 
         var map = HashMap<String, Any>()
@@ -604,6 +605,33 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
 
     }
 
+    var onoff = 0
+    fun getSendDpBool(){
+        if (onoff==0){
+            onoff==1
+        }else{
+            onoff = 0
+        }
+
+        TuyaUtilsSo.getInstance().sendDpBool(TuyaSoDp.START_STOP,onoff)
+    }
+
+    var str = 1
+    fun getSendDpStr(){
+        TuyaUtilsSo.getInstance().sendDpStr(TuyaSoDp.SPEED,str.toString())
+        str ++
+    }
+
+    var emun = 0
+    fun getSendDpEmun(){
+        TuyaUtilsSo.getInstance().sendDpEnum(TuyaSoDp.AUTOMATIC_PROGRAM,str)
+        emun ++
+    }
+
+    fun getSendDpValue(){
+        TuyaUtilsSo.getInstance().sendDpValue(TuyaSoDp.AUTOMATIC_PROGRAM,str)
+        emun ++
+    }
 
 
     fun getappLog() {

+ 22 - 1
BusinessStep/src/main/java/com/develop/step/ui/ModesDetailActivity.kt

@@ -761,6 +761,27 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
             }, 500)
 
         }
+        if ("change_direction"== event.type){
+
+            ThreadUtils.runOnMainThread({
+                binding.clCookDirection.updateChangeValue(
+                    viewModel.getDirectionStr(
+                        currDevInfo.motorDirection.toInt() == MotorDirections.REVERSE.toInt(), resources
+                    )
+                )
+                binding.flDirection.updateDirectionView(
+                    if (currDevInfo.motorDirection.toInt()  == MotorDirections.FORWARD.toInt()) DirectionView.Direction.RIGHT
+                    else DirectionView.Direction.LEFT
+                )
+
+            }, 500)
+
+
+
+        }
+
+
+
 
 
     }
@@ -880,7 +901,7 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
             return
         }
 
-//        Log.d("TAG DevStateEvent", "event:" + event.devInfo.toString())
+        Log.d("TAG ModeActivity", "DevStateEvent:" + event.devInfo.toString())
 
 
         //由于sdk没有判断E7到E16 需要判断运行和暂停过程中,设备发生故障弹出窗口告知故障

+ 3 - 2
app/src/main/java/com/develop/foodcooking/FoodCookingApp.kt

@@ -44,6 +44,7 @@ import com.develop.common.tag.MODEL
 import com.develop.common.utils.AppVersionUtil
 import com.develop.common.utils.StringUtils
 import com.develop.common.utils.TuyaUtils
+import com.develop.common.utils.TuyaUtilsSo
 import com.develop.common.utils.compat.RecyclerViewCompat
 import com.develop.common.utils.compat.ShapeableImageViewCompat
 import com.develop.common.utils.compat.SmartRefreshLayoutCompat
@@ -373,7 +374,7 @@ class FoodCookingApp : BaseApp() {
     @Subscribe
     fun onTuyaEvent(event: TuyaEvent) {
 
-        TuyaUtils.uploadData()
+        TuyaUtilsSo.getInstance().uploadData()
         heartBeatInterval?.cancel()
         val pm = getSystemService(POWER_SERVICE) as PowerManager
 
@@ -405,7 +406,7 @@ class FoodCookingApp : BaseApp() {
     @Subscribe
     @Synchronized
     fun globalCoverEvent(event: DevStatusEvent) {
-        TuyaUtils.uploadData()
+        TuyaUtilsSo.getInstance().uploadData()
         heartBeatInterval?.cancel()
         val devInfo = event.devInfo;
         val pm = getSystemService(POWER_SERVICE) as PowerManager

BIN
app/src/main/jniLibs/arm64-v8a/libtuya_api.so


BIN
app/src/main/jniLibs/armeabi-v7a/libtuya_api.so