Jelajahi Sumber

3015涂鸦移植

wbspool 1 tahun lalu
induk
melakukan
9477b3bc87
25 mengubah file dengan 1269 tambahan dan 50 penghapusan
  1. 1 0
      BusinessSetting/src/main/AndroidManifest.xml
  2. 29 0
      BusinessSetting/src/main/java/com/develop/setting/init/ui/SettingMainActivity.kt
  3. 71 0
      BusinessSetting/src/main/java/com/develop/setting/init/ui/TuyaActivity.kt
  4. 122 9
      BusinessStep/src/main/java/com/develop/step/modes/ModesDetailActivity.kt
  5. 7 1
      app/build.gradle
  6. 254 0
      app/src/main/assets/tuya_config.json
  7. 55 35
      app/src/main/java/com/develop/foodcooking/FoodCookApp.kt
  8. 9 1
      app/src/main/java/com/develop/foodcooking/MainActivity.kt
  9. 1 0
      libBase/src/main/AndroidManifest.xml
  10. 10 1
      libBase/src/main/java/com/develop/food/base/data/DataFactory.kt
  11. 1 0
      libBase/src/main/java/com/develop/food/base/router/Screens.kt
  12. 3 0
      libBase/src/main/java/com/develop/food/base/utils/CfConfig.kt
  13. 54 0
      libBase/src/main/java/com/develop/food/base/utils/CommonTag.kt
  14. 118 0
      libBase/src/main/java/com/develop/food/base/utils/CommonUtils.kt
  15. 66 2
      libBase/src/main/java/com/develop/food/base/utils/ConfigUtils.kt
  16. 1 1
      libBase/src/main/java/com/develop/food/base/utils/GlobalExt.kt
  17. 49 0
      libBase/src/main/java/com/develop/food/base/utils/TopResumedAtyHolder.kt
  18. 4 0
      libBase/src/main/java/com/develop/food/base/utils/TuyaConfig.kt
  19. 33 0
      libBase/src/main/java/com/develop/food/base/utils/TuyaDps.java
  20. 46 0
      libBase/src/main/java/com/develop/food/base/utils/TuyaEvent.java
  21. 315 0
      libBase/src/main/java/com/develop/food/base/utils/TuyaUtils.java
  22. 3 0
      libBase/src/main/java/com/develop/food/base/utils/WorkMode.kt
  23. 2 0
      libBase/src/main/res/values/strings.xml
  24. 9 0
      libThirdParty/build.gradle
  25. 6 0
      settings.gradle

+ 1 - 0
BusinessSetting/src/main/AndroidManifest.xml

@@ -35,6 +35,7 @@
         </activity>
         <activity android:name=".init.ui.BrightnessActivity" />
         <activity android:name=".init.ui.SoundActivity" />
+        <activity android:name=".init.ui.TuyaActivity" />
         <activity android:name=".init.ui.AboutActivity" />
         <activity android:name=".init.ui.RestoreActivity" />
     </application>

+ 29 - 0
BusinessSetting/src/main/java/com/develop/setting/init/ui/SettingMainActivity.kt

@@ -2,18 +2,21 @@ package com.develop.setting.init.ui
 
 import android.content.Intent
 import android.graphics.Rect
+import android.net.NetworkInfo
 import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.View
 import androidx.recyclerview.widget.GridLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import com.alibaba.android.arouter.facade.annotation.Route
+import com.blankj.utilcode.util.ToastUtils
 import com.blankj.utilcode.util.UriUtils
 import com.blankj.utilcode.util.UtilsFileProvider
 import com.develop.food.base.common.LANGUAGE_FROM_SETTING
 import com.develop.food.base.common.WIFI_FROM_MAIN_SETTING
 import com.develop.food.base.data.DataFactory
 import com.develop.food.base.data.SettingType
+import com.develop.food.base.manager.wifi.WifiHelp
 import com.develop.food.base.router.Screens
 import com.develop.food.base.router.navigateTo
 import com.develop.food.base.ui.BaseActivity
@@ -22,6 +25,8 @@ import com.develop.food.base.utils.ResDimension
 import com.develop.setting.R
 import com.develop.setting.databinding.ActivitySettingMainBinding
 import com.develop.setting.init.adapter.SettingMainAdapter
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus
+import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
 
 
 @Route(path = Screens.Setting.MAIN_SETTING)
@@ -33,6 +38,8 @@ class SettingMainActivity : BaseActivity<ActivitySettingMainBinding>() {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
+        var ctx = this
+
         binding.topBar.setTopBarTitle(getString(R.string.settings))
         binding.topBar.listenBackClick {
             finish()
@@ -104,6 +111,28 @@ class SettingMainActivity : BaseActivity<ActivitySettingMainBinding>() {
                 }
                 SettingType.STORAGE -> {
                     openFileManager()
+                }
+                SettingType.TUYA -> {
+
+                    if(CofarSDK.devInfo().status !== DevStatus.STOP.toInt()){
+                        ToastUtils.showShort(getString(R.string.change_lang_tips))
+                    }else{
+                        if( NetworkInfo.DetailedState.CONNECTED == WifiHelp.Build(ctx).build().getDetailedState()){
+                            navigateTo(Screens.Setting.TUYA)
+
+                        }else{
+                            navigateTo(Screens.Setting.WIFI) {
+                                val bundle = Bundle()
+                                bundle.putBoolean(WIFI_FROM_MAIN_SETTING, true)
+                                with(bundle)
+                            }
+                        }
+                    }
+
+
+
+
+
                 }
             }
         }

+ 71 - 0
BusinessSetting/src/main/java/com/develop/setting/init/ui/TuyaActivity.kt

@@ -0,0 +1,71 @@
+package com.develop.setting.init.ui
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import com.alibaba.android.arouter.facade.annotation.Route
+
+import com.develop.food.base.router.Screens
+import com.develop.food.base.ui.BaseActivity
+import com.develop.food.base.utils.QRCodeUtils
+import com.develop.food.base.utils.ThreadUtils
+import com.develop.food.base.utils.TuyaUtils
+import com.develop.food.base.utils.updateText
+import com.develop.setting.R
+import com.develop.setting.databinding.ActivityTuyaBinding
+import com.tuya.smartai.iot_sdk.*
+
+import org.greenrobot.eventbus.Subscribe
+
+
+@Route(path = Screens.Setting.TUYA)
+class TuyaActivity : BaseActivity<ActivityTuyaBinding>() {
+
+    private val TAG = "TUYA"
+
+    var mPid: String? = "dquk8axtyy72c1ap"
+    var mUid: String? = "uuid50e9e0c707553116"
+    var mAk: String? = "MJhcxmQ6LeZDj1tNu6F5kqK5aQJfpdOb"
+
+    var ioTSDKManager: IoTSDKManager? = null
+
+
+    override fun createViewBinding(inflater: LayoutInflater):ActivityTuyaBinding {
+        return ActivityTuyaBinding.inflate(layoutInflater)
+    }
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+
+        super.onCreate(savedInstanceState)
+        binding.topBar.setTopBarTitle(getString(R.string.tuya))
+        binding.topBar.listenBackClick {
+            finish()
+        }
+
+
+        if(TuyaUtils.qrcodeUrl != "" && !TuyaUtils.init){
+            ThreadUtils.runOnMainThread {
+                val bitmap = QRCodeUtils.createQRCodeBitmap(TuyaUtils.qrcodeUrl, 500, 500)
+                binding.tuyaQrcode.setImageBitmap(bitmap)
+                binding.tuyaQrcode.visibility = View.VISIBLE
+            }
+        }else{
+                binding.cancelWrapper.visibility = View.VISIBLE
+                binding.cancelBtn.setOnClickListener{
+                    TuyaUtils.cancelBind()
+                }
+        }
+
+
+    }
+
+
+    @Subscribe
+    fun onTuyaStateChange(event:TuyaUtils){
+        println("adasdasd")
+    }
+
+
+
+
+}

