Skip to content

Commit

Permalink
Implement LoRa Actility triangulated device location support
Browse files Browse the repository at this point in the history
  • Loading branch information
harism committed Sep 29, 2023
1 parent 00a508e commit b076994
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
abstract class ActilityBaseProvider extends JsonBasedLoraProvider {
protected static final String FIELD_ACTILITY_CHANNEL = "Channel";
protected static final String FIELD_ACTILITY_FPORT = "FPort";
protected static final String FIELD_ACTILITY_DEV_ALTITUDE = "DevAlt";
protected static final String FIELD_ACTILITY_DEV_LATITUDE = "DevLAT";
protected static final String FIELD_ACTILITY_DEV_LONGITUDE = "DevLON";
protected static final String FIELD_ACTILITY_FRAME_COUNT_UPLINK = "FCntUp";
protected static final String FIELD_ACTILITY_LATITUTDE = "LrrLAT";
protected static final String FIELD_ACTILITY_LONGITUDE = "LrrLON";
protected static final String FIELD_ACTILITY_LRR = "Lrr";
protected static final String FIELD_ACTILITY_LRR_ID = "Lrrid";
protected static final String FIELD_ACTILITY_LRR_LATITUDE = "LrrLAT";
protected static final String FIELD_ACTILITY_LRR_LONGITUDE = "LrrLON";
protected static final String FIELD_ACTILITY_LRR_RSSI = "LrrRSSI";
protected static final String FIELD_ACTILITY_LRR_SNR = "LrrSNR";
protected static final String FIELD_ACTILITY_LRRS = "Lrrs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ protected LoraMetaData extractMetaData(final JsonObject rootObject) {
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_CHANNEL, String.class)
.map(this::getFrequency)
.ifPresent(data::setFrequency);
Optional.ofNullable(LoraUtils.newLocation(
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_DEV_LONGITUDE, Double.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_DEV_LATITUDE, Double.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_DEV_ALTITUDE, Double.class)))
.ifPresent(data::setLocation);

LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LRRS, JsonObject.class)
.map(lrrs -> lrrs.getValue(FIELD_ACTILITY_LRR))
Expand All @@ -70,8 +75,8 @@ protected LoraMetaData extractMetaData(final JsonObject rootObject) {
.ifPresent(s -> gwId.ifPresent(id -> {
if (id.equals(s)) {
Optional.ofNullable(LoraUtils.newLocation(
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LONGITUDE, Double.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LATITUTDE, Double.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LRR_LONGITUDE, Double.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LRR_LATITUDE, Double.class),
Optional.empty()))
.ifPresent(gateway::setLocation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ protected LoraMetaData extractMetaData(final JsonObject rootObject) {
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_CHANNEL, String.class)
.map(this::getFrequency)
.ifPresent(data::setFrequency);
Optional.ofNullable(LoraUtils.newLocationFromString(
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_DEV_LONGITUDE, String.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_DEV_LATITUDE, String.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_DEV_ALTITUDE, String.class)))
.ifPresent(data::setLocation);

LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LRRS, JsonObject.class)
.map(lrrs -> lrrs.getValue(FIELD_ACTILITY_LRR))
Expand All @@ -74,8 +79,8 @@ protected LoraMetaData extractMetaData(final JsonObject rootObject) {
.ifPresent(s -> gwId.ifPresent(id -> {
if (id.equals(s)) {
Optional.ofNullable(LoraUtils.newLocationFromString(
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LONGITUDE, String.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LATITUTDE, String.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LRR_LONGITUDE, String.class),
LoraUtils.getChildObject(rootObject, FIELD_ACTILITY_LRR_LATITUDE, String.class),
Optional.empty()))
.ifPresent(gateway::setLocation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ protected void assertMetaDataForUplinkMessage(final UplinkLoraMessage loraMessag
assertThat(data.getFunctionPort()).isEqualTo(2);
assertThat(data.getFrameCount()).isEqualTo(57);
assertThat(data.getFrequency()).isEqualTo(868.5);

assertThat(data.getLocation().getLatitude()).isEqualTo(61.499146);
assertThat(data.getLocation().getLongitude()).isEqualTo(23.765516);
assertThat(data.getLocation().getAltitude()).isEqualTo(0.000001);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ protected void assertMetaDataForUplinkMessage(final UplinkLoraMessage loraMessag
assertThat(data.getGatewayInfo().get(0).getGatewayId()).isEqualTo("18035559");
assertThat(data.getGatewayInfo().get(0).getRssi()).isEqualTo(-48);
assertThat(data.getGatewayInfo().get(0).getSnr()).isEqualTo(3.0);
assertThat(data.getGatewayInfo().get(0).getLocation().getLatitude()).isEqualTo(53.108805);
assertThat(data.getGatewayInfo().get(0).getLocation().getLongitude()).isEqualTo(9.193430);
assertThat(data.getGatewayInfo().get(1).getGatewayId()).isEqualTo("18035560");
assertThat(data.getGatewayInfo().get(1).getRssi()).isEqualTo(-49);
assertThat(data.getGatewayInfo().get(1).getSnr()).isEqualTo(4.0);
assertThat(data.getGatewayInfo().get(1).getLocation()).isNull();

assertThat(data.getLocation().getLatitude()).isEqualTo(61.499146);
assertThat(data.getLocation().getLongitude()).isEqualTo(23.765516);
assertThat(data.getLocation().getAltitude()).isEqualTo(0.000001);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"DevLrrCnt": 1,
"Lrrid": "10000001",
"Late": 0,
"DevLAT": 61.499146,
"DevLON": 23.765516,
"DevAlt": 0.000001,
"LrrLAT": 27.831039,
"LrrLON": -97.534576,
"Lrrs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"DevLrrCnt": "1",
"Lrrid": "18035559",
"Late": "0",
"DevLAT": "61.499146",
"DevLON": "23.765516",
"DevAlt": "0.000001",
"LrrLAT": "53.108805",
"LrrLON": "9.193430",
"Lrrs": {
Expand Down

0 comments on commit b076994

Please sign in to comment.