LightOperationUtils.java
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.qnbar.smc.utils;
import android.util.Log;
import com.qnbar.smc.service.TelinkLightService;
/**
* Created by wugian on 2017/4/27
*/
public class LightOperationUtils {
public static void setLightValue(int value) {
int addr = 0xFFFF;//addr of all
//change group brightness or color temperature
// addr = 0x8003;
byte opcode;
byte[] params;
opcode = (byte) 0xD2;//brightness
params = new byte[]{(byte) value};
if (TelinkLightService.Instance() != null && TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true)) {
Log.d("LightOperationUtils", "setLightValue success");
} else {
Log.d("LightOperationUtils", "setLightValue:" + (TelinkLightService.Instance() != null));
}
// opcode = (byte) 0xE2;//temperature
// params = new byte[]{0x05, (byte) value};
// TelinkLightService.Instance().sendCommandNoResponse(opcode, addr, params, true);
}
public static void open() {
byte opcode = (byte) 0xD0;
int address = 0xFFFF;
byte[] params = new byte[]{0x01, 0x00, 0x00};
if (TelinkLightService.Instance() != null && TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) {
Log.d("LightOperationUtils", "open all success");
} else {
Log.d("LightOperationUtils", "open:" + (TelinkLightService.Instance() != null));
}
}
public static void close() {
byte opcode = (byte) 0xD0;
int address = 0xFFFF;
byte[] params = new byte[]{0x00, 0x00, 0x00};
if (TelinkLightService.Instance() != null && TelinkLightService.Instance().sendCommandNoResponse(opcode, address, params)) {
Log.d("LightOperationUtils", "close all success");
} else {
Log.d("LightOperationUtils", "close:" + (TelinkLightService.Instance() != null));
}
}
}