+ 122 - 9
BusinessStep/src/main/java/com/develop/step/modes/ModesDetailActivity.kt

@@ -20,11 +20,7 @@ import com.develop.food.base.ext.background_drawable
 import com.develop.food.base.manager.FloatWindowManager
 import com.develop.food.base.router.Screens
 import com.develop.food.base.ui.BaseActivity
-import com.develop.food.base.utils.CofarUtils
-import com.develop.food.base.utils.GlobalApp
-import com.develop.food.base.utils.ThreadUtils
-import com.develop.food.base.utils.isNightTheme
-import com.develop.food.base.utils.resId2Dimension
+import com.develop.food.base.utils.*
 import com.develop.food.base.widgets.CancelConfirmDialog
 import com.develop.food.base.widgets.DirectionView
 import com.develop.food.base.widgets.TimePickerView
@@ -467,6 +463,121 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
     }
 
 
+    @Subscribe
+    fun onTuyaEvent(event: TuyaEvent){
+
+        if("start" == event.type){
+            if(DevStatus.PAUSE.toInt() == CofarSDK.devInfo().status){
+                CofarSDK.confirm()
+                resumeClick()
+            }else{
+                startClick(false)
+            }
+        }
+
+        if("stop" == event.type){
+            stopClick(false)
+        }
+
+        if("pause" == event.type){
+            pauseClick()
+        }
+
+
+        if("change_time" == event.type){
+
+            ThreadUtils.runOnMainThread {
+                //当前调节时间
+                var targetTime = currDevInfo.targetTime
+                if (currDevInfo.remainTime != 0) {
+                    targetTime = currDevInfo.remainTime
+                }
+                if (currDevInfo.targetTimeBuffer != -1) {
+                    targetTime = currDevInfo.targetTimeBuffer
+                }
+
+
+                if (targetTime < 0) {
+                    targetTime = 0;
+                }
+                if (targetTime > currDevInfo.mode.maxTime) {
+                    targetTime = currDevInfo.mode.maxTime
+                }
+                if (targetTime < currDevInfo.mode.minTime) {
+                    targetTime = currDevInfo.mode.minTime
+                }
+                val sec = targetTime % 60
+                val min = ((targetTime / 60) % 60)
+                val hour = (targetTime / 3600)
+                var time = ""
+                if (hour > 0) {
+                    time += if (hour < 10) {
+                        "0${hour}"
+                    } else {
+                        "$hour"
+                    }
+
+                    time += if (min < 10) {
+                        ":0${min}"
+                    } else {
+                        ":${min}"
+                    }
+                } else {
+                    time += if (min < 10) {
+                        "0${min}"
+                    } else {
+                        "$min"
+                    }
+
+                    time += if (sec < 10) {
+                        ":0${sec}"
+                    } else {
+                        ":${sec}"
+                    }
+                }
+                rollTimeEvent(hour, min, sec, time, setByUser = true)
+                currDevInfo.apply {
+                    updateTimeUI(
+                        mode.minTime,
+                        mode.maxTime,
+                        remainTime,
+                        targetTime.toLong(),
+                        true
+                    )
+                }
+                binding.clSetTime.setTimeInternal(
+                    hour,
+                    min,
+                    sec,
+                    changeSetting = true,
+                    setByUser = true
+                )
+            }
+
+        }
+
+
+        if("change_temp" == event.type){
+
+            ThreadUtils.runOnMainThread ({
+                updateTempUI(
+                    minTemp.toFloat(),
+                    maxTemp.toFloat(),
+                    if (currDevInfo.status == DevStatus.STOP.toInt()) currDevInfo.targetTemp.toInt()
+                    else currDevInfo.temp.toInt(),
+                    if (currDevInfo.targetTempBuffer.toInt() != -1 ) currDevInfo.targetTempBuffer.toString() else currDevInfo.targetTemp.toString(),
+                    isTempChange,
+                    focusUpdate = true
+                )
+            },500)
+
+        }
+
+
+
+    }
+
+
     @Subscribe
     fun onDevCommonEvent(event: DevCommonEvent) {
 
@@ -1314,14 +1425,16 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
     /**
      * 点击开始操作
      */
-    private fun startClick() {
+    private fun startClick(showStopTips:Boolean=true) {
         if (mRunningInstId != mSettingInstId) {
             overrideModeDialog.showDialog(supportFragmentManager, "overrideModeDialog")
         } else {
             userChanging = false
             CofarSDK.cancel()
             CofarSDK.devInfo().runningRecipeId = null
-            CofarSDK.start(modeType)
+            var startConfig = HashMap<String, Any>()
+            startConfig.put("stopTips",showStopTips)
+            CofarSDK.startWithConfig(modeType,startConfig)
             whereIndex = -1
             binding.clSetTime.stopAlphaAnim()
         }
@@ -1363,10 +1476,10 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
     /**
      * 点击停止操作
      */
-    private fun stopClick() {
+    private fun stopClick(tips:Boolean = true) {
         userChanging = false
         //结束
-        CofarSDK.stop()
+        CofarSDK.stop(tips)
         //TODO 崩溃?
         try {
             FloatWindowManager.hideStepFlowWindow()

+ 7 - 1
app/build.gradle

@@ -23,7 +23,7 @@ static  int formatTime() {
 
 ext{
      versionCode=Integer.parseInt(new SimpleDateFormat("yyMMddHH").format(new Date()) + 1)
-     brandCode="034A"
+     brandCode="000A"
      brandVersionCode=versionCode
      model="3015"
 }
@@ -51,6 +51,12 @@ android {
                 arg("room.schemaLocation", "$projectDir/schemas".toString())
             }
         }
+
+        packagingOptions {
+            pickFirst 'lib/armeabi-v7a/libc++_shared.so'
+
+        }
+
     }
 
     flavorDimensions "platform"

+ 254 - 0
app/src/main/assets/tuya_config.json

@@ -0,0 +1,254 @@
+{
+  "licences": {
+    "010D10390020123010100032": {
+      "pid": "dquk8axtyy72c1ap",
+      "uid": "uuid50e9e0c707553116",
+      "ak": "MJhcxmQ6LeZDj1tNu6F5kqK5aQJfpdOb"
+    },
+    "036I21060020123010190004": {
+      "pid": "dquk8axtyy72c1ap",
+      "uid": "uuid168073f63512a624",
+      "ak": "0En6WmDAuDg5NLCJoRNtvB0KkwuxTkhc"
+    },
+    "036I21060020123010190003": {
+      "pid": "dquk8axtyy72c1ap",
+      "uid": "uuid27a0577cc7eeb9b3",
+      "ak": "TAfnHpfr6AeVxYBsGrAfPE3oVwlslH1l"
+    },
+    "036I21060020123010190001": {
+      "pid": "dquk8axtyy72c1ap",
+      "uid": "uuid7893db2e701b853b",
+      "ak": "nlJdxC119wB2r36kxjWjZWSlEEm5Z4DA"
+    },
+    "036I21060020123010190002": {
+      "pid": "dquk8axtyy72c1ap",
+      "uid": "uuid0686e96fe0e49ef4",
+      "ak": "Vvys7wDcOiOeSpAmSCzI0jgB5g7cXr5W"
+    },
+    "011A10390020123010190001": {
+      "pid": "qgdd3xgte8ia75pp",
+      "uid": "uuidcfb66c9f9dcea3dc",
+      "ak": "kKjmiFklQUJxTtfX6gb0HvAIzhLSQwZQ"
+    },
+    "011A10390020123010190004": {
+      "pid": "qgdd3xgte8ia75pp",
+      "uid": "uuidf6bdce9208626720",
+      "ak": "ojPkHIyzW0h0RBVd9zR91krSH6kD4Bq3"
+    },
+    "011A10390020123010190005": {
+      "pid": "qgdd3xgte8ia75pp",
+      "uid": "uuid7752936117877258",
+      "ak": "JuiAfRuH9mPzdLnxQax0A5lR1M15krtb"
+    },
+    "011A10390020123010190006": {
+      "pid": "qgdd3xgte8ia75pp",
+      "uid": "uuid3e8a0406eeb6a1d7",
+      "ak": "lJ7am8gTa2aHrInhXFcSKKVLCm7xMFlH"
+    },
+    "030A10390020123010190001": {
+      "pid": "9op3u0wpf50gbin0",
+      "uid": "uuid87fc4bde71569018",
+      "ak": "snLULDmG12PuGQvl0Y3th86oF1HOnpLf"
+    },
+    "030A10390020123010190002": {
+      "pid": "9op3u0wpf50gbin0",
+      "uid": "uuidf0a1752601f29ce1",
+      "ak": "TIgWTYpAXf8CyiMHCafiFADRm3s97bKI"
+    },
+    "030A10390020123010190003": {
+      "pid": "9op3u0wpf50gbin0",
+      "uid": "uuida901ffc0e9dc637e",
+      "ak": "qj0hVrEnR8qjlr0xmTXf8vdDsVZdxhGz"
+    },
+    "030A10390020123010190004": {
+      "pid": "9op3u0wpf50gbin0",
+      "uid": "uuid45d0dc7820ff91f5",
+      "ak": "WGIlOwvp9VrkBAt5H1z5XvUoGXNjElb7"
+    },
+    "017A20060020123010190001": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuida6f0aa9ac519d121",
+      "ak": "X9Qg32ARni4HjY36AjZByNHHiyiKGp7q"
+    },
+    "017A20060020123010190002": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuida614de446b1ee366",
+      "ak": "AfqDVCmksePcSHyA9eZ9TBcxHMuxQ8xy"
+    },
+    "017A10390020123010190001": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuiddf8c180889b237d4",
+      "ak": "Fazjbb1E7A9pOqb02qj1bbI2rypQPHgo"
+    },
+    "017A10390020123010190002": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuid423714ed76e17194",
+      "ak": "68P4KEAu6ucwxO5xraPoVJjbm0VdaAAm"
+    },
+    "017A21030020123010190001": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuidcce2542317a42ace",
+      "ak": "ZdJhs7kOnrPuyGzI9MfbjAviXLwGZ3u5"
+    },
+    "017A21030020123010190002": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuid3f941111a707d913",
+      "ak": "8WnDXx4RGSPDkYHeSXK42SjuOd0olJcp"
+    },
+    "017A21030020123010190003": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuid4ea902d217a5214b",
+      "ak": "JOEhiBCU7Y0hjGXzQeKT65tUctavCrXl"
+    },
+    "017A21030020123010190004": {
+      "pid": "ley4mnr5nqmtyq6e",
+      "uid": "uuidd66ed40536890f70",
+      "ak": "7hEDpBi08283FeoK1tL2SfTf9ZjLVXeZ"
+    },
+    "000A10390020123010190009": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuide834ae3a35c85891",
+      "ak": "ARhlijghAQJFVDsAbTKbNxe9RgLDAR5b"
+    },
+    "000A10390020123010190010": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuidcc01214733d60dec",
+      "ak": "d8VA2BnPgQoHJL98UcSzMrATvYmFjnck"
+    },
+    "000A10390020123010190011": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid1a3173102ec7297d",
+      "ak": "WwRyqI7dPt5ymWwEEgDfpj7qDHxuavvW"
+    },
+    "000A10390020123010190012": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuiddc725f67a649312d",
+      "ak": "wXJYOjFRWWkmVEOyd5OdXOAatTo0be1R"
+    },
+    "000A10390020123010190013": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid9a548bc824c5e2b9",
+      "ak": "rxR958Jqu5amgXvGLcpgJG6OFIwLEPaj"
+    },
+    "000A20080020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuide4ebd69311eab54e",
+      "ak": "96cTOSOPxvvcExlyJJe7NrkLaucr0As2"
+    },
+    "000A21010020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid61a37ca17e67cbc3",
+      "ak": "IYWpO8bAQSXbvNieoLIQLcOyBV3dHDQu"
+    },
+    "000A21010020123010190002": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuidc6356e02d0dd1bb8",
+      "ak": "AA99M0iNYx0m7oQjvTufuWGg5VLX6kez"
+    },
+    "000A21010020123010190003": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuidb99c97f880409aae",
+      "ak": "SvJO9yi31ExNXnyE77caaCtFZCVri2L7"
+    },
+    "000A20010020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuide4ebd69311eab54e",
+      "ak": "96cTOSOPxvvcExlyJJe7NrkLaucr0As2"
+    },
+    "000A21020020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid536f6d347c683f57",
+      "ak": "AwIWCkr5a8ECMfYy3xaJW1KIsRlOfmP4"
+    },
+    "000A20020020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid695298970165f5de",
+      "ak": "eWzAbm8DZv92F567nWhuedSUzcc9FJVv"
+    },
+    "000A21050020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuidccfcbea39afd9db7",
+      "ak": "AsixolEhGRMlREnmEBcAsjoDtbFSJj0Q"
+    },
+    "000A21050020123010190002": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuideb52df92e83c3af1",
+      "ak": "OnWBbmXp4TCIotAXJBie8dCPr0tWNyoK"
+    },
+    "000A10590020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid903f6fec79d1eb6c",
+      "ak": "EeAAuxIZ9BlSq3gi7vuJ2QqSmsiRMeOU"
+    },
+    "000A10590020123010190002": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid50491cb0667dddad",
+      "ak": "uxBrNdezj5T9kD3AMWjBehvfVpRWmlwU"
+    },
+    "000A10590020123010190003": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuidf49bd4b6f57750c7",
+      "ak": "l7K3bjZMgNtAt9EA5PAOUapDMlNEjUZD"
+    },
+    "000A50370020123010190004": {
+      "pid": "as3ox9yav2atavax",
+      "uid": "uuid631374afce4623be",
+      "ak": "2ruoU36UAeJRHvum5DGUno7ndYgTq59U"
+    },
+    "000A50370020123010190005": {
+      "pid": "as3ox9yav2atavax",
+      "uid": "uuidac8a5cf8224a59e3",
+      "ak": "A3rA6eguEINAo1NEjmd3onsemJns90e9"
+    },
+    "011A50370020123010190001": {
+      "pid": "o0qxz32qigce6kpk",
+      "uid": "uuid6031dc53e68fcf7c",
+      "ak": "n2lSnzW5JzShsqHlwgNeVZwAKKu66Vvo"
+    },
+    "000A50370020123010190007": {
+      "pid": "as3ox9yav2atavax",
+      "uid": "uuide83b2f327a3a4511",
+      "ak": "0bJ4Rmy3P3OSrb74ah13c2MEVANI0SNb"
+    },
+    "000A50370020123010190008": {
+      "pid": "as3ox9yav2atavax",
+      "uid": "uuid3b0f5831c50a60f2",
+      "ak": "8DolWLYhmoED0jaGp1H69pZ1NS2ksxrx"
+    },
+    "011A50370020123010190002": {
+      "pid": "o0qxz32qigce6kpk",
+      "uid": "uuid1ed716f65a8fc8c6",
+      "ak": "TliIl48lle7GbMB2MCjrvWDknjH4guo9"
+    },
+    "045A50370020123010190001": {
+      "pid": "lozjriuxwhwpaz4k",
+      "uid": "uuid68716791437c5329",
+      "ak": "qcz27dPBLo82sgvbZpmwuVmZxheKrtzk"
+    },
+    "045A50370020123010190002": {
+      "pid": "lozjriuxwhwpaz4k",
+      "uid": "uuiddd1bf831a6aecfae",
+      "ak": "ko3JgbIIFmiNHyD7sPPq4jYyeycrbB6t"
+    },
+    "029C21010020123010190001": {
+      "pid": "vowpjhiaj5tyv2rd",
+      "uid": "uuidce031f7e9f636843",
+      "ak": "WxPYNPoBopk4EkMLd9QViOpAAIshqeuf"
+    },
+    "029C21010020123010190002": {
+      "pid": "vowpjhiaj5tyv2rd",
+      "uid": "uuid5c221a4957ad2f69",
+      "ak": "ysx7mZoKndu12lNAqABH8AP31yW3Iv8v"
+    },
+    "000A30150020123010190001": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid3a0b274f5edbc38b",
+      "ak": "2wGAsGNRzAsTlL8x3qgxmP46DC6p2K8Y"
+    },
+    "000A30150020123010190002": {
+      "pid": "wy8ogbhchnzkmrup",
+      "uid": "uuid9b013a8e95d86914",
+      "ak": "3dePwMm0LzZfhto5VaX9Kh4yynD4yAev"
+    }
+  }
+}

