2
2
3
3
import io .github .hapjava .accessories .Bridge ;
4
4
import io .github .hapjava .accessories .HomekitAccessory ;
5
+ import io .github .hapjava .server .HomekitAccessoryCategories ;
5
6
import io .github .hapjava .server .HomekitAuthInfo ;
6
7
import io .github .hapjava .server .HomekitWebHandler ;
7
8
import io .github .hapjava .server .impl .connections .HomekitClientConnectionFactoryImpl ;
25
26
public class HomekitRoot {
26
27
27
28
private static final Logger logger = LoggerFactory .getLogger (HomekitRoot .class );
28
-
29
+ private static final int DEFAULT_ACCESSORY_CATEGORY = HomekitAccessoryCategories . OTHER ;
29
30
private final JmdnsHomekitAdvertiser advertiser ;
30
31
private final HomekitWebHandler webHandler ;
31
32
private final HomekitAuthInfo authInfo ;
32
33
private final String label ;
34
+ private final int category ;
33
35
private final HomekitRegistry registry ;
34
36
private final SubscriptionManager subscriptions = new SubscriptionManager ();
35
37
private boolean started = false ;
36
38
private int configurationIndex = 1 ;
37
39
38
40
HomekitRoot (
39
- String label , HomekitWebHandler webHandler , InetAddress localhost , HomekitAuthInfo authInfo )
41
+ String label , HomekitWebHandler webHandler , InetAddress host , HomekitAuthInfo authInfo )
42
+ throws IOException {
43
+ this (label , DEFAULT_ACCESSORY_CATEGORY , webHandler , authInfo , new JmdnsHomekitAdvertiser (host ));
44
+ }
45
+
46
+ HomekitRoot (
47
+ String label ,
48
+ int category ,
49
+ HomekitWebHandler webHandler ,
50
+ InetAddress host ,
51
+ HomekitAuthInfo authInfo )
40
52
throws IOException {
41
- this (label , webHandler , authInfo , new JmdnsHomekitAdvertiser (localhost ));
53
+ this (label , category , webHandler , authInfo , new JmdnsHomekitAdvertiser (host ));
42
54
}
43
55
44
56
HomekitRoot (
45
57
String label ,
58
+ int category ,
46
59
HomekitWebHandler webHandler ,
47
60
HomekitAuthInfo authInfo ,
48
61
JmdnsHomekitAdvertiser advertiser )
@@ -51,14 +64,25 @@ public class HomekitRoot {
51
64
this .webHandler = webHandler ;
52
65
this .authInfo = authInfo ;
53
66
this .label = label ;
67
+ this .category = category ;
54
68
this .registry = new HomekitRegistry (label );
55
69
}
56
70
57
- HomekitRoot (String label , HomekitWebHandler webHandler , JmDNS jmdns , HomekitAuthInfo authInfo )
71
+ HomekitRoot (
72
+ String label ,
73
+ int category ,
74
+ HomekitWebHandler webHandler ,
75
+ JmDNS jmdns ,
76
+ HomekitAuthInfo authInfo )
58
77
throws IOException {
59
- this (label , webHandler , authInfo , new JmdnsHomekitAdvertiser (jmdns ));
78
+ this (label , category , webHandler , authInfo , new JmdnsHomekitAdvertiser (jmdns ));
60
79
}
61
80
81
+ HomekitRoot (String label , HomekitWebHandler webHandler , JmDNS jmdns , HomekitAuthInfo authInfo )
82
+ throws IOException {
83
+ this (
84
+ label , DEFAULT_ACCESSORY_CATEGORY , webHandler , authInfo , new JmdnsHomekitAdvertiser (jmdns ));
85
+ }
62
86
/**
63
87
* Add an accessory to be handled and advertised by this root. Any existing HomeKit connections
64
88
* will be terminated to allow the clients to reconnect and see the updated accessory list. When
@@ -127,7 +151,12 @@ public void start() {
127
151
try {
128
152
refreshAuthInfo ();
129
153
advertiser .advertise (
130
- label , authInfo .getMac (), port , configurationIndex , authInfo .getSetupId ());
154
+ label ,
155
+ category ,
156
+ authInfo .getMac (),
157
+ port ,
158
+ configurationIndex ,
159
+ authInfo .getSetupId ());
131
160
} catch (Exception e ) {
132
161
throw new RuntimeException (e );
133
162
}
0 commit comments