forked from badbadc0ffee/ogn-client-java
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
importing files
- Loading branch information
Showing
15 changed files
with
1,058 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.project | ||
.classpath | ||
.settings/ | ||
.target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.ogn</groupId> | ||
<artifactId>ogn-client-java</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<url>http://glidernet.org</url> | ||
<name>Open Glider Network (OGN)</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.ogn</groupId> | ||
<artifactId>ogn-commons-java</artifactId> | ||
<version>[,1.0.0)</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>1.7.5</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.2.4</version> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.2</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (c) 2014 OGN, All Rights Reserved. | ||
*/ | ||
|
||
package org.ogn.client; | ||
|
||
import org.ogn.commons.beacon.OgnBeacon; | ||
|
||
public interface OgnBeaconListener<BeaconType extends OgnBeacon> { | ||
void onUpdate(final BeaconType beacon); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2014 OGN, All Rights Reserved. | ||
*/ | ||
|
||
package org.ogn.client; | ||
|
||
import org.ogn.commons.beacon.AircraftBeacon; | ||
import org.ogn.commons.beacon.ReceiverBeacon; | ||
|
||
public interface OgnClient { | ||
|
||
/** | ||
* subscribes a listener to the aircraft beacons | ||
* | ||
* @param listener | ||
*/ | ||
void subscribeToAircraftBeacons(OgnBeaconListener<AircraftBeacon> listener); | ||
|
||
/** | ||
* unsubscribes a listener from receiving aircraft beacons | ||
* | ||
* @param listener | ||
*/ | ||
void unsubscribeFromAircraftBeacons(OgnBeaconListener<AircraftBeacon> listener); | ||
|
||
/** | ||
* subscribes a listener to the base stations beacons | ||
* | ||
* @param listener | ||
*/ | ||
void subscribeToReceiverBeacons(OgnBeaconListener<ReceiverBeacon> listener); | ||
|
||
/** | ||
* unsubscribes a listener from receiving base stations beacons | ||
* | ||
* @param listener | ||
*/ | ||
void unsubscribeFromReceiverBeacons(OgnBeaconListener<ReceiverBeacon> listener); | ||
|
||
/** | ||
* connects the client to the OGN APRS service (no filtering) | ||
*/ | ||
void connect(); | ||
|
||
/** | ||
* connects to the OGN APRS service | ||
* | ||
* @param aprsFilter optional APRS filter, if null no filter will be used, as it is in case of {@link #connect() | ||
* connect()}. | ||
* @see <a href="http://www.aprs-is.net/javAPRSFilter.aspx">Server-side Filter Commands</a> | ||
*/ | ||
void connect(String aprsFilter); | ||
|
||
/** | ||
* disconnects a client from the OGN APRS service | ||
*/ | ||
void disconnect(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2014 OGN, All Rights Reserved. | ||
*/ | ||
|
||
package org.ogn.client; | ||
|
||
public interface OgnClientConstants { | ||
String OGN_DEFAULT_SERVER_NAME = "aprs.glidernet.org"; | ||
String OGN_DEFAULT_APP_NAME = "ogn-client-java"; | ||
String OGN_DEFAULT_APP_VERSION = "1.0.0"; | ||
|
||
Integer OGN_DEFAULT_APRS_PORT = 10152; | ||
Integer OGN_DEFAULT_APRS_PORT_FILTERED = 14580; | ||
|
||
Integer OGN_DEFAULT_RECONNECTION_TIMEOUT_MS = 5000; | ||
Integer OGN_CLIENT_DEFAULT_KEEP_ALIVE_INTERVAL_MS = 15*60*1000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright (c) 2014 OGN, All Rights Reserved. | ||
*/ | ||
|
||
package org.ogn.client; | ||
|
||
import static org.ogn.client.OgnClientConstants.OGN_CLIENT_DEFAULT_KEEP_ALIVE_INTERVAL_MS; | ||
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APP_NAME; | ||
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APP_VERSION; | ||
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APRS_PORT; | ||
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APRS_PORT_FILTERED; | ||
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_RECONNECTION_TIMEOUT_MS; | ||
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_SERVER_NAME; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_APP_NAME; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_APP_VERSION; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_IGNORE_AIRCRAFT_BEACONS; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_IGNORE_RECEIVER_BEACONS; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_KEEP_ALIVE_INTERVAL; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_NAME; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_PORT_FILTERED; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_PORT_UNFILTERED; | ||
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_RECONNECTION_TIMEOUT; | ||
|
||
import org.ogn.client.aprs.AprsOgnClient; | ||
|
||
/** | ||
* This factory creates instances of OGN client. Several parameters can be tuned through the environment variables. | ||
* | ||
* @author wbuczak | ||
*/ | ||
public class OgnClientFactory { | ||
|
||
private static String serverName = System.getProperty(PROP_OGN_SRV_NAME, OGN_DEFAULT_SERVER_NAME); | ||
|
||
private static int port = Integer.getInteger(PROP_OGN_SRV_PORT_UNFILTERED, OGN_DEFAULT_APRS_PORT); | ||
private static int portFiltered = Integer.getInteger(PROP_OGN_SRV_PORT_FILTERED, OGN_DEFAULT_APRS_PORT_FILTERED); | ||
private static int reconnectionTimeout = Integer.getInteger(PROP_OGN_SRV_RECONNECTION_TIMEOUT, | ||
OGN_DEFAULT_RECONNECTION_TIMEOUT_MS); | ||
|
||
private static int keepAliveInterval = Integer.getInteger(PROP_OGN_CLIENT_KEEP_ALIVE_INTERVAL, | ||
OGN_CLIENT_DEFAULT_KEEP_ALIVE_INTERVAL_MS); | ||
|
||
private static String appName = System.getProperty(PROP_OGN_CLIENT_APP_NAME, OGN_DEFAULT_APP_NAME); | ||
private static String appVersion = System.getProperty(PROP_OGN_CLIENT_APP_VERSION, OGN_DEFAULT_APP_VERSION); | ||
|
||
private static boolean ignoreReceiverBeacons = System.getProperty(PROP_OGN_CLIENT_IGNORE_RECEIVER_BEACONS) != null; | ||
private static boolean ignoreAircraftBeacons = System.getProperty(PROP_OGN_CLIENT_IGNORE_AIRCRAFT_BEACONS) != null; | ||
|
||
public static OgnClient createClient() { | ||
return new AprsOgnClient.Builder().serverName(serverName).aprsPort(port).aprsPortFiltered(portFiltered) | ||
.reconnectionTimeout(reconnectionTimeout).appName(appName).appVersion(appVersion).keepAlive(keepAliveInterval) | ||
.ignoreReceiverBeacons(ignoreReceiverBeacons).ignoreAicraftrBeacons(ignoreAircraftBeacons).build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) 2014 OGN, All Rights Reserved. | ||
*/ | ||
|
||
package org.ogn.client; | ||
|
||
/** | ||
* declarations of the environment properties which can be set to overwrite the client's defaults | ||
* | ||
* @author wbuczak | ||
*/ | ||
public interface OgnClientProperties { | ||
String PROP_OGN_SRV_NAME = "ogn.server.name"; | ||
String PROP_OGN_SRV_PORT_UNFILTERED = "ogn.server.port_unfiltered"; | ||
String PROP_OGN_SRV_PORT_FILTERED = "ogn.server.port_filtered"; | ||
String PROP_OGN_SRV_RECONNECTION_TIMEOUT = "ogn.reconnection.timeout"; | ||
|
||
String PROP_OGN_CLIENT_APP_NAME = "ogn.app.name"; | ||
String PROP_OGN_CLIENT_APP_VERSION = "ogn.app.version"; | ||
|
||
String PROP_OGN_CLIENT_KEEP_ALIVE_INTERVAL = "ogn.client.keep_alive"; | ||
String PROP_OGN_CLIENT_IGNORE_RECEIVER_BEACONS = "ogn.client.ignore_receiver_beacons"; | ||
String PROP_OGN_CLIENT_IGNORE_AIRCRAFT_BEACONS = "ogn.client.ignore_aircraft_beacons"; | ||
} |
Oops, something went wrong.