+ 55 - 35
app/src/main/java/com/develop/foodcooking/FoodCookApp.kt

@@ -12,11 +12,7 @@ import com.blankj.utilcode.util.ResourceUtils
 import com.blankj.utilcode.util.Utils
 import com.develop.food.base.FoodCookBaseApp
 import com.develop.food.base.router.ARouterUtils
-import com.develop.food.base.utils.AppVerUtils
-import com.develop.food.base.utils.MmkvUtils
-import com.develop.food.base.utils.NetWorkManager
-import com.develop.food.base.utils.RecyclerViewCompat
-import com.develop.food.base.utils.setNightTheme
+import com.develop.food.base.utils.*
 import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus
 import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevStatusEvent
 import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
@@ -51,8 +47,7 @@ class FoodCookApp : FoodCookBaseApp() {
         ARouterUtils.init(this, BuildConfig.DEBUG)
         CrashReport.initCrashReport(this, "0c1b27f35b", BuildConfig.DEBUG)
         ResourceUtils.copyFileFromAssets(
-            ASSETS_NIGHT_SKIN_PACK,
-            SKIN_PACK_PATH + NIGHT_SKIN_PACK_NAME
+            ASSETS_NIGHT_SKIN_PACK, SKIN_PACK_PATH + NIGHT_SKIN_PACK_NAME
         )
         WindowManager.getInstance().init(this, OptionFactory())
         val isNight = BuildConfig.UpdatePlatform.equals("night")
@@ -62,58 +57,84 @@ class FoodCookApp : FoodCookBaseApp() {
         CofarSDK.register(this)
         CofarSDK.stopNative()
         val mContext = applicationContext
-        val powerManager = mContext.getSystemService(android.content.Context.POWER_SERVICE) as PowerManager
-        val  wakeLock: WakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "motionDetection:keepAwake")
+        val powerManager =
+            mContext.getSystemService(android.content.Context.POWER_SERVICE) as PowerManager
+        val wakeLock: WakeLock =
+            powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "motionDetection:keepAwake")
         wakeLock.acquire()
         NetWorkManager.get().init(this)
         AppVerUtils.checkRecipeUpdate()
         var minute = MmkvUtils.getInt("ScreenSaver")
