Parameters.java
4.01 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright (C) 2015 The Telink Bluetooth Light Project
*
*/
package com.telink.bluetooth.light;
import android.support.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
public class Parameters {
public static final String PARAM_MESH_NAME = "com.telink.bluetooth.light.PARAM_MESH_NAME";
public static final String PARAM_OUT_OF_MESH = "com.telink.bluetooth.light.PARAM_OUT_OF_MESH";
public static final String PARAM_MESH_PASSWORD = "com.telink.bluetooth.light.PARAM_MESH_PASSWORD";
public static final String PARAM_NEW_MESH_NAME = "com.telink.bluetooth.light.PARAM_NEW_MESH_NAME";
public static final String PARAM_NEW_PASSWORD = "com.telink.bluetooth.light.PARAM_NEW_PASSWORD";
public static final String PARAM_TIMEOUT_SECONDS = "com.telink.bluetooth.light.PARAM_TIMEOUT_SECONDS";
public static final String PARAM_LONG_TERM_KEY = "com.telink.bluetooth.light.PARAM_LONG_TERM_KEY";
public static final String PARAM_AUTO_REFRESH_NOTIFICATION_REPEAT = "com.telink.bluetooth.light.PARAM_AUTO_REFRESH_NOTIFICATION_REPEAT";
public static final String PARAM_AUTO_REFRESH_NOTIFICATION_DELAY = "com.telink.bluetooth.light.PARAM_AUTO_REFRESH_NOTIFICATION_DELAY";
public static final String PARAM_OFFLINE_TIMEOUT_SECONDS = "com.telink.bluetooth.light.PARAM_OFFLINE_TIMEOUT_SECONDS";
public static final String PARAM_DEVICE_LIST = "com.telink.bluetooth.light.PARAM_DEVICE_LIST";
public static final String PARAM_SCAN_TIMEOUT_SECONDS = "com.telink.bluetooth.light.PARAM_SCAN_TIMEOUT_SECONDS";
public static final String PARAM_SCAN_TYPE_SINGLE = "com.telink.bluetooth.light.PARAM_SCAN_TYPE_SINGLE";
public static final String PARAM_AUTO_ENABLE_NOTIFICATION = "com.telink.bluetooth.light.PARAM_AUTO_ENABLE_NOTIFICATION";
private final Map<String, Object> mParams = new HashMap<>();
public Parameters() {
this.set(PARAM_OUT_OF_MESH, "out_of_mesh");
}
public static Parameters newInstance() {
return new Parameters();
}
public static LeScanParameters createScanParameters() {
return LeScanParameters.create();
}
public static LeUpdateParameters createUpdateParameters() {
return LeUpdateParameters.create();
}
public static LeAutoConnectParameters createAutoConnectParameters() {
return LeAutoConnectParameters.create();
}
public static LeRefreshNotifyParameters createRefreshNotifyParameters() {
return LeRefreshNotifyParameters.create();
}
public static LeOtaParameters createOtaParameters() {
return LeOtaParameters.create();
}
public static LeDeleteParameters createDeleteParameters() {
return LeDeleteParameters.create();
}
public Parameters set(String key, Object value) {
this.mParams.put(key, value);
return this;
}
public Object get(String key) {
return this.mParams.get(key);
}
@Nullable
public byte[] getBytes(String key) {
if (this.mParams.containsKey(key))
return (byte[]) this.mParams.get(key);
return null;
}
public int getInt(String key, int defaultValue) {
if (this.mParams.containsKey(key))
return (int) this.mParams.get(key);
return defaultValue;
}
public int getInt(String key) {
return this.getInt(key, 0);
}
public boolean getBoolean(String key, boolean defaultValue) {
if (this.mParams.containsKey(key))
return (boolean) this.mParams.get(key);
return defaultValue;
}
public String getString(String key) {
if (this.mParams.containsKey(key))
return (String) this.mParams.get(key);
return null;
}
public boolean getBoolean(String key) {
return this.getBoolean(key, false);
}
public boolean contains(String key) {
return this.mParams.containsKey(key);
}
public void clear() {
this.mParams.clear();
}
}