Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@

<build>
<plugins>
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.6.0</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -272,19 +284,19 @@
<profile>
<id>ossrh</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
<gpg.defaultKeyring>false</gpg.defaultKeyring>
<gpg.publicKeyring>deploy/pubring.gpg</gpg.publicKeyring>
<gpg.secretKeyring>deploy/secring.gpg</gpg.secretKeyring>
</properties>
<gpg.executable>gpg</gpg.executable>
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
<gpg.defaultKeyring>false</gpg.defaultKeyring>
<gpg.publicKeyring>deploy/pubring.gpg</gpg.publicKeyring>
<gpg.secretKeyring>deploy/secring.gpg</gpg.secretKeyring>
</properties>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down
109 changes: 56 additions & 53 deletions src/main/java/com/beowulfe/hap/HomekitAccessory.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,67 @@
import java.util.Collection;

/**
* Base interface for all Homekit Accessories. You can implement this interface directly, but most users will
* prefer to use the more full featured interfaces in {@link com.beowulfe.hap.accessories} which include a
* default implementation of {@link #getServices()}.
*
* Base interface for all Homekit Accessories. You can implement this interface directly, but most
* users will prefer to use the more full featured interfaces in {@link
* com.beowulfe.hap.accessories} which include a default implementation of {@link #getServices()}.
*
* @author Andy Lintner
*/
public interface HomekitAccessory {

/**
* A unique identifier that must remain static across invocations to prevent errors with paired iOS devices. When used
* as a child of a Bridge, this value must be greater than 1, as that ID is reserved for the Bridge itself.
*
* @return the unique identifier.
*/
int getId();

/**
* Returns a label to display in iOS.
*
* @return the label.
*/
String getLabel();

/**
* Performs an operation that can be used to identify the accessory. This action can be performed without
* pairing.
*/
void identify();
/**
* A unique identifier that must remain static across invocations to prevent errors with paired
* iOS devices. When used as a child of a Bridge, this value must be greater than 1, as that ID is
* reserved for the Bridge itself.
*
* @return the unique identifier.
*/
int getId();

/**
* Returns a serial number to display in iOS.
*
* @return the serial number, or null.
*/
String getSerialNumber();
/**
* Returns a label to display in iOS.
*
* @return the label.
*/
String getLabel();

/**
* Returns a model name to display in iOS.
*
* @return the model name, or null.
*/
String getModel();
/**
* Performs an operation that can be used to identify the accessory. This action can be performed
* without pairing.
*/
void identify();

/**
* Returns a manufacturer to display in iOS.
*
* @return the manufacturer, or null.
*/
String getManufacturer();

/**
* The collection of Services this accessory supports. Services are the primary way to interact with the accessory via
* Homekit. Besides the Services offered here, the accessory will automatically include the required information service.
*
* This method will only be useful if you're implementing your own accessory type. For the standard accessories, use
* the default implementation provided by the interfaces in {@link com.beowulfe.hap.accessories}.
*
* @return the collection of services.
*/
Collection<Service> getServices();
/**
* Returns a serial number to display in iOS.
*
* @return the serial number, or null.
*/
String getSerialNumber();

/**
* Returns a model name to display in iOS.
*
* @return the model name, or null.
*/
String getModel();

/**
* Returns a manufacturer to display in iOS.
*
* @return the manufacturer, or null.
*/
String getManufacturer();

/**
* The collection of Services this accessory supports. Services are the primary way to interact
* with the accessory via Homekit. Besides the Services offered here, the accessory will
* automatically include the required information service.
*
* <p>This method will only be useful if you're implementing your own accessory type. For the
* standard accessories, use the default implementation provided by the interfaces in {@link
* com.beowulfe.hap.accessories}.
*
* @return the collection of services.
*/
Collection<Service> getServices();
}
141 changes: 74 additions & 67 deletions src/main/java/com/beowulfe/hap/HomekitAuthInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,86 @@
import java.math.BigInteger;

/**
* Authentication info that must be provided when constructing a new {@link HomekitServer}. You will need to implement
* this interface yourself to provide the necessary callbacks to a persistent storage mechanism. All values provided
* must be constant across invocations or the accessories will require re-pairing within iOS.
* Authentication info that must be provided when constructing a new {@link HomekitServer}. You will
* need to implement this interface yourself to provide the necessary callbacks to a persistent
* storage mechanism. All values provided must be constant across invocations or the accessories
* will require re-pairing within iOS.
*
* @author Andy Lintner
*/
public interface HomekitAuthInfo {

/**
* A pin code used for pairing the device. This pin will be required within iOS in order to complete pairing. The numbers
* cannot be sequential and should not have a repeating pattern.
*
* @return the pin code, in the form ###-##-###
*/
String getPin();

/**
* A unique MAC address to be advertised with the Homekit information. This does not have to be the MAC address of the
* network interface. You can generate this using {@link HomekitServer#generateMac()}.
*
* @return the unique MAC address.
*/
String getMac();
/**
* A pin code used for pairing the device. This pin will be required within iOS in order to
* complete pairing. The numbers cannot be sequential and should not have a repeating pattern.
*
* @return the pin code, in the form ###-##-###
*/
String getPin();

/**
* The Salt that will be used when hashing the pin code to send to the client. You should generate this using
* {@link HomekitServer#generateSalt()}.
*
* @return the Salt.
*/
BigInteger getSalt();
/**
* A unique MAC address to be advertised with the Homekit information. This does not have to be
* the MAC address of the network interface. You can generate this using {@link
* HomekitServer#generateMac()}.
*
* @return the unique MAC address.
*/
String getMac();

/**
* The private key used by the server during pairing and message encryption. You should generate this using
* {@link HomekitServer#generateKey()}
*
* @return the private key.
*/
byte[] getPrivateKey();

/**
* Called during the pairing process, you should store the user and public key in a manner that the public key can later
* be retrieved using {@link #getUserPublicKey(String)}. This must be stored in a persistent store as pairing will
* need to be reset if the information is lost.
*
* @param username the iOS device's username. The value will not be meaningful to anything but iOS.
* @param publicKey the iOS device's public key.
*/
void createUser(String username, byte[] publicKey);

/**
* Called when an iOS device needs to remove an existing pairing. Subsequent calls to {@link #getUserPublicKey(String)} for this
* username return null.
*
* @param username the username to delete from the persistent store.
*/
void removeUser(String username);
/**
* The Salt that will be used when hashing the pin code to send to the client. You should generate
* this using {@link HomekitServer#generateSalt()}.
*
* @return the Salt.
*/
BigInteger getSalt();

/**
* Called when an already paired iOS device is re-connecting. The public key returned by this method will be compared
* with the signature of the pair verification request to validate the device.
*
* @param username the username of the iOS device to retrieve the public key for.
* @return the previously stored public key for this user.
*/
byte[] getUserPublicKey(String username);

/**
* Called to check if a user has been created. The homekit accessory advertises whether the accessory has already been paired.
* At this time, it's unclear whether multiple users can be created, however it is known that advertising as unpaired
* will break in iOS 9. The default value has been provided to maintain API compatibility for implementations targeting iOS 8.
*
* @return whether a user has been created and stored
*/
default boolean hasUser() { return false; };
/**
* The private key used by the server during pairing and message encryption. You should generate
* this using {@link HomekitServer#generateKey()}
*
* @return the private key.
*/
byte[] getPrivateKey();

/**
* Called during the pairing process, you should store the user and public key in a manner that
* the public key can later be retrieved using {@link #getUserPublicKey(String)}. This must be
* stored in a persistent store as pairing will need to be reset if the information is lost.
*
* @param username the iOS device's username. The value will not be meaningful to anything but
* iOS.
* @param publicKey the iOS device's public key.
*/
void createUser(String username, byte[] publicKey);

/**
* Called when an iOS device needs to remove an existing pairing. Subsequent calls to {@link
* #getUserPublicKey(String)} for this username return null.
*
* @param username the username to delete from the persistent store.
*/
void removeUser(String username);

/**
* Called when an already paired iOS device is re-connecting. The public key returned by this
* method will be compared with the signature of the pair verification request to validate the
* device.
*
* @param username the username of the iOS device to retrieve the public key for.
* @return the previously stored public key for this user.
*/
byte[] getUserPublicKey(String username);

/**
* Called to check if a user has been created. The homekit accessory advertises whether the
* accessory has already been paired. At this time, it's unclear whether multiple users can be
* created, however it is known that advertising as unpaired will break in iOS 9. The default
* value has been provided to maintain API compatibility for implementations targeting iOS 8.
*
* @return whether a user has been created and stored
*/
default boolean hasUser() {
return false;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import com.beowulfe.hap.characteristics.EventableCharacteristic;

/**
* A callback interface for notifying subscribers that a characteristic value has changed.
*
* {@link EventableCharacteristic}s can be subscribed to, and in doing so, are supplied an instance of this class. Implementors
* should call the {@link #changed()} method on the passed object when a subscribed characteristic changes.
* A callback interface for notifying subscribers that a characteristic value has changed.
*
* <p>{@link EventableCharacteristic}s can be subscribed to, and in doing so, are supplied an
* instance of this class. Implementors should call the {@link #changed()} method on the passed
* object when a subscribed characteristic changes.
*
* @author Andy Lintner
*/
@FunctionalInterface
public interface HomekitCharacteristicChangeCallback {

/**
* Call when the value of the characteristic that was subscribed to when this object was passed changes.
*/
void changed();
/**
* Call when the value of the characteristic that was subscribed to when this object was passed
* changes.
*/
void changed();
}
Loading