Showing
1 changed file
with
41 additions
and
11 deletions
| ... | ... | @@ -46,6 +46,8 @@ import java.io.OutputStream; |
| 46 | 46 | import java.lang.ref.WeakReference; |
| 47 | 47 | import java.net.Socket; |
| 48 | 48 | import java.util.Arrays; |
| 49 | +import java.util.Timer; | |
| 50 | +import java.util.TimerTask; | |
| 49 | 51 | |
| 50 | 52 | //import static com.qnbar.smc.service.SocketService.JUST_OPEN_DOOR; |
| 51 | 53 | //import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR; |
| ... | ... | @@ -441,7 +443,7 @@ public class SocketService1 extends BaseService { |
| 441 | 443 | //获取serverId |
| 442 | 444 | ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class); |
| 443 | 445 | // String serverId = rps.getServerId(); |
| 444 | - reportEquStatus(rps.getServerId()); | |
| 446 | + reportEquStatus(rps.getServerId(),0); | |
| 445 | 447 | break; |
| 446 | 448 | |
| 447 | 449 | case SET_EQU_STATUS://设置声音,灯光,播放暂停 |
| ... | ... | @@ -487,7 +489,7 @@ public class SocketService1 extends BaseService { |
| 487 | 489 | } |
| 488 | 490 | } |
| 489 | 491 | |
| 490 | - private void reportEquStatus(String serverId) { | |
| 492 | + private void reportEquStatus(String serverId,int lightSet) { | |
| 491 | 493 | //填充返回数据 |
| 492 | 494 | int volume = getAudioVolume() / 6 + 1; |
| 493 | 495 | int lightStatus = 2; |
| ... | ... | @@ -499,10 +501,18 @@ public class SocketService1 extends BaseService { |
| 499 | 501 | } catch (RemoteException e) { |
| 500 | 502 | e.printStackTrace(); |
| 501 | 503 | } |
| 502 | - if (Lights.getInstance().getByMeshAddress( | |
| 503 | - ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status | |
| 504 | - == ConnectionStatus.ON) { | |
| 505 | - lightStatus = 1; | |
| 504 | + | |
| 505 | + if (lightSet == 1 || lightSet == 2) { | |
| 506 | + lightStatus = lightSet; | |
| 507 | + } else { | |
| 508 | + ConnectionStatus stu = Lights.getInstance().getByMeshAddress(((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status; | |
| 509 | + if( Lights.getInstance().getByMeshAddress( | |
| 510 | + ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status == ConnectionStatus.ON ) { | |
| 511 | + Log.d("ReportInfo","lightStatus==1"); | |
| 512 | + lightStatus = 1; | |
| 513 | + } else { | |
| 514 | + Log.d("ReportInfo", "lightStatus:"+stu); | |
| 515 | + } | |
| 506 | 516 | } |
| 507 | 517 | |
| 508 | 518 | EquipmentStatus equStatus = new EquipmentStatus(); |
| ... | ... | @@ -524,11 +534,26 @@ public class SocketService1 extends BaseService { |
| 524 | 534 | if (op == 1) {//打开灯光 |
| 525 | 535 | Log.d("setEqu", "打开灯光"); |
| 526 | 536 | LightOperationUtils.open(); |
| 527 | - LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50)); | |
| 528 | - } else if (op == 2) {//关闭灯光 | |
| 529 | - Log.d("setEqu", "关闭灯光"); | |
| 530 | 537 | LightOperationUtils.setLightValue(5); |
| 531 | - LightOperationUtils.close(); | |
| 538 | + | |
| 539 | + //延时增亮 | |
| 540 | + Timer timer=new Timer();//实例化Timer类 | |
| 541 | + timer.schedule(new TimerTask(){ | |
| 542 | + public void run(){ | |
| 543 | + LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50)); | |
| 544 | + this.cancel();}},2000);//毫秒 | |
| 545 | + } | |
| 546 | + else if(op == 2)//关闭灯光 | |
| 547 | + { | |
| 548 | + Log.d("setEqu","关闭灯光"); | |
| 549 | + LightOperationUtils.setLightValue(5); | |
| 550 | + | |
| 551 | + //延时关闭 | |
| 552 | + Timer timer=new Timer();//实例化Timer类 | |
| 553 | + timer.schedule(new TimerTask(){ | |
| 554 | + public void run(){ | |
| 555 | + LightOperationUtils.close(); | |
| 556 | + this.cancel();}},2000);//毫秒 | |
| 532 | 557 | } |
| 533 | 558 | } |
| 534 | 559 | |
| ... | ... | @@ -556,8 +581,13 @@ public class SocketService1 extends BaseService { |
| 556 | 581 | |
| 557 | 582 | setAudioVolume(equc.getAudioCtl()); |
| 558 | 583 | |
| 559 | - reportEquStatus(equc.getServerId()); | |
| 584 | + try { | |
| 585 | + Thread.sleep(500); | |
| 586 | + } catch (InterruptedException e) { | |
| 587 | + e.printStackTrace(); | |
| 588 | + } | |
| 560 | 589 | |
| 590 | + reportEquStatus(equc.getServerId(),equc.getLightCtl()); | |
| 561 | 591 | } |
| 562 | 592 | |
| 563 | 593 | /*--命令处理-end-----------------------------------*/ | ... | ... |
Please
register
or
login
to post a comment