@@ -32,6 +32,7 @@ public class HomekitRoot {
3232 private final HomekitRegistry registry ;
3333 private final SubscriptionManager subscriptions = new SubscriptionManager ();
3434 private boolean started = false ;
35+ private int configurationIndex = 1 ;
3536
3637 HomekitRoot (String label , HomekitWebHandler webHandler , InetAddress localhost ,
3738 HomekitAuthInfo authInfo ) throws IOException {
@@ -101,7 +102,7 @@ public void start() {
101102 registry , subscriptions , advertiser )).thenAccept (port -> {
102103 try {
103104 refreshAuthInfo ();
104- advertiser .advertise (label , authInfo .getMac (), port );
105+ advertiser .advertise (label , authInfo .getMac (), port , configurationIndex );
105106 } catch (Exception e ) {
106107 throw new RuntimeException (e );
107108 }
@@ -120,7 +121,7 @@ public void stop() {
120121 /**
121122 * Refreshes auth info after it has been changed outside this library
122123 *
123- * @throws IOException if the info cannot be read
124+ * @throws IOException if there is an error in the underlying protocol, such as a TCP error
124125 */
125126 public void refreshAuthInfo () throws IOException {
126127 advertiser .setDiscoverable (!authInfo .hasUser ());
@@ -136,6 +137,27 @@ public void allowUnauthenticatedRequests(boolean allow) {
136137 registry .setAllowUnauthenticatedRequests (allow );
137138 }
138139
140+
141+ /**
142+ * By default, the bridge advertises itself at revision 1. If you make changes to the accessories you're
143+ * including in the bridge after your first call to {@link start()}, you should increment this number. The
144+ * behavior of the client if the configuration index were to decrement is undefined, so this implementation will
145+ * not manage the configuration index by automatically incrementing - preserving this state across invocations should
146+ * be handled externally.
147+ *
148+ * @param revision an integer, greater than or equal to one, indicating the revision of the accessory information
149+ * @throws IOException if there is an error in the underlying protocol, such as a TCP error
150+ */
151+ public void setConfigurationIndex (int revision ) throws IOException {
152+ if (revision < 1 ) {
153+ throw new IllegalArgumentException ("revision must be greater than or equal to 1" );
154+ }
155+ this .configurationIndex = revision ;
156+ if (this .started ) {
157+ advertiser .setConfigurationIndex (revision );
158+ }
159+ }
160+
139161 HomekitRegistry getRegistry () {
140162 return registry ;
141163 }
0 commit comments