-        if(minute == 0){
+        if (minute == 0) {
             minute = 3;
         }
         Settings.System.putInt(
-            contentResolver,
-            Settings.System.SCREEN_OFF_TIMEOUT,
-            (1000 * 60 * minute).toInt()
+            contentResolver, Settings.System.SCREEN_OFF_TIMEOUT, (1000 * 60 * minute).toInt()
         )
-        val uri: Uri = Settings.System
-            .getUriFor(Settings.System.SCREEN_OFF_TIMEOUT)
+        val uri: Uri = Settings.System.getUriFor(Settings.System.SCREEN_OFF_TIMEOUT)
         contentResolver.notifyChange(uri, null)
     }
 
 
+    var keepScreen = false
 
+    var timer: Timer? = null;
 
+    var ledLock = false;
 
-    var keepScreen = false
 
-    var  timer:Timer ?= null;
+    @SuppressLint("InvalidWakeLockTag")
+    @Subscribe
+    fun onTuyaEvent(event: TuyaEvent) {
+
+        TuyaUtils.uploadData()
+        val pm = getSystemService(POWER_SERVICE) as PowerManager
+
+        if (mWakeLock == null) {
+            mWakeLock = pm.newWakeLock(
+                PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ON_AFTER_RELEASE or PowerManager.ACQUIRE_CAUSES_WAKEUP,
+                "tag"
+            );
+            mWakeLock?.setReferenceCounted(false);
+            mWakeLock?.acquire()
+        }
+
+        mWakeLock?.release()
+        mWakeLock = null
+        val intent = Intent()
+        intent.action = "android.intent.action.SS_DEVICE_TOUCH"
+        sendBroadcast(intent)
+    }
 
-    var ledLock = false;
 
     @SuppressLint("InvalidWakeLockTag")
     @Subscribe
     @Synchronized
