GetGroupNotificationParser.java
1.12 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
/*
* Copyright (C) 2015 The Telink Bluetooth Light Project
*
*/
package com.telink.bluetooth.light;
import java.util.ArrayList;
import java.util.List;
/**
* 分组通知解析器
*/
public final class GetGroupNotificationParser extends NotificationParser<List<Integer>> {
private GetGroupNotificationParser() {
}
public static GetGroupNotificationParser create() {
return new GetGroupNotificationParser();
}
@Override
public byte opcode() {
return Opcode.BLE_GATT_OP_CTRL_D4.getValue();
}
@Override
public List<Integer> parse(NotificationInfo notifyInfo) {
List<Integer> mAddress = new ArrayList<>();
byte[] params = notifyInfo.params;
int length = params.length;
int position = 0;
int address;
while (position < length) {
address = params[position++];
address = address & 0xFF;
if (address == 0xFF)
break;
address = address | 0x8000;
mAddress.add(address);
}
return mAddress;
}
}