|
@@ -50,7 +50,6 @@ public class TuyaUtilsSo {
|
|
|
public boolean isUser = false;
|
|
|
|
|
|
|
|
|
-
|
|
|
public static TuyaUtilsSo getInstance() {
|
|
|
if (singleton == null) {
|
|
|
synchronized (TuyaUtilsSo.class) {
|
|
@@ -195,11 +194,11 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (enumValue==2){
|
|
|
+ if (enumValue == 2) {
|
|
|
heatType = 1;
|
|
|
- }else if (enumValue==10){
|
|
|
+ } else if (enumValue == 10) {
|
|
|
heatType = 2;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
heatType = 0;
|
|
|
}
|
|
|
autoMaticType = enumValue;
|
|
@@ -209,12 +208,12 @@ public class TuyaUtilsSo {
|
|
|
break;
|
|
|
case TuyaSoDp.COOKING_TEMPERATURE:
|
|
|
byte mode = HeatModes.PU_TONG;
|
|
|
- if (heatType==1){
|
|
|
+ if (heatType == 1) {
|
|
|
mode = HeatModes.ZHENG_QI;
|
|
|
- }else if (heatType==2){
|
|
|
- mode = HeatModes.SAP_SHUI;
|
|
|
- }else {
|
|
|
- mode =HeatModes.PU_TONG;
|
|
|
+ } else if (heatType == 2) {
|
|
|
+ mode = HeatModes.SAP_SHUI;
|
|
|
+ } else {
|
|
|
+ mode = HeatModes.PU_TONG;
|
|
|
}
|
|
|
|
|
|
isUser = true;
|
|
@@ -247,7 +246,7 @@ public class TuyaUtilsSo {
|
|
|
case TuyaSoDp.SPEED:
|
|
|
isUser = true;
|
|
|
|
|
|
- CofarSDK.cfgMotorGear((byte) intValue );
|
|
|
+ CofarSDK.cfgMotorGear((byte) intValue);
|
|
|
break;
|
|
|
case TuyaSoDp.REVERSIBLE:
|
|
|
isUser = true;
|
|
@@ -268,6 +267,7 @@ public class TuyaUtilsSo {
|
|
|
case TuyaSoDp.CURRENT_RECIPE_NUMBER:
|
|
|
|
|
|
CommonTuyaSoUtils.INSTANCE.navigateToRemoteRecipe(strValue);
|
|
|
+ wakeUpScreen(context);
|
|
|
break;
|
|
|
case TuyaSoDp.CURRENT_RECIPE_STEP:
|
|
|
|
|
@@ -284,6 +284,7 @@ public class TuyaUtilsSo {
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -360,7 +361,7 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
|
|
|
CommonTuyaSoUtils.INSTANCE.navigateToAdaptedCooking(type);
|
|
|
-
|
|
|
+ wakeUpScreen(context);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -453,7 +454,7 @@ public class TuyaUtilsSo {
|
|
|
|
|
|
|
|
|
public void uploadData() {
|
|
|
- if (!tuyaNetwork||!isUser) {
|
|
|
+ if (!tuyaNetwork || !isUser) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -464,7 +465,7 @@ public class TuyaUtilsSo {
|
|
|
DevInfo info = CofarSDK.devInfo();
|
|
|
BaseDevMode mode = info.getMode();
|
|
|
int time = (int) System.currentTimeMillis();
|
|
|
- if (getAutoMaticModes(info.getRunningInstId())!=autoMaticType){
|
|
|
+ if (getAutoMaticModes(info.getRunningInstId()) != autoMaticType) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -508,39 +509,6 @@ public class TuyaUtilsSo {
|
|
|
|
|
|
int automatic = getModes(info.getRunningInstId());
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
List<DPEvent> dpEvents = new ArrayList<>(Arrays.asList(
|
|
|
new DPEvent(TuyaSoDp.ON_OFF, (byte) DPEvent.Type.PROP_BOOL, 1, 0),
|
|
@@ -596,16 +564,16 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
|
|
|
if (event.type == DPEvent.Type.PROP_BOOL) {
|
|
|
- sendDpBool(event.dpid, value,time);
|
|
|
+ sendDpBool(event.dpid, value, time);
|
|
|
}
|
|
|
if (event.type == DPEvent.Type.PROP_VALUE) {
|
|
|
- sendDpValue(event.dpid, value,time);
|
|
|
+ sendDpValue(event.dpid, value, time);
|
|
|
}
|
|
|
if (event.type == DPEvent.Type.PROP_STR) {
|
|
|
- sendDpStr(event.dpid, String.valueOf(value),time);
|
|
|
+ sendDpStr(event.dpid, String.valueOf(value), time);
|
|
|
}
|
|
|
if (event.type == DPEvent.Type.PROP_ENUM) {
|
|
|
- sendDpEnum(event.dpid, value,time);
|
|
|
+ sendDpEnum(event.dpid, value, time);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -627,7 +595,7 @@ public class TuyaUtilsSo {
|
|
|
DevInfo info = CofarSDK.devInfo();
|
|
|
BaseDevMode mode = info.getMode();
|
|
|
int time = (int) System.currentTimeMillis();
|
|
|
- Log.v("tuya_iot",info.toString());
|
|
|
+ Log.v("tuya_iot", info.toString());
|
|
|
|
|
|
|
|
|
int status = info.getStatus();
|
|
@@ -757,16 +725,16 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
|
|
|
if (event.type == DPEvent.Type.PROP_BOOL) {
|
|
|
- sendDpBool(event.dpid, value,time);
|
|
|
+ sendDpBool(event.dpid, value, time);
|
|
|
}
|
|
|
if (event.type == DPEvent.Type.PROP_VALUE) {
|
|
|
- sendDpValue(event.dpid, value,time);
|
|
|
+ sendDpValue(event.dpid, value, time);
|
|
|
}
|
|
|
if (event.type == DPEvent.Type.PROP_STR) {
|
|
|
- sendDpStr(event.dpid, String.valueOf(value),time);
|
|
|
+ sendDpStr(event.dpid, String.valueOf(value), time);
|
|
|
}
|
|
|
if (event.type == DPEvent.Type.PROP_ENUM) {
|
|
|
- sendDpEnum(event.dpid, value,time);
|
|
|
+ sendDpEnum(event.dpid, value, time);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -926,15 +894,11 @@ public class TuyaUtilsSo {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private int getModes(String enumValue) {
|
|
|
|
|
|
|
|
|
- if (autoMaticType!=-1){
|
|
|
- return autoMaticType;
|
|
|
+ if (autoMaticType != -1) {
|
|
|
+ return autoMaticType;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1007,7 +971,7 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private int getAutoMaticModes(String enumValue){
|
|
|
+ private int getAutoMaticModes(String 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)
|
|
@@ -1082,7 +1046,7 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void sendDpEnum(int dpid, int value,int time_stamp) {
|
|
|
+ public void sendDpEnum(int dpid, int value, int time_stamp) {
|
|
|
Integer mapInt = map.get(dpid);
|
|
|
if (mapInt != null) {
|
|
|
int mapValue = mapInt.intValue();
|
|
@@ -1091,7 +1055,7 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- int code = getTuyaApi().send_dp_enum(dpid, value,time_stamp);
|
|
|
+ int code = getTuyaApi().send_dp_enum(dpid, value, time_stamp);
|
|
|
|
|
|
if (code == 0) {
|
|
|
map.put(dpid, value);
|
|
@@ -1100,12 +1064,12 @@ public class TuyaUtilsSo {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void sendDpStr(int dpid, String value,int time_stamp) {
|
|
|
+ public void sendDpStr(int dpid, String value, int time_stamp) {
|
|
|
|
|
|
- getTuyaApi().send_dp_str(dpid, value,time_stamp);
|
|
|
+ getTuyaApi().send_dp_str(dpid, value, time_stamp);
|
|
|
}
|
|
|
|
|
|
- public void sendDpValue(int dpid, int value,int time_stamp) {
|
|
|
+ public void sendDpValue(int dpid, int value, int time_stamp) {
|
|
|
Integer mapInt = map.get(dpid);
|
|
|
if (mapInt != null) {
|
|
|
int mapValue = mapInt.intValue();
|
|
@@ -1113,7 +1077,7 @@ public class TuyaUtilsSo {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- int code = getTuyaApi().send_dp_value(dpid, value,time_stamp);
|
|
|
+ int code = getTuyaApi().send_dp_value(dpid, value, time_stamp);
|
|
|
|
|
|
if (code == 0) {
|
|
|
map.put(dpid, value);
|
|
@@ -1121,7 +1085,7 @@ public class TuyaUtilsSo {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void sendDpBool(int dpid, int value,int time_stamp) {
|
|
|
+ public void sendDpBool(int dpid, int value, int time_stamp) {
|
|
|
Integer mapInt = map.get(dpid);
|
|
|
if (mapInt != null) {
|
|
|
int mapValue = mapInt.intValue();
|
|
@@ -1131,7 +1095,7 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
|
|
|
|
|
|
- int code = getTuyaApi().send_dp_bool(dpid, value,time_stamp);
|
|
|
+ int code = getTuyaApi().send_dp_bool(dpid, value, time_stamp);
|
|
|
|
|
|
|
|
|
if (code == 0) {
|
|
@@ -1139,8 +1103,9 @@ public class TuyaUtilsSo {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void setDpTemp() {
|
|
|
- getTuyaApi().send_dp_temp();
|
|
|
+ public void setDpCurrentActivity() {
|
|
|
+ int time = (int)System.currentTimeMillis();
|
|
|
+ getTuyaApi().send_dp_bool(TuyaSoDp.CURRENT_ACTIVITY,1,time);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1186,4 +1151,25 @@ public class TuyaUtilsSo {
|
|
|
getTuyaApi().log_message(tag, msg);
|
|
|
}
|
|
|
|
|
|
+ public void wakeUpScreen(Context context) {
|
|
|
+ PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
|
|
+
|
|
|
+ if (!powerManager.isInteractive()) {
|
|
|
+ PowerManager.WakeLock wakeLock = null;
|
|
|
+
|
|
|
+ if (powerManager != null) {
|
|
|
+ wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyApp::MyWakelockTag");
|
|
|
+
|
|
|
+ wakeLock.acquire(0);
|
|
|
+
|
|
|
+ if (wakeLock != null && wakeLock.isHeld()) {
|
|
|
+ wakeLock.release();
|
|
|
+ wakeLock = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|