-    fun devMsg(event: DevStatusEvent){
+    fun devMsg(event: DevStatusEvent) {
 
 //        return
+        TuyaUtils.uploadData()
+
         val devInfo = event.devInfo;
         val pm = getSystemService(POWER_SERVICE) as PowerManager
         var minute = MmkvUtils.getInt("ScreenSaver")
-        if(minute == 0){
+        if (minute == 0) {
             minute = 3;
         }
 
-        if(devInfo.status == DevStatus.RUNNING.toInt() || devInfo.isWeightStatus){
-            if(mWakeLock == null){
-                mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ON_AFTER_RELEASE or PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
+        if (devInfo.status == DevStatus.RUNNING.toInt() || devInfo.isWeightStatus) {
+            if (mWakeLock == null) {
+                mWakeLock = pm.newWakeLock(
+                    PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ON_AFTER_RELEASE or PowerManager.ACQUIRE_CAUSES_WAKEUP,
+                    "tag"
+                );
                 mWakeLock?.setReferenceCounted(false);
                 mWakeLock?.acquire()
             }
 
 
-        }else if (devInfo.status != DevStatus.RUNNING.toInt()){
-            if(mWakeLock != null){
+        } else if (devInfo.status != DevStatus.RUNNING.toInt()) {
+            if (mWakeLock != null) {
                 mWakeLock?.release()
                 mWakeLock = null
                 val intent = Intent()
@@ -126,25 +147,25 @@ class FoodCookApp : FoodCookBaseApp() {
 
 
 
-        if(!ledLock){
+        if (!ledLock) {
             ledLock = true;
-            if(!pm.isScreenOn){
+            if (!pm.isScreenOn) {
 
                 //合盖
-                if(devInfo.potCloverStatus.toInt() == 0){
+                if (devInfo.potCloverStatus.toInt() == 0) {
                     CofarSDK.flashWhiteRedLed()
-                }else{
+                } else {
                     CofarSDK.switchWhiteLed('0');
                     CofarSDK.flashRedLed()
                 }
 
-            }else{
+            } else {
                 if (devInfo.status == DevStatus.STOP.toInt()) {
 
                     if (devInfo.potStatus.toInt() == 0) {
-                        if(devInfo.potCloverStatus.toInt() == 0){
+                        if (devInfo.potCloverStatus.toInt() == 0) {
                             CofarSDK.flashWhiteRedLed()
-                        }else{
+                        } else {
                             CofarSDK.switchWhiteLed('0');
                             CofarSDK.flashRedLed()
                         }
@@ -170,10 +191,10 @@ class FoodCookApp : FoodCookBaseApp() {
 
                     //判断盖子是否打开
                     //合盖
-                    if(devInfo.potCloverStatus.toInt() == 1){
+                    if (devInfo.potCloverStatus.toInt() == 1) {
                         CofarSDK.switchWhiteLed('0');
                         CofarSDK.flashRedLed()
-                    }else{
+                    } else {
                         CofarSDK.flashWhiteRedLed()
                     }
 
@@ -190,7 +211,6 @@ class FoodCookApp : FoodCookBaseApp() {
     }
 
 
-
 }
 
 class OptionFactory : IOptionFactory {

+ 9 - 1
app/src/main/java/com/develop/foodcooking/MainActivity.kt

@@ -2,6 +2,7 @@ package com.develop.foodcooking
 
 import android.os.Bundle
 import android.view.LayoutInflater
+import com.develop.common.utils.ConfigUtils
 import com.develop.food.base.api.FoodRepository
 import com.develop.food.base.http.observeStatus
 import com.develop.food.base.ui.BaseActivity
@@ -10,6 +11,7 @@ import com.develop.food.base.router.navigateTo
 import com.develop.foodcooking.databinding.ActivityMainBinding
 import com.develop.food.base.router.Screens
 import com.develop.food.base.utils.TopResumedActivityHolder
+import com.develop.food.base.utils.TuyaUtils
 import com.develop.food.base.widgets.RecipeUpdateDialog
 
 class MainActivity : BaseActivity<ActivityMainBinding>() {
@@ -22,7 +24,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
             navigateTo(Screens.Setting.ANIMATION)
         }
 
-
+        var tuyaConfig =  ConfigUtils.loadTuyaConfig()
+        if(tuyaConfig != null){
+            TuyaUtils.mAk = tuyaConfig.get("ak")
+            TuyaUtils.mPid = tuyaConfig.get("pid")
+            TuyaUtils.mUid = tuyaConfig.get("uid")
+            TuyaUtils.initSDK(this,"1.0.0")
+        }
 
         finish()
     }

+ 1 - 0
libBase/src/main/AndroidManifest.xml

@@ -8,4 +8,5 @@
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <uses-permission android:name="android.permission.REBOOT" />
 </manifest>

+ 10 - 1
libBase/src/main/java/com/develop/food/base/data/DataFactory.kt

@@ -254,6 +254,14 @@ object DataFactory {
             SettingType.RESTORE_FACTORY_SETTINGS,
             SettingType.ABOUT
         )
+
+        var tuyaConfig =  ConfigUtils.loadTuyaConfig()
+        if(tuyaConfig != null){
+            settingTypeList.add(SettingType.TUYA)
+            nameList.add(resource.getString(R.string.tuya))
+            resIdList.add(R.drawable.ic_setting_tuya)
+        }
+
         for (i in resIdList.indices) {
             result.add(SettingModel(resIdList[i], nameList[i], settingTypeList[i]))
         }
@@ -466,7 +474,8 @@ enum class SettingType {
     USER_ACCOUNT,
     STORAGE,
     ABOUT,
-    RESTORE_FACTORY_SETTINGS
+    RESTORE_FACTORY_SETTINGS,
+    TUYA
 }
 
 enum class CategoryType {

+ 1 - 0
libBase/src/main/java/com/develop/food/base/router/Screens.kt

@@ -19,6 +19,7 @@ object Screens {
         const val SOUND = "$SCHEMA/sound"
         const val ABOUT = "$SCHEMA/about"
         const val RESTORE = "$SCHEMA/restore"
+        const val TUYA = "$SCHEMA/tuya"
     }
 
     object Main {

+ 3 - 0
libBase/src/main/java/com/develop/food/base/utils/CfConfig.kt

@@ -0,0 +1,3 @@
+package com.develop.common.bean
+
+data class CfConfig(var baseQrUrl:String,var workModes: ArrayList<WorkMode>)

+ 54 - 0
libBase/src/main/java/com/develop/food/base/utils/CommonTag.kt

@@ -0,0 +1,54 @@
+package com.develop.food.base.utils
+
+
+const val FIRST_IN = "FIRST_IN"
+
+const val FOOL_LIST_TITLE = "FOOL_LIST_TITLE"
+const val FOOD_LIST_TYPE = "FOOD_LIST_TYPE"
+const val WIFI_FROM_MAIN_SETTING = "WIFI_FROM_MAIN_SETTING"
+const val POLICY_FROM_MAIN_SETTING = "POLICY_FROM_MAIN_SETTING"
+const val MODE_ENTRANCE = "MODE_ENTRANCE"
+const val RECIPES_TYPE = "RECIPES_TYPE"
+const val HOME_TITLE = "HOME_TITLE"
+const val MODE_TYPE = "mode_type"
+const val LANGUAGE_FROM_SETTING = "LANGUAGE_FROM_SETTING"
+const val SCREENSAVER = "ScreenSaver"
+const val SOURCE_TAG = "source"
+const val NUMBER_TAG = "number"
+const val IS_LIKE_TAG = "isLike"
+const val RECIPES_EDITION_TAG = "recipesEdition"
+
+const val Favourite = 1
+const val History = 2
+const val Downloaded = 3
+
+const val Mode = 1
+const val Recipes = 2
+
+const val NetFood = 1
+const val LocalFood = 2
+
+const val CURRENT_LANGUAGE = "CURRENT_LANGUAGE"
+const val API_TOKEN = "API_TOKEN"
+const val LOGIN_TAG = "LOGIN_TAG"
+const val CURRENT_USER_ID_TAG = "CURRENT_USER_ID"
+
+const val EN = "EN"
+const val ZH = "ZH"
+const val JA = "JA"
+const val FR = "FR"
+const val CZ = "CZ"
+const val ES = "ES"
+const val HU = "HU"
+const val SK = "SK"
+const val DE = "DE"
+const val IT = "IT"
+const val PL = "PL"
+const val NL = "NL"
+const val PT = "PT"
+const val RU = "RU"
+
+const val TURN_UP_KEY_CODE = 19
+const val TURN_DOWN_KEY_CODE = 20
+const val PRESS_DOWN_KEY_CODE = 66
+

+ 118 - 0
libBase/src/main/java/com/develop/food/base/utils/CommonUtils.kt

@@ -0,0 +1,118 @@
+package com.develop.food.base.utils
+
+import android.os.Bundle
+import com.develop.food.base.repo.FoodDataProvider
+import com.develop.food.base.router.Screens
+import com.develop.food.base.router.navigateTo
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevModes
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.WorkModes
+import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
+
+object  CommonUtils {
+
+    fun navigateToRemoteRecipe(number:String){
+
+
+        FoodDataProvider.getDatabase().recipeDao().apply {
+
+            val recipeBean = queryRecipe(number)
+            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(){
+
+
+        TopResumedActivityHolder.getCurrentActivity()?.apply {
+
+
+            if(localClassName.indexOf("ModesDetailActivity") != -1){
+                if(CommonUtils.devReady()){
+                    return
+                }else{
+                    finish()
+                }
+            }
+
+        }
+
+
+
+
+
+        if(DevModes.SOUP == CofarSDK.devInfo().devMode){
+            val bundle = Bundle()
+            bundle.putString(MODE_TYPE, WorkModes.ADAPTED_COOKING)
+            bundle.putString("OP_MODE","APP")
+            TopResumedActivityHolder.getCurrentActivity()?.navigateTo(Screens.Cook.COOK_MODES) {
+                with(bundle)
+            }
+        }else if (DevModes.AIR_FRYER == CofarSDK.devInfo().devMode){
+            val bundle = Bundle()
+            bundle.putString(MODE_TYPE, WorkModes.AF_DIY)
+            bundle.putString("OP_MODE","APP")
+            TopResumedActivityHolder.getCurrentActivity()?.navigateTo(Screens.Cook.COOK_MODES) {
+                with(bundle)
+            }
+        }
+
+
+
+    }
+
+    fun devReady():Boolean{
+
+        var result = false;
+        var localClassName = TopResumedActivityHolder.getCurrentActivity()?.localClassName?.indexOf("ModesDetailActivity")
+        if(DevModes.SOUP == CofarSDK.devInfo().devMode){
+            result  =TopResumedActivityHolder.getCurrentActivity()?.localClassName?.indexOf("ModesDetailActivity") != -1  && CofarSDK.devInfo().mode.mode === WorkModes.ADAPTED_COOKING && !CofarSDK.devInfo().isWeightStatus
+
+        }else if (DevModes.AIR_FRYER == CofarSDK.devInfo().devMode){
+            result  =TopResumedAtyHolder.getCurrentActivity()?.localClassName?.indexOf("ModesDetailActivity") != -1  && CofarSDK.devInfo().mode.mode === WorkModes.AF_DIY  && !CofarSDK.devInfo().isWeightStatus
+
+        }
+
+        return result
+
+
+
+
+
+    }
+
+
+
+}

+ 66 - 2
libBase/src/main/java/com/develop/food/base/utils/ConfigUtils.kt

@@ -1,7 +1,11 @@
 package com.develop.common.utils
 
 
+import com.develop.common.bean.CfConfig
+import com.develop.common.bean.TuyaConfig
+import com.develop.common.bean.WorkMode
 import com.develop.food.base.utils.GlobalApp
+import com.develop.food.base.utils.getSN
 import com.google.gson.Gson
 import java.io.IOException
 import java.io.InputStream
@@ -15,10 +19,42 @@ object ConfigUtils {
     data class LangConfig(var langs: ArrayList<Lang>)
 
 
+    fun loadConfig(): CfConfig? {
+        return try {
+            var sn = getSN()
+            var brandNum = sn.substring(0,3)
+
+            val fileList = GlobalApp().assets.list("") ?: arrayOf()
+            var inputStream: InputStream? = null
+            if(fileList.contains("config_${brandNum}.json")){
+                inputStream = GlobalApp().assets.open("config_${brandNum}.json")
+            }else{
+                inputStream = GlobalApp().assets.open("config.json")
+            }
+
+
+            val size = inputStream.available()
+            val buffer = ByteArray(size)
+            inputStream.read(buffer)
+            inputStream.close()
+
+            val jsonString = String(buffer, Charset.defaultCharset())
+            val gson = Gson()
+            val cfConfig = gson.fromJson(jsonString, CfConfig::class.java)
+            cfConfig;
+        } catch (ex: IOException) {
+            ex.printStackTrace()
+            null
+        }
+    }
+
+
     fun loadLangConfig(): LangConfig? {
         return try {
-            val sn = "034K"
-            val brandNum = sn.substring(0,3)
+
+            var sn = getSN()
+            var brandNum = sn.substring(0,3)
+
             val fileList = GlobalApp().assets.list("") ?: arrayOf()
             var inputStream: InputStream? = null
             if(fileList.contains("lang_config_${brandNum}.json")){
@@ -42,6 +78,34 @@ object ConfigUtils {
         }
     }
 
+    fun loadTuyaConfig(): Map<String,String>? {
+        return try {
+            var sn = getSN()
+
+            var inputStream: InputStream? = null
+            inputStream = GlobalApp().assets.open("tuya_config.json")
+
+
+            val size = inputStream.available()
+            val buffer = ByteArray(size)
+            inputStream.read(buffer)
+            inputStream.close()
+
+            val jsonString = String(buffer, Charset.defaultCharset())
+            val gson = Gson()
+            val cfConfig = gson.fromJson(jsonString, TuyaConfig::class.java)
+            cfConfig.licences.get(sn)
+        } catch (ex: IOException) {
+            ex.printStackTrace()
+            null
+        }
+    }
+
+
+    fun getMode(type: String): WorkMode? {
+        return loadConfig()?.workModes?.find { it.type == type }?.copy()
+    }
+
 
 
 }

+ 1 - 1
libBase/src/main/java/com/develop/food/base/utils/GlobalExt.kt

@@ -269,7 +269,7 @@ fun timeStamp2Time(timeSeconds: Long, format: String = "yyyy/MM/dd HH:mm"): Stri
 fun getSN(): String {
     //通过反射获取sn号
     var serial: String
-   // return "034A30150020123010190001"
+    return "000A30150020123010190001"
     try {
         val c = Class.forName("android.os.SystemProperties")
         val get = c.getMethod("get", String::class.java)

+ 49 - 0
libBase/src/main/java/com/develop/food/base/utils/TopResumedAtyHolder.kt

@@ -0,0 +1,49 @@
+package com.develop.food.base.utils
+
+import android.app.Activity
+import android.app.Application
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import java.lang.ref.WeakReference
+
+/**
+ *
+ */
+object TopResumedAtyHolder : Application.ActivityLifecycleCallbacks {
+
+    private var ref: WeakReference<AppCompatActivity>? = null
+
+    fun getCurrentActivity(): AppCompatActivity? {
+        return ref?.get()
+    }
+
+    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
+
+    }
+
+    override fun onActivityStarted(activity: Activity) {
+
+    }
+
+    override fun onActivityResumed(activity: Activity) {
+        if (activity is AppCompatActivity) {
+            ref = WeakReference(activity)
+        }
+    }
+
+    override fun onActivityPaused(activity: Activity) {
+
+    }
+
+    override fun onActivityStopped(activity: Activity) {
+
+    }
+
+    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
+
+    }
+
+    override fun onActivityDestroyed(activity: Activity) {
+
+    }
+}

+ 4 - 0
libBase/src/main/java/com/develop/food/base/utils/TuyaConfig.kt

@@ -0,0 +1,4 @@
+package com.develop.common.bean
+
+
+data class TuyaConfig(var licences: Map<String,Map<String,String>>)

+ 33 - 0
libBase/src/main/java/com/develop/food/base/utils/TuyaDps.java

@@ -0,0 +1,33 @@
+package com.develop.food.base.utils;
+
+public class TuyaDps {
+
+    public static final int WORK_STATE = 101;
+    public static final int CURRENT_PRESSURE_COOKER = 102;
+    public static final int MOTOR_GEAR = 103;
+    public static final int MOTOR_DIRECTION = 104;
+    public static final int SPRAY_WATER = 105;
+    public static final int POT_STATUS = 106;
+    public static final int TARGET_PRESSURE_COOKER = 107;
+    public static final int WIND_SPEED = 108;
+    public static final int DEV_MODE = 109;
+    public static final int DEV_READY = 110;
+    public static final int POT_CLOVER_STATUS = 111;
+    public static final int REMAIN_TIME_O = 112;
+    public static final int ERROR_CODE = 113;
+    public static final int TY_ERROR_CODE = 13;
+    public static final int RECIPE_NUM = 115;
+    public static final int TARGET_TEMP = 116;
+    public static final int CURRENT_TEMP = 117;
+    public static final int TARGET_TIME = 118;
+    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 MAX_SPRAY_WATER = 125;
+    public static final int MIN_SPRAY_WATER = 126;
+
+
+}

+ 46 - 0
libBase/src/main/java/com/develop/food/base/utils/TuyaEvent.java

@@ -0,0 +1,46 @@
+package com.develop.food.base.utils;
+
+
+public class TuyaEvent {
+
+    private String type;
+
+
+    private Integer temp;
+
+    private Integer motorGear;
+
+    private Integer time;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Integer getTemp() {
+        return temp;
+    }
+
+    public void setTemp(Integer temp) {
+        this.temp = temp;
+    }
+
+    public Integer getMotorGear() {
+        return motorGear;
+    }
+
+    public void setMotorGear(Integer motorGear) {
+        this.motorGear = motorGear;
+    }
+
+    public Integer getTime() {
+        return time;
+    }
+
+    public void setTime(Integer time) {
+        this.time = time;
+    }
+}

+ 315 - 0
libBase/src/main/java/com/develop/food/base/utils/TuyaUtils.java

@@ -0,0 +1,315 @@
+package com.develop.food.base.utils;
+
+import static android.content.Context.MODE_PRIVATE;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.PowerManager;
+
+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.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.tuya.smartai.iot_sdk.DPEvent;
+import com.tuya.smartai.iot_sdk.IoTSDKManager;
+import com.tuya.smartai.iot_sdk.Log;
+import com.tuya.smartai.iot_sdk.UpgradeEventCallback;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.Map;
+
+public class TuyaUtils {
+    public static Context context;
+    public static String version;
+    public static final String TAG = "TUYA";
+    public static  String mPid = "dquk8axtyy72c1ap";
+    public static  String mUid = "uuid50e9e0c707553116";
+    public static  String mAk = "MJhcxmQ6LeZDj1tNu6F5kqK5aQJfpdOb";
+    public static  String qrcodeUrl =  "";
+    public static IoTSDKManager ioTSDKManager = null;
+    
+    public static boolean init = false;
+
+    public static void output(String text) {
+        Log.d(TAG, text);
+    }
+
+
+    public static 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 static void  uploadData(){
+        if(ioTSDKManager == null || !init){
+            return;
+        }
+
+        int devMode = -1;
+        if(DevModes.SOUP.equals(CofarSDK.devInfo().getDevMode())){
+            devMode = 0;
+        }else if (DevModes.AIR_FRYER.equals(CofarSDK.devInfo().getDevMode())){
+            devMode = 4;
+        }
+
+        DevInfo info = CofarSDK.devInfo();
+
+        BaseDevMode mode = info.getMode();
+
+        DPEvent[] dpEvents = new DPEvent[]{
+          new DPEvent(TuyaDps.DEV_MODE,(byte) DPEvent.Type.PROP_VALUE,devMode,0),
+          new DPEvent(TuyaDps.CURRENT_PRESSURE_COOKER,(byte) DPEvent.Type.PROP_VALUE,-1,0),
+          new DPEvent(TuyaDps.TARGET_PRESSURE_COOKER,(byte) DPEvent.Type.PROP_VALUE,-1,-1),
+          new DPEvent(TuyaDps.TARGET_TIME,(byte) DPEvent.Type.PROP_VALUE,info.getTargetTimeBuffer() != -1 ? info.getTargetTimeBuffer() : info.getTargetTime(),0),
+          new DPEvent(TuyaDps.REMAIN_TIME_O,(byte) DPEvent.Type.PROP_VALUE,info.getRemainTime(),0),
+          new DPEvent(TuyaDps.ERROR_CODE,(byte) DPEvent.Type.PROP_VALUE,(int)info.getErrCode(),0),
+          new DPEvent(TuyaDps.TY_ERROR_CODE,(byte) DPEvent.Type.PROP_BITMAP, parse(info.getErrCode()),0),
+          new DPEvent(TuyaDps.WORK_STATE,(byte) DPEvent.Type.PROP_VALUE,info.getStatus(),0),
+          new DPEvent(TuyaDps.MOTOR_GEAR,(byte) DPEvent.Type.PROP_VALUE,(int)(info.getMotorGearBuffer() != -1 ? info.getMotorGearBuffer() : info.getMotorGear()),0),
+          new DPEvent(TuyaDps.MOTOR_DIRECTION,(byte) DPEvent.Type.PROP_VALUE,(int)(info.getMotorDirectionBuffer() != -1 ? info.getMotorDirectionBuffer():info.getMotorDirection()),0),
+          new DPEvent(TuyaDps.SPRAY_WATER,(byte) DPEvent.Type.PROP_VALUE,(int)(info.getWaterGearBuffer() != -1 ? info.getWaterGearBuffer() : info.getWaterGear()),0),
+          new DPEvent(TuyaDps.WIND_SPEED,(byte) DPEvent.Type.PROP_VALUE,1,0),
+          new DPEvent(TuyaDps.TARGET_TEMP,(byte) DPEvent.Type.PROP_VALUE,(int)(info.getTargetTempBuffer() != -1 ? info.getTargetTempBuffer():info.getTargetTemp()),0),
+          new DPEvent(TuyaDps.CURRENT_TEMP,(byte) DPEvent.Type.PROP_VALUE,(int)CofarUtils.parseTemp(info.getTemp()),0),
+          new DPEvent(TuyaDps.POT_CLOVER_STATUS,(byte) DPEvent.Type.PROP_VALUE,(int)info.getPotCloverStatus(),0),
+          new DPEvent(TuyaDps.POT_STATUS,(byte) DPEvent.Type.PROP_VALUE,(int)info.getPotStatus(),0),
+          new DPEvent(TuyaDps.DEV_READY,(byte) DPEvent.Type.PROP_VALUE,CommonUtils.INSTANCE.devReady() ? 0 : 1,0),
+          new DPEvent(TuyaDps.MAX_TIME,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMaxTime(),0),
+          new DPEvent(TuyaDps.MIN_TIME,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMinTime(),0),
+          new DPEvent(TuyaDps.MAX_TEMP,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMaxTemp(),0),
+          new DPEvent(TuyaDps.MIN_TEMP,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMinTemp(),0),
+          new DPEvent(TuyaDps.MAX_MOTOR_GEAR,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMaxMotorGear(),0),
+          new DPEvent(TuyaDps.MIN_MOTOR_GEAR,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMinMotorGear(),0),
+          new DPEvent(TuyaDps.MAX_SPRAY_WATER,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMaxWaterGear(),0),
+          new DPEvent(TuyaDps.MIN_MOTOR_GEAR,(byte) DPEvent.Type.PROP_VALUE,mode == null ? 0 : mode.getMinMotorGear(),0),
+
+
+        };
+
+
+
+        ioTSDKManager.sendDP(dpEvents);
+    }
+
+    public static void cancelBind(){
+        init = false;
+        if (ioTSDKManager!=null){
+            ioTSDKManager.reset();
+        }
+
+
+
+    }
+
+
+    public static void baseInitSDK(Context ctx,String version) {
+
+        ioTSDKManager = new IoTSDKManager(ctx) {
+            @Override
+            protected boolean isOffline() {
+                //实现自定义网络监测
+                Log.d(TAG, "isOffline: " + super.isOffline());
+                return super.isOffline();
+            }
+        };
+
+        output("固件版本:" + version);
+
+        output("init sdk:" + mPid + "/" + mUid + "/" + mAk);
+
+        //注意:这里的pid等配置读取自local.properties文件,不能直接使用。请填写你自己的配置!
+        ioTSDKManager.initSDK("/sdcard/tuya_iot/", mPid
+                , mUid, mAk, version, new IoTSDKManager.IoTCallback() {
+
+                    @Override
+                    public void onDpEvent(DPEvent event) {
+
+                        TuyaEvent a = new TuyaEvent();
+                        a.setType("test");
+                        EventBus.getDefault().post(a);
+
+                        if (event != null) {
+                            output("收到 dp: " + event);
+
+                            if(event.dpid == TuyaDps.RECIPE_NUM){
+                                CommonUtils.INSTANCE.navigateToRemoteRecipe((String) event.value);
+                            }
+
+                            if(event.dpid == TuyaDps.DEV_READY){
+                                CommonUtils.INSTANCE.navigateToAdaptedCooking();
+                            }
+
+                            if(event.dpid == TuyaDps.WORK_STATE){
+
+                                if(DevStatus.STOP == (int)event.value){
+                                    TuyaEvent e = new TuyaEvent();
+                                    e.setType("stop");
+                                    EventBus.getDefault().post(e);
+                                }
+
+
+                                if(DevStatus.PAUSE == (int)event.value){
+                                    TuyaEvent e = new TuyaEvent();
+                                    e.setType("pause");
+                                    EventBus.getDefault().post(e);
+                                }
+
+
+                                if(DevStatus.RUNNING == (int)event.value){
+                                    TuyaEvent e = new TuyaEvent();
+                                    e.setType("start");
+                                    EventBus.getDefault().post(e);
+                                }
+                            }
+
+
+                            if(event.dpid == TuyaDps.TARGET_TEMP){
+                                CofarSDK.cfgHeat((short) (int) event.value, HeatModes.PU_TONG);
+                                TuyaEvent e = new TuyaEvent();
+                                e.setType("change_temp");
+                                EventBus.getDefault().post(e);
+                            }
+
+                            if(event.dpid == TuyaDps.TARGET_TIME){
+                                CofarSDK.cfgTime( (int) event.value);
+                                TuyaEvent e = new TuyaEvent();
+                                e.setType("change_time");
+                                EventBus.getDefault().post(e);
+                            }
+
+                            if(event.dpid == TuyaDps.MOTOR_DIRECTION){
+                                CofarSDK.cfgMotorDirection((int) event.value == 0 ? MotorDirections.FORWARD:MotorDirections.REVERSE);
+                            }
+
+                            if(event.dpid == TuyaDps.MOTOR_GEAR){
+                                CofarSDK.cfgMotorGear((byte) ((int)event.value & 0xFF));
+                            }
+
+
+
+                        }
+
+
+                    }
+
+                    @Override
+                    public void onReset() {
+
+                        ctx.getSharedPreferences("event_cache", MODE_PRIVATE).edit().clear().commit();
+                        PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
+                        pm.reboot("");
+
+                    }
+
+                    @Override
+                    public void onShorturl(String urlJson) {
+                        output("shorturl: " + urlJson);
+                        Gson gson = new Gson();
+                        Map d = gson.fromJson(urlJson, Map.class);
+                        String url = (String) d.get("shortUrl");
+                        qrcodeUrl = url;
+                        MmkvUtils.INSTANCE.save("tuya_url",url);
+                        EventBus.getDefault().post(new TuyaUtils());
+                    }
+
+                    @Override
+                    public void onActive() {
+                        output("onActive: devId-> " + ioTSDKManager.getDeviceId());
+                        init = true;
+                    }
+
+                    @Override
+                    public void onFirstActive() {
+                        output("onFirstActive");
+                    }
+
+                    @Override
+                    public void onMQTTStatusChanged(int status) {
+                        output("onMQTTStatusChanged: " + status);
+
+                        switch (status) {
+                            case IoTSDKManager.STATUS_OFFLINE:
+                                // 设备网络离线
+                                break;
+                            case IoTSDKManager.STATUS_MQTT_OFFLINE:
+                                // 网络在线MQTT离线
+                                break;
+                            case IoTSDKManager.STATUS_MQTT_ONLINE:
+                                // 网络在线MQTT在线
+
+                                SharedPreferences sp = ctx.getSharedPreferences("event_cache", MODE_PRIVATE);
+
+                                DPEvent[] events = ioTSDKManager.getEvents();
+
+                                if (events != null) {
+                                    for (DPEvent event : events) {
+                                        if (event != null) {
+                                            output(event.toString());
+                                        }
+                                    }
+                                }
+                                break;
+                        }
+                    }
+
+//                    @Override
+//                    public void onMqttMsg(int protocol, org.json.JSONObject msgObj) {
+//
+//                    }
+                });
+
+        ioTSDKManager.setUpgradeCallback(new UpgradeEventCallback() {
+            @Override
+            public void onUpgradeInfo(String s) {
+                Log.w(TAG, "onUpgradeInfo: " + s);
+
+                output("收到升级信息: " + s);
+
+//                runOnUiThread(() -> upgradeDialog.show());
+
+                ioTSDKManager.startUpgradeDownload();
+            }
+
+            @Override
+            public void onUpgradeDownloadStart() {
+                Log.w(TAG, "onUpgradeDownloadStart");
+
+                output("开始升级下载");
+            }
+
+            @Override
+            public void onUpgradeDownloadUpdate(int i) {
+                Log.w(TAG, "onUpgradeDownloadUpdate: " + i);
+            }
+
+            @Override
+            public void upgradeFileDownloadFinished(int result, String file) {
+                Log.w(TAG, "upgradeFileDownloadFinished: " + result);
+
+                output("下载完成:" + result + " / " + file);
+            }
+        });
+    }
+
+    public static void initSDK(Context ctx,String version) {
+        context = ctx;
+        version = version;
+        //Log.init(ctx, "/sdcard/tuya_log/iot_demo/", 3);
+        baseInitSDK(ctx,version);
+    }
+
+
+}

+ 3 - 0
libBase/src/main/java/com/develop/food/base/utils/WorkMode.kt

@@ -0,0 +1,3 @@
+package com.develop.common.bean
+
+data class WorkMode(val name: String?, val type: String, val icon: String?,val bg: String?,val devMode:String?,val listShow:Boolean?)

+ 2 - 0
libBase/src/main/res/values/strings.xml

@@ -252,4 +252,6 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="captcha_can_not_be_empty">Captcha can not be empty!</string>
     <string name="please_fill_in_the_password">Please fill in the password</string>
     <string name="reset_password_success">Reset password success!</string>
+    <string name="tuya">TUYA</string>
+    <string name="cancel_tuya_bind">Cancel Bind</string>
 </resources>

+ 9 - 0
libThirdParty/build.gradle

@@ -32,6 +32,12 @@ android {
             jniLibs.srcDirs = ['libs']
         }
     }
+
+    packagingOptions {
+        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
+
+    }
+
 }
 
 dependencies {
@@ -93,4 +99,7 @@ dependencies {
     // 需要替换字体库时引入
     api 'com.github.CoderAlee.PaintedSkin:typeface-plugin:3.5.2.1'
     api files('libs/PaintedSkin-release.aar')
+
+    api 'com.tuya.smart:tuyasmart-iot_sdk:1.0.8-rc.1'
+    api 'com.tencent.mars:mars-xlog:1.2.3'
 }

+ 6 - 0
settings.gradle

@@ -3,6 +3,8 @@ pluginManagement {
         maven { url 'https://jitpack.io' }
         maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
         maven { url 'https://maven.aliyun.com/repository/public' }
+        maven { url 'https://maven-other.tuya.com/repository/maven-releases/'}
+        maven { url 'https://maven-other.tuya.com/repository/maven-snapshots/'}
         gradlePluginPortal()
         google()
         mavenCentral()
@@ -14,6 +16,10 @@ dependencyResolutionManagement {
         maven { url 'https://jitpack.io' }
         maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
         maven { url 'https://maven.aliyun.com/repository/public' }
+        maven { url 'https://maven-other.tuya.com/repository/maven-releases/'}
+        maven { url 'https://maven-other.tuya.com/repository/maven-snapshots/'}
+        maven { url 'https://dl.bintray.com/tuyasmartai/sdk' }
+
         google()
         mavenCentral()
     }