forked from hap-java/HAP-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacteristic.java
More file actions
57 lines (51 loc) · 2.03 KB
/
Characteristic.java
File metadata and controls
57 lines (51 loc) · 2.03 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
package io.github.hapjava.characteristics;
import java.util.concurrent.CompletableFuture;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonValue;
/**
* Interface for the characteristics provided by a Service.
*
* <p>Characteristics are the lowest level building block of the HomeKit Accessory Protocol. They
* define variables that can be retrieved or set by the remote client. Most consumers of this
* library will be better served by using one of the characteristic classes in {@link
* io.github.hapjava.characteristics} when creating custom accessory types (the standard accessories
* from {@link io.github.hapjava.accessories} already include the necessary characteristics),
* instead of trying to implement the JSON formats directly.
*
* @author Andy Lintner
*/
public interface Characteristic {
/** @return The UUID type for this characteristic. */
String getType();
/**
* Adds an attribute to the passed JsonObjectBuilder named "value" with the current value of the
* characteristic.
*
* @param characteristicBuilder the JsonObjectBuilder to add the value attribute to.
*/
void supplyValue(JsonObjectBuilder characteristicBuilder);
/**
* Creates the JSON representation of the characteristic, in accordance with the HomeKit Accessory
* Protocol.
*
* @param iid The instance ID of the characteristic to be included in the serialization.
* @return the future completing with the resulting JSON.
*/
CompletableFuture<JsonObject> toJson(int iid);
/**
* Invoked by the remote client, this updates the current value of the characteristic.
*
* @param jsonValue the JSON serialized value to set.
*/
void setValue(JsonValue jsonValue);
/**
* Invoked by the remote client, this updates the current value of the characteristic.
*
* @param jsonValue the JSON serialized value to set.
* @param username the authenticated username making the request
*/
default void setValue(JsonValue jsonValue, String username) {
setValue(jsonValue);
}
}