kopia lustrzana https://github.com/bertrik/ttnhabbridge
Put the antenna altitude in the listener doc "antenna" field.
rodzic
96062144e7
commit
5cc5bc7a02
|
@ -169,7 +169,7 @@ public final class HabitatUploader {
|
|||
|
||||
// upload payload listener info
|
||||
LOG.info("Sending listener info using UUID {}...", uuids.get(0));
|
||||
final ListenerInformationDoc info = new ListenerInformationDoc(date, receiver.getCallsign());
|
||||
final ListenerInformationDoc info = new ListenerInformationDoc(date, receiver);
|
||||
final UploadResult infoResult = restClient.uploadDocument(uuids.get(0), info.format());
|
||||
LOG.info("Result from uploading listener info: {}", infoResult);
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package nl.sikken.bertrik.hab.habitat.docs;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import nl.sikken.bertrik.hab.habitat.HabReceiver;
|
||||
|
||||
/**
|
||||
* Listener information doc.
|
||||
*
|
||||
|
@ -15,7 +18,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|||
*/
|
||||
public final class ListenerInformationDoc extends ListenerDoc {
|
||||
|
||||
private final String callSign;
|
||||
private final HabReceiver receiver;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -23,16 +26,18 @@ public final class ListenerInformationDoc extends ListenerDoc {
|
|||
* @param date the date
|
||||
* @param callSign the listener call sign
|
||||
*/
|
||||
public ListenerInformationDoc(Date date, String callSign) {
|
||||
public ListenerInformationDoc(Date date, HabReceiver receiver) {
|
||||
super("listener_information", date);
|
||||
this.callSign = callSign;
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonNode createDataNode() {
|
||||
final ObjectNode node = factory().objectNode();
|
||||
node.set("callsign", factory().textNode(callSign));
|
||||
node.set("callsign", factory().textNode(receiver.getCallsign()));
|
||||
node.set("radio", factory().textNode("TheThingsNetwork"));
|
||||
final String antenna = String.format(Locale.US, "%.0f m", receiver.getLocation().getAlt());
|
||||
node.set("antenna", factory().textNode(antenna));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ import nl.sikken.bertrik.hab.Sentence;
|
|||
*/
|
||||
public final class HabitatUploaderTest {
|
||||
|
||||
private static final Location LOCATION = new Location(52.0162, 4.4735, 5);
|
||||
|
||||
/**
|
||||
* Happy flow scenario for payload upload.
|
||||
*/
|
||||
|
@ -29,7 +31,7 @@ public final class HabitatUploaderTest {
|
|||
// verify upload using the uploader
|
||||
uploader.start();
|
||||
try {
|
||||
final HabReceiver receiver = new HabReceiver("BERTRIK", null);
|
||||
final HabReceiver receiver = new HabReceiver("BERTRIK", LOCATION);
|
||||
final Date date = new Date();
|
||||
final Sentence sentence = new Sentence("NOTAFLIGHT", 1, date, 52.0182307, 4.695772, 1000);
|
||||
|
||||
|
@ -56,7 +58,7 @@ public final class HabitatUploaderTest {
|
|||
// verify upload using the uploader
|
||||
uploader.start();
|
||||
try {
|
||||
final HabReceiver receiver = new HabReceiver("BERTRIK", null);
|
||||
final HabReceiver receiver = new HabReceiver("BERTRIK", LOCATION);
|
||||
final Date date = new Date();
|
||||
|
||||
uploader.scheduleListenerDataUpload(receiver, date);
|
||||
|
|
|
@ -5,6 +5,9 @@ import java.util.Date;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import nl.sikken.bertrik.hab.habitat.HabReceiver;
|
||||
import nl.sikken.bertrik.hab.habitat.Location;
|
||||
|
||||
/**
|
||||
* Unit tests for ListenerInfoDoc
|
||||
*/
|
||||
|
@ -16,7 +19,8 @@ public final class ListenerInfoDocTest {
|
|||
@Test
|
||||
public void testFormat() {
|
||||
final Date date = new Date();
|
||||
final ListenerInformationDoc doc = new ListenerInformationDoc(date, "BERTRIK");
|
||||
final HabReceiver receiver = new HabReceiver("BERTRIK", new Location(52.0162, 4.4753, 0.0));
|
||||
final ListenerInformationDoc doc = new ListenerInformationDoc(date, receiver);
|
||||
final String json = doc.format();
|
||||
|
||||
Assert.assertNotNull(json);
|
||||
|
|
Ładowanie…
Reference in New Issue