wangzhibo
4 天以前 ae6f40460dcd56af6c5f60ba52c883854c3bac55
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
package nodomain.freeyourgadget.gadgetbridge.devices.huawei;
 
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
 
public class HuaweiReportThreshold {
    private int dataType;
    private int valueType;
    private int value;
    private int action;
 
    public HuaweiReportThreshold(int dataType, int valueType, int value, int action) {
        this.dataType = dataType;
        this.valueType = valueType;
        this.value = value;
        this.action = action;
    }
 
    public byte[] getBytes() {
        ByteBuffer buffer = ByteBuffer.allocate(5);
        buffer.put((byte) dataType);
        buffer.put((byte) valueType);
        buffer.putShort((short) value);
        buffer.put((byte) action);
        return buffer.array();
    }
 
    public static List<HuaweiReportThreshold> getReportThresholds() {
        List<HuaweiReportThreshold> thresholds = new ArrayList<>();
        thresholds.add(new HuaweiReportThreshold(1,3, 500, 2));
        thresholds.add(new HuaweiReportThreshold(3,3, 100, 2));
 
        int current_hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        int value = (current_hour < 6)?21600:3600;
        thresholds.add(new HuaweiReportThreshold(4,3, value, 2));
 
        return thresholds;
    }
}