Skip to content

Commit 7145c94

Browse files
authored
Merge pull request #101 from yfre/refactoring_for_optional
Refactoring for optional
2 parents 8b77a6e + 6d13db3 commit 7145c94

File tree

450 files changed

+11061
-4534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

450 files changed

+11061
-4534
lines changed

CHANGES.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# HAP-Java 2.0.0
2+
* major refactoring to support optional characteristics
3+
* structure and names adapted to HAP spec structure and naming.
4+
* structure is following
5+
* `accessory` package include basis accessory as the listed in HAP spec, plus interfaces for optional characteristics. clients should extend the accessory classes. e.g. `WindowCoveringAccessory` or `AccessoryWithBrightness`
6+
* `characteristics` package consists of all characteristics, optional and mandatory. e.g. `TargetHorizontalTiltAngleCharacteristic`. The naming is done in accordance to HAP spec.
7+
* `services` package consists of services, which grouping characteristics. e.g. `WindowCoveringService` defines mandatory and optional characteristics for a window covering service as it is defined in HAP spec.
8+
* `server` package consists classes to run HomeKit server and handle communication
9+
* the process is following: client, e.g. openHAB bindings, extends accessory classes, e.g. `WindowCoveringAccessory` and implements all required methods. WindowCoveringAccessory is linked already to WindowCoveringService, that in turn is link to single characteristics.
10+
111
# HAP-Java 1.1.5
212

313
## Fixes

README.md

+58-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,74 @@
11
HAP-Java
22
=========
3-
HAP-Java is a Java implementation of the Homekit Accessory Protocol.
3+
HAP-Java is a Java implementation of the HomeKit Accessory Protocol.
44

5-
Using this library, you can create your own Homekit Accessory or Homekit Accessory Bridge.
6-
7-
Because the MFi Specification is closed to individual developers, and this implementation was made without access to that specification, it may not be complete. iOS devices do recognize and are able to interact with accessories exposed via this library however.
5+
Using this library, you can create your own HomeKit Accessory or HomeKit Accessory Bridge.
86

