22
33import io .github .hapjava .accessories .Bridge ;
44import io .github .hapjava .accessories .HomekitAccessory ;
5+ import io .github .hapjava .server .HomekitAccessoryCategories ;
56import io .github .hapjava .server .HomekitAuthInfo ;
67import io .github .hapjava .server .HomekitWebHandler ;
78import io .github .hapjava .server .impl .connections .HomekitClientConnectionFactoryImpl ;
2526public class HomekitRoot {
2627
2728 private static final Logger logger = LoggerFactory .getLogger (HomekitRoot .class );
28-
29+ private static final int DEFAULT_ACCESSORY_CATEGORY = HomekitAccessoryCategories . OTHER ;
2930 private final JmdnsHomekitAdvertiser advertiser ;
3031 private final HomekitWebHandler webHandler ;
3132 private final HomekitAuthInfo authInfo ;
3233 private final String label ;
34+ private final int category ;
3335 private final HomekitRegistry registry ;
3436 private final SubscriptionManager subscriptions = new SubscriptionManager ();
3537 private boolean started = false ;
3638 private int configurationIndex = 1 ;
3739
3840 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 )
4052 throws IOException {
41- this (label , webHandler , authInfo , new JmdnsHomekitAdvertiser (localhost ));
53+ this (label , category , webHandler , authInfo , new JmdnsHomekitAdvertiser (host ));
4254 }
4355
4456 HomekitRoot (
4557 String label ,
58+ int category ,
4659 HomekitWebHandler webHandler ,
4760 HomekitAuthInfo authInfo ,
4861 JmdnsHomekitAdvertiser advertiser )
@@ -51,14 +64,25 @@ public class HomekitRoot {
5164 this .webHandler = webHandler ;
5265 this .authInfo = authInfo ;
5366 this .label = label ;
67+ this .category = category ;
5468 this .registry = new HomekitRegistry (label );
5569 }
5670
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 )
5877 throws IOException {
59- this (label , webHandler , authInfo , new JmdnsHomekitAdvertiser (jmdns ));
78+ this (label , category , webHandler , authInfo , new JmdnsHomekitAdvertiser (jmdns ));
6079 }
6180
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+ }
6286 /**
6387 * Add an accessory to be handled and advertised by this root. Any existing HomeKit connections
6488 * will be terminated to allow the clients to reconnect and see the updated accessory list. When
@@ -127,7 +151,12 @@ public void start() {
127151 try {
128152 refreshAuthInfo ();
129153 advertiser .advertise (
130- label , authInfo .getMac (), port , configurationIndex , authInfo .getSetupId ());
154+ label ,
155+ category ,
156+ authInfo .getMac (),
157+ port ,
158+ configurationIndex ,
159+ authInfo .getSetupId ());
131160 } catch (Exception e ) {
132161 throw new RuntimeException (e );
133162 }
0 commit comments