|
@@ -2,12 +2,17 @@ package com.develop.common.utils;
|
|
|
|
|
|
import static android.content.Context.MODE_PRIVATE;
|
|
|
|
|
|
+import android.app.AlarmManager;
|
|
|
+import android.app.PendingIntent;
|
|
|
import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
import android.content.SharedPreferences;
|
|
|
+import android.os.PowerManager;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
|
|
|
import com.develop.base.util.MMkvUtils;
|
|
|
+import com.develop.base.util.TopResumedAtyHolder;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus;
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.constant.core.MotorDirections;
|
|
@@ -18,6 +23,7 @@ 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 org.json.JSONObject;
|
|
|
|
|
|
import java.util.Arrays;
|
|
@@ -26,12 +32,13 @@ import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
public class TuyaUtils {
|
|
|
-
|
|
|
+ public static Context context;
|
|
|
+ public static String version;
|
|
|
public static final String TAG = "TUYA";
|
|
|
- public static final String mPid = "dquk8axtyy72c1ap";
|
|
|
- public static final String mUid = "uuid50e9e0c707553116";
|
|
|
- public static final String mAk = "MJhcxmQ6LeZDj1tNu6F5kqK5aQJfpdOb";
|
|
|
- public static String qrcodeUrl = MMkvUtils.INSTANCE.getString("tuya_url");
|
|
|
+ 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;
|
|
@@ -75,9 +82,14 @@ public class TuyaUtils {
|
|
|
ioTSDKManager.sendDP(dpEvents);
|
|
|
}
|
|
|
|
|
|
- public static void initSDK(Context ctx,String version) {
|
|
|
+ public static void cancelBind(){
|
|
|
+ init = false;
|
|
|
+ ioTSDKManager.reset();
|
|
|
|
|
|
- Log.init(ctx, "/sdcard/tuya_log/iot_demo/", 3);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void baseInitSDK(Context ctx,String version) {
|
|
|
|
|
|
ioTSDKManager = new IoTSDKManager(ctx) {
|
|
|
@Override
|
|
@@ -100,14 +112,20 @@ public class TuyaUtils {
|
|
|
public void onDpEvent(DPEvent event) {
|
|
|
if (event != null) {
|
|
|
output("收到 dp: " + event);
|
|
|
-
|
|
|
+ if(event.dpid == TuyaDps.RECIPE_NUM){
|
|
|
+ CommonUtils.INSTANCE.navigateToRemoteRecipe((String) event.value);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onReset() {
|
|
|
|
|
|
ctx.getSharedPreferences("event_cache", MODE_PRIVATE).edit().clear().commit();
|
|
|
+ PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
|
|
|
+ pm.reboot("");
|
|
|
|
|
|
}
|
|
|
|
|
@@ -119,7 +137,7 @@ public class TuyaUtils {
|
|
|
String url = (String) d.get("shortUrl");
|
|
|
qrcodeUrl = url;
|
|
|
MMkvUtils.INSTANCE.save("tuya_url",url);
|
|
|
-
|
|
|
+ EventBus.getDefault().post(new TuyaUtils());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -201,5 +219,12 @@ public class TuyaUtils {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public static void initSDK(Context ctx,String version) {
|
|
|
+ context = ctx;
|
|
|
+ version = version;
|
|
|
+ Log.init(ctx, "/sdcard/tuya_log/iot_demo/", 3);
|
|
|
+ baseInitSDK(ctx,version);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|