97
This library would not have been possible without [Tian Zhang](https://github.com/KhaosT) who did a lot of the hard work of figuring out how the protocol works in his NodeJS implementation.
108

119
Usage
1210
=========
1311
Include HAP-Java in your project using maven:
12+
1413
```
1514
<dependency>
1615
<groupId>io.github.hap-java</groupId>
1716
<artifactId>hap</artifactId>
18-
<version>1.2.0-SNAPSHOT</version>
17+
<version>2.0.0-SNAPSHOT</version>
1918
</dependency>
2019
```
2120

22-
After that, read the [Javadoc](http://beowulfe.github.io/HAP-Java/apidocs/) and check out the [Sample](https://github.com/beowulfe/HAP-Java/tree/sample).
21+
After that, check out the [Sample](https://github.com/hap-java/HAP-Java/tree/sample).
22+
23+
Supported HomeKit Accessories
24+
=========
25+
26+
Current implementation fully supports 37 HomeKit accessory/services.
27+
28+
| HomeKit Accessory & Service type | Supported by Java-HAP |
29+
|--------------------|--------------------|
30+
| Accessory Information | :white_check_mark: |
31+
| Air Purifier | :white_check_mark: |
32+
| Air Quality Sensor | :white_check_mark: |
33+
| Audio Stream Management | :x: |
34+
| Battery Service | :white_check_mark: |
35+
| Camera RTP Stream Management | :x: |
36+
| Carbon Dioxide Sensor | :white_check_mark: |
37+
| Carbon Monoxide Sensor | :white_check_mark: |
38+
| Contact Sensor | :white_check_mark: |
39+
| Data Stream Transport Management | :x: |
40+
| Door | :white_check_mark: |
41+
| Doorbell | :white_check_mark: |
42+
| Fan | :white_check_mark: |
43+
| Faucet | :white_check_mark: |
44+
| Filter Maintenance | :x: |
45+
| Garage Door Opener | :white_check_mark: |
46+
| HAP Protocol Information | :white_check_mark: |
47+
| Heater Cooler | :white_check_mark: |
48+
| Humidifier Dehumidifier | :white_check_mark: |
49+
| Humidity Sensor | :white_check_mark: |
50+
| Irrigation System | :white_check_mark: |
51+
| Leak Sensor | :white_check_mark: |
52+
| Light Bulb | :white_check_mark: |
53+
| Light Sensor | :white_check_mark: |
54+
| Lock Management | :x: |
55+
| Lock Mechanism | :white_check_mark: |
56+
| Microphone | :white_check_mark: |
57+
| Motion Sensor | :white_check_mark: |
58+
| Occupancy Sensor | :white_check_mark: |
59+
| Outlet | :white_check_mark: |
60+
| Security System | :white_check_mark: |
61+
| Service Label | :white_check_mark: |
62+
| Siri | :x: |
63+
| Slat | :white_check_mark: |
64+
| Smoke Sensor | :white_check_mark: |
65+
| Speaker | :white_check_mark: |
66+
| Stateless Programmable Switch | :white_check_mark: |
67+
| Switch | :white_check_mark: |
68+
| Target Control | :x: |
69+
| Target Control Management | :x: |
70+
| Temperature Sensor | :white_check_mark: |
71+
| Thermostat | :white_check_mark: |
72+
| Valve | :white_check_mark: |
73+
| Window | :white_check_mark: |
74+
| Window Covering | :white_check_mark: |

pom.xml

+47-14
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
<artifactId>hap</artifactId>
66
<name>hap-java</name>
77
<description>Homekit Accessory Protocol for Java</description>
8-
<version>1.2.0-snapshot</version>
8+
<version>2.0.0-snapshot</version>
99
<packaging>jar</packaging>
1010
<url>https://github.com/hap-java/HAP-Java</url>
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
</properties>
14+
<netty.version>4.1.42.Final</netty.version>
15+
16+
</properties>
1517

1618
<licenses>
1719
<license>
@@ -56,8 +58,44 @@
5658

5759
<dependency>
5860
<groupId>io.netty</groupId>
59-
<artifactId>netty-all</artifactId>
60-
<version>4.0.32.Final</version>
61+
<artifactId>netty-common</artifactId>
62+
<version>${netty.version}</version>
63+
</dependency>
64+
65+
<dependency>
66+
<groupId>io.netty</groupId>
67+
<artifactId>netty-buffer</artifactId>
68+
<version>${netty.version}</version>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>io.netty</groupId>
73+
<artifactId>netty-transport</artifactId>
74+
<version>${netty.version}</version>
75+
</dependency>
76+
77+
<dependency>
78+
<groupId>io.netty</groupId>
79+
<artifactId>netty-handler</artifactId>
80+
<version>${netty.version}</version>
81+
</dependency>
82+
83+
<dependency>
84+
<groupId>io.netty</groupId>
85+
<artifactId>netty-codec</artifactId>
86+
<version>${netty.version}</version>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>io.netty</groupId>
91+
<artifactId>netty-codec-http</artifactId>
92+
<version>${netty.version}</version>
93+
</dependency>
94+
95+
<dependency>
96+
<groupId>io.netty</groupId>
97+
<artifactId>netty-resolver</artifactId>
98+
<version>${netty.version}</version>
6199
</dependency>
62100

63101
<dependency>
@@ -102,12 +140,6 @@
102140
<version>3.4.1</version>
103141
</dependency>
104142

105-
<dependency>
106-
<groupId>commons-io</groupId>
107-
<artifactId>commons-io</artifactId>
108-
<version>2.4</version>
109-
</dependency>
110-
111143
<dependency>
112144
<groupId>junit</groupId>
113145
<artifactId>junit</artifactId>
@@ -163,9 +195,10 @@
163195
<plugin>
164196
<groupId>org.apache.maven.plugins</groupId>
165197
<artifactId>maven-javadoc-plugin</artifactId>
166-
<version>3.0.1</version>
198+
<version>3.2.0</version>
167199
<configuration>
168-
<excludePackageNames>io.github.hapjava.impl</excludePackageNames>
200+
<excludePackageNames>io.github.hapjava.server.impl</excludePackageNames>
201+
<source>8</source>
169202
</configuration>
170203
<executions>
171204
<execution>
@@ -178,7 +211,7 @@
178211
</plugin>
179212
<plugin>
180213
<artifactId>maven-assembly-plugin</artifactId>
181-
<version>3.1.0</version>
214+
<version>3.1.1</version>
182215
<configuration>
183216
<descriptors>
184217
<descriptor>deploy/distribution.xml</descriptor>
@@ -272,7 +305,7 @@
272305
<artifactId>maven-javadoc-plugin</artifactId>
273306
<version>3.0.1</version>
274307
<configuration>
275-
<excludePackageNames>io.github.hapjava.impl</excludePackageNames>
308+
<excludePackageNames>io.github.hapjava.server.impl</excludePackageNames>
276309
</configuration>
277310
<reportSets>
278311
<reportSet>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.airpurifier.CurrentAirPurifierStateEnum;
5+
import io.github.hapjava.characteristics.impl.airpurifier.TargetAirPurifierStateEnum;
6+
import io.github.hapjava.services.Service;
7+
import io.github.hapjava.services.impl.AirPurifierService;
8+
import java.util.Collection;
9+
import java.util.Collections;
10+
import java.util.concurrent.CompletableFuture;
11+
12+
/** An air purifier. */
13+
public interface AirPurifierAccessory extends HomekitAccessory {
14+
/**
15+
* Mandatory: Retrieves the current active state of the fan'.
16+
*
17+
* @return a future that will contain the binary state
18+
*/
19+
CompletableFuture<Boolean> isActive();
20+
21+
/**
22+
* Sets the active state of the fan
23+
*
24+
* @param state the binary state to set
25+
* @return a future that completes when the change is made
26+
* @throws Exception when the change cannot be made
27+
*/
28+
CompletableFuture<Void> setActive(boolean state) throws Exception;
29+
30+
/**
31+
* Subscribes to changes in the active state of the fan.
32+
*
33+
* @param callback the function to call when the direction changes.
34+
*/
35+
void subscribeActive(HomekitCharacteristicChangeCallback callback);
36+
37+
/** Unsubscribes from changes in the active state of the fan. */
38+
void unsubscribeActive();
39+
40+
/**
41+
* Retrieves the current state of the air purifier
42+
*
43+
* @return a future that will contain the state
44+
*/
45+
CompletableFuture<CurrentAirPurifierStateEnum> getCurrentState();
46+
47+
/**
48+
* Subscribes to changes in the state of the air purifier.
49+
*
50+
* @param callback the function to call when the state changes.
51+
*/
52+
void subscribeCurrentState(HomekitCharacteristicChangeCallback callback);
53+
54+
/** Unsubscribes from changes in the state of the air purifier. */
55+
void unsubscribeCurrentState();
56+
57+
/**
58+
* Retrieves the air purifier target state.
59+
*
60+
* @return a future that will contain the air purifier target state .
61+
*/
62+
CompletableFuture<TargetAirPurifierStateEnum> getTargetState();
63+
64+
/**
65+
* set target state the air purifier target state.
66+
*
67+
* @param state air purifier target state
68+
* @return a future that completes when the change is made
69+
*/
70+
CompletableFuture<Void> setTargetState(TargetAirPurifierStateEnum state);
71+
72+
/**
73+
* Subscribes to changes in the target state of the air purifier.
74+
*
75+
* @param callback the function to call when the target state changes.
76+
*/
77+
void subscribeTargetState(HomekitCharacteristicChangeCallback callback);
78+
79+
/** Unsubscribes from changes in the target state of the air purifier. */
80+
void unsubscribeTargetState();
81+
82+
@Override
83+
default Collection<Service> getServices() {
84+
return Collections.singleton(new AirPurifierService(this));
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.airquality.AirQualityEnum;
5+
import io.github.hapjava.services.Service;
6+
import io.github.hapjava.services.impl.AirQualityService;
7+
import java.util.Collection;
8+
import java.util.Collections;
9+
import java.util.concurrent.CompletableFuture;
10+
11+
/** An air quality accessory which can include several sensors. */
12+
public interface AirQualityAccessory extends HomekitAccessory {
13+
14+
/**
15+
* Retrieves the state of the air quality
16+
*
17+
* @return a future that will contain the state
18+
*/
19+
CompletableFuture<AirQualityEnum> getAirQuality();
20+
21+
/**
22+
* Subscribes to changes in the air quality
23+
*
24+
* @param callback the function to call when the air quality changes.
25+
*/
26+
void subscribeAirQuality(HomekitCharacteristicChangeCallback callback);
27+
28+
/** Unsubscribes from changes in the air quality. */
29+
void unsubscribeAirQuality();
30+
31+
@Override
32+
default Collection<Service> getServices() {
33+
return Collections.singleton(new AirQualityService(this));
34+
}
35+
}

0 commit comments

Comments
 (0)