Opcode.java
3.77 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Copyright (C) 2015 The Telink Bluetooth Light Project
*
*/
package com.telink.bluetooth.light;
import android.support.annotation.Nullable;
public enum Opcode {
/********************************************************************************
* Mesh Pairing Opcode
*******************************************************************************/
BLE_GATT_OP_PAIR_REQ((byte) 0x01, ""),
BLE_GATT_OP_PAIR_RSP((byte) 0x02, ""),
BLE_GATT_OP_PAIR_REJECT((byte) 0x03, ""),
BLE_GATT_OP_PAIR_NETWORK_NAME((byte) 0x04, ""),
BLE_GATT_OP_PAIR_PASS((byte) 0x05, ""),
BLE_GATT_OP_PAIR_LTK((byte) 0x06, ""),
BLE_GATT_OP_PAIR_CONFIRM((byte) 0x07, ""),
BLE_GATT_OP_PAIR_LTK_REQ((byte) 0x08, ""),
BLE_GATT_OP_PAIR_LTK_RSP((byte) 0x09, ""),
BLE_GATT_OP_PAIR_DELETE((byte) 0x0A, ""),
BLE_GATT_OP_PAIR_DEL_RSP((byte) 0x0B, ""),
BLE_GATT_OP_PAIR_ENC_REQ((byte) 0x0C, ""),
BLE_GATT_OP_PAIR_ENC_RSP((byte) 0x0D, ""),
BLE_GATT_OP_PAIR_ENC_FAIL((byte) 0x0E, ""),
/********************************************************************************
* Mesh Control Opcode
*******************************************************************************/
BLE_GATT_OP_CTRL_D0((byte) 0xD0, "on off"),
BLE_GATT_OP_CTRL_D1((byte) 0xD1, "reserved"),
BLE_GATT_OP_CTRL_D2((byte) 0xD2, "set brightness and color"),
BLE_GATT_OP_CTRL_D3((byte) 0xD3, "reserved"),
BLE_GATT_OP_CTRL_D4((byte) 0xD4, "response to short group id query"),
BLE_GATT_OP_CTRL_D5((byte) 0xD5, "response to long group id query"),
BLE_GATT_OP_CTRL_D6((byte) 0xD6, "response to long group id query"),
BLE_GATT_OP_CTRL_D7((byte) 0xD7, "add group or remove group"),
BLE_GATT_OP_CTRL_D8((byte) 0xD8, "reserved"),
BLE_GATT_OP_CTRL_D9((byte) 0xD9, "reserved"),
BLE_GATT_OP_CTRL_DA((byte) 0xDA, "status query"),
BLE_GATT_OP_CTRL_DB((byte) 0xDB, "status response"),
BLE_GATT_OP_CTRL_DC((byte) 0xDC, "online status report"),
BLE_GATT_OP_CTRL_DD((byte) 0xDD, "group id query"),
BLE_GATT_OP_CTRL_DE((byte) 0xDE, "reserved"),
BLE_GATT_OP_CTRL_DF((byte) 0xDF, "reserved"),
BLE_GATT_OP_CTRL_E0((byte) 0xE0, "set device address"),
BLE_GATT_OP_CTRL_E1((byte) 0xE1, "notify the device address information"),
BLE_GATT_OP_CTRL_E2((byte) 0xE2, "configure rgb value"),
BLE_GATT_OP_CTRL_E3((byte) 0xE3, "kick out / reset factory"),
BLE_GATT_OP_CTRL_E4((byte) 0xE4, "set device time"),
BLE_GATT_OP_CTRL_E5((byte) 0xE5, "alarm operation opcode"),
BLE_GATT_OP_CTRL_E6((byte) 0xE6, "get device alarm"),
BLE_GATT_OP_CTRL_E7((byte) 0xE7, "alarm response"),
BLE_GATT_OP_CTRL_E8((byte) 0xE8, "get device time"),
BLE_GATT_OP_CTRL_E9((byte) 0xE9, "time response"),
BLE_GATT_OP_CTRL_EA((byte) 0xEA, "user all"),
BLE_GATT_OP_CTRL_EB((byte) 0xEB, "user all notify"),
BLE_GATT_OP_CTRL_EE((byte) 0xEE, "scene operation opcode"),
BLE_GATT_OP_CTRL_EF((byte) 0xEF, "load scene opcode"),
BLE_GATT_OP_CTRL_C0((byte) 0xC0, "get scene opcode"),
BLE_GATT_OP_CTRL_C1((byte) 0xC1, "scene response"),;
private final byte value;
private final String info;
Opcode(byte value, @Nullable String info) {
this.value = value;
this.info = info;
}
public static Opcode valueOf(byte value) {
value = (byte) (value & 0xFF);
byte opcodeValue;
Opcode[] opcodes = Opcode.values();
for (Opcode opcode : opcodes) {
opcodeValue = opcode.getValue();
if (opcodeValue == value)
return opcode;
}
return null;
}
public byte getValue() {
return (byte) (value & 0xFF);
}
public String getInfo() {
return info;
}
}