Commit a68df0d35938213984a989b2eca6f1193a0660b0

Authored by wugian
1 parent 3376fc75

light factory mode error charge

@@ -62,6 +62,7 @@ import com.gimi.common.cinema.model.MessageEvent; @@ -62,6 +62,7 @@ import com.gimi.common.cinema.model.MessageEvent;
62 import com.gimi.common.cinema.utils.AuthUtils; 62 import com.gimi.common.cinema.utils.AuthUtils;
63 import com.gimi.common.cinema.utils.LeeImageLoader; 63 import com.gimi.common.cinema.utils.LeeImageLoader;
64 import com.gimi.common.cinema.utils.M1905Utils; 64 import com.gimi.common.cinema.utils.M1905Utils;
  65 +import com.gimi.common.cinema.utils.NetStatusUtils;
65 import com.gimi.common.cinema.utils.OpenMMUtils; 66 import com.gimi.common.cinema.utils.OpenMMUtils;
66 import com.gimi.common.cinema.utils.ScreenUtils; 67 import com.gimi.common.cinema.utils.ScreenUtils;
67 import com.gimi.common.cinema.utils.SystemUtils; 68 import com.gimi.common.cinema.utils.SystemUtils;
@@ -1037,6 +1038,10 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen @@ -1037,6 +1038,10 @@ public class MainActivity extends BaseActivity implements IMainView, EventListen
1037 show("没有配置智能幕布"); 1038 show("没有配置智能幕布");
1038 return; 1039 return;
1039 } 1040 }
  1041 + if (!NetStatusUtils.isAvailableByPing(mDeviceIp)) {
  1042 + show("没有找到智能幕布");
  1043 + return;
  1044 + }
1040 messageThread = new MessageThread(); 1045 messageThread = new MessageThread();
1041 1046
1042 new Thread(messageThread).start(); 1047 new Thread(messageThread).start();
@@ -23,6 +23,7 @@ import android.os.Handler; @@ -23,6 +23,7 @@ import android.os.Handler;
23 import android.os.IBinder; 23 import android.os.IBinder;
24 import android.os.RemoteException; 24 import android.os.RemoteException;
25 import android.util.Log; 25 import android.util.Log;
  26 +import android.widget.Toast;
26 import com.gimi.common.cinema.model.MessageEvent; 27 import com.gimi.common.cinema.model.MessageEvent;
27 import com.gimi.common.cinema.utils.Utils; 28 import com.gimi.common.cinema.utils.Utils;
28 import com.qnbar.smc.model.Light; 29 import com.qnbar.smc.model.Light;
@@ -38,6 +39,7 @@ import java.util.ArrayList; @@ -38,6 +39,7 @@ import java.util.ArrayList;
38 import java.util.List; 39 import java.util.List;
39 40
40 public class CinemaControlService extends Service { 41 public class CinemaControlService extends Service {
  42 + private static final int LIGHT_MIN_VALUE = 5;
41 private ArrayList<String> movies = new ArrayList<>(); 43 private ArrayList<String> movies = new ArrayList<>();
42 private long duration = 0; 44 private long duration = 0;
43 private long currentPosition = 0; 45 private long currentPosition = 0;
@@ -175,7 +177,7 @@ public class CinemaControlService extends Service { @@ -175,7 +177,7 @@ public class CinemaControlService extends Service {
175 private Runnable openRunnable = new Runnable() { 177 private Runnable openRunnable = new Runnable() {
176 @Override 178 @Override
177 public void run() { 179 public void run() {
178 - if (value++ == 10) { 180 + if (value++ == LIGHT_MIN_VALUE) {
179 open(); 181 open();
180 handler.postDelayed(this, 2 * 1000); 182 handler.postDelayed(this, 2 * 1000);
181 } else { 183 } else {
@@ -255,6 +257,10 @@ public class CinemaControlService extends Service { @@ -255,6 +257,10 @@ public class CinemaControlService extends Service {
255 return; 257 return;
256 } 258 }
257 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); 259 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress);
  260 + if (byMeshAddress == null) {
  261 + Toast.makeText(context, "若智能灯光是出厂设置,请重新配置",Toast.LENGTH_SHORT).show();
  262 + return;
  263 + }
258 if (byMeshAddress.status == ConnectionStatus.ON) { 264 if (byMeshAddress.status == ConnectionStatus.ON) {
259 handler.removeCallbacks(closeRunnable); 265 handler.removeCallbacks(closeRunnable);
260 return; 266 return;
@@ -262,7 +268,7 @@ public class CinemaControlService extends Service { @@ -262,7 +268,7 @@ public class CinemaControlService extends Service {
262 maxValue = Utils.getInt(context, "brightness", 50); 268 maxValue = Utils.getInt(context, "brightness", 50);
263 // int status = mApplication.getConnectDevice().status; 269 // int status = mApplication.getConnectDevice().status;
264 // Log.d("status_charge", "fadeIn: " + status); 270 // Log.d("status_charge", "fadeIn: " + status);
265 - value = 10; 271 + value = LIGHT_MIN_VALUE;
266 handler.post(openRunnable); 272 handler.post(openRunnable);
267 } 273 }
268 274
@@ -273,6 +279,10 @@ public class CinemaControlService extends Service { @@ -273,6 +279,10 @@ public class CinemaControlService extends Service {
273 return; 279 return;
274 } 280 }
275 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress); 281 Light byMeshAddress = Lights.getInstance().getByMeshAddress(connectDevice.meshAddress);
  282 + if (byMeshAddress == null) {
  283 + Toast.makeText(context, "若智能灯光是出厂设置,请重新配置",Toast.LENGTH_SHORT).show();
  284 + return;
  285 + }
276 if (byMeshAddress.status == ConnectionStatus.OFF) { 286 if (byMeshAddress.status == ConnectionStatus.OFF) {
277 handler.removeCallbacks(openRunnable); 287 handler.removeCallbacks(openRunnable);
278 return; 288 return;
@@ -286,17 +296,15 @@ public class CinemaControlService extends Service { @@ -286,17 +296,15 @@ public class CinemaControlService extends Service {
286 } 296 }
287 297
288 private void setLightValue(int value) { 298 private void setLightValue(int value) {
289 - int addr = 0xFFFF; 299 + int addr = 0xFFFF;//addr of all
290 //change group brightness or color temperature 300 //change group brightness or color temperature
291 // addr = 0x8003; 301 // addr = 0x8003;
292 byte opcode; 302 byte opcode;
293 byte[] params; 303 byte[] params;
294 -  
295 opcode = (byte) 0xD2; 304 opcode = (byte) 0xD2;
296 params = new byte[]{(byte) value}; 305 params = new byte[]{(byte) value};
297 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); 306 TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
298 307
299 -  
300 // opcode = (byte) 0xE2; 308 // opcode = (byte) 0xE2;
301 // params = new byte[]{0x05, (byte) value}; 309 // params = new byte[]{0x05, (byte) value};
302 // TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true); 310 // TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
Please register or login to post a comment