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
33 changes: 31 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.beowulfe.hap</groupId>
<artifactId>hap-sample</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
<name>hap-java-sample</name>
<dependencies>
<dependency>
<groupId>io.github.hap-java</groupId>
<artifactId>hap</artifactId>
<version>1.2.0-snapshot</version>
<version>2.0.0-snapshot</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -28,6 +28,35 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.beowulfe.hap.sample.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
7 changes: 4 additions & 3 deletions src/main/java/com/beowulfe/hap/sample/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import io.github.hapjava.HomekitRoot;
import io.github.hapjava.HomekitServer;
import io.github.hapjava.server.impl.HomekitRoot;
import io.github.hapjava.server.impl.HomekitServer;

public class Main {

Expand All @@ -32,7 +32,8 @@ public static void main(String[] args) {
}

HomekitServer homekit = new HomekitServer(PORT);
HomekitRoot bridge = homekit.createBridge(mockAuth, "TestBridge", "TestBridge, Inc.", "G6", "111abe234");
HomekitRoot bridge = homekit.createBridge(mockAuth, "Test Bridge", "TestBridge, Inc.", "G6", "111abe234", "1.1", "1.2");


mockAuth.onChange(state -> {
try {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/beowulfe/hap/sample/MockAuthInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import java.math.BigInteger;
import java.security.InvalidAlgorithmParameterException;
import java.util.function.Consumer;
import io.github.hapjava.HomekitAuthInfo;
import io.github.hapjava.HomekitServer;

import io.github.hapjava.server.HomekitAuthInfo;
import io.github.hapjava.server.impl.HomekitServer;

/**
* This is a simple implementation that should never be used in actual production. The mac, salt, and privateKey
Expand Down
33 changes: 22 additions & 11 deletions src/main/java/com/beowulfe/hap/sample/MockSwitch.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.beowulfe.hap.sample;

import java.util.concurrent.CompletableFuture;
import io.github.hapjava.HomekitCharacteristicChangeCallback;
import io.github.hapjava.accessories.Lightbulb;

public class MockSwitch implements Lightbulb {
import io.github.hapjava.accessories.LightbulbAccessory;
import io.github.hapjava.accessories.optionalcharacteristic.AccessoryWithHardwareRevision;
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;

public class MockSwitch implements LightbulbAccessory, AccessoryWithHardwareRevision {

private boolean powerState = false;
private HomekitCharacteristicChangeCallback subscribeCallback = null;
Expand All @@ -15,8 +17,8 @@ public int getId() {
}

@Override
public String getLabel() {
return "Test Lightbulb";
public CompletableFuture<String> getName() {
return CompletableFuture.completedFuture("Test Switch Name");
}

@Override
Expand All @@ -25,18 +27,23 @@ public void identify() {
}

@Override
public String getSerialNumber() {
return "none";
public CompletableFuture<String> getSerialNumber() {
return CompletableFuture.completedFuture("Test SwitchSN");
}

@Override
public CompletableFuture<String> getModel() {
return CompletableFuture.completedFuture("TestSwitch Model");
}

@Override
public String getModel() {
return "none";
public CompletableFuture<String> getManufacturer() {
return CompletableFuture.completedFuture("Test SwitchManufacturer");
}

@Override
public String getManufacturer() {
return "none";
public CompletableFuture<String> getFirmwareRevision() {
return CompletableFuture.completedFuture("Test Switch Firmware");
}

@Override
Expand Down Expand Up @@ -66,4 +73,8 @@ public void unsubscribeLightbulbPowerState() {
this.subscribeCallback = null;
}

@Override
public CompletableFuture<String> getHardwareRevision() {
return CompletableFuture.completedFuture("Test Switch Hardware");
}
}
17 changes: 17 additions & 0 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="TRACE">
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout
pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="io.github" level="debug" additivity="false">
<AppenderRef ref="console"/>
</Logger>
<Root level="TRACE" additivity="false">
<AppenderRef ref="console" />
</Root>
</Loggers>
</Configuration>
2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</encoder>
</appender>

<logger name="com.beowulfe.hap" level="DEBUG" />
<logger name="io.github.hapjava" level="DEBUG" />

<root level="info">
<appender-ref ref="STDOUT" />
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/simplelogger.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.slf4j.simpleLogger.defaultLogLevel=DEBUG