From 793ebd76f6531407243b217f96227e20f19724db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harri=20Sm=C3=A5tt?= Date: Sat, 7 Oct 2023 14:47:25 +0300 Subject: [PATCH] [#3557] Implement LoRa Actility triangulated device location support --- .../adapter/lora/providers/ActilityBaseProvider.java | 7 +++++-- .../lora/providers/ActilityEnterpriseProvider.java | 11 ++++++++--- .../lora/providers/ActilityWirelessProvider.java | 11 ++++++++--- .../providers/ActilityEnterpriseProviderTest.java | 6 +++++- .../lora/providers/ActilityWirelessProviderTest.java | 9 ++++++++- .../resources/payload/actilityEnterprise.uplink.json | 3 +++ .../resources/payload/actilityWireless.uplink.json | 3 +++ legal/src/main/resources/legal/NOTICE.md | 1 + 8 files changed, 41 insertions(+), 10 deletions(-) diff --git a/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityBaseProvider.java b/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityBaseProvider.java index 0bf13ccedc..2296896e1a 100644 --- a/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityBaseProvider.java +++ b/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityBaseProvider.java @@ -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"; diff --git a/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProvider.java b/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProvider.java index 4d8ab846f8..66cc97f545 100644 --- a/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProvider.java +++ b/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2020, 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -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)) @@ -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); } diff --git a/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProvider.java b/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProvider.java index 7b5cca5b31..e5ca138314 100644 --- a/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProvider.java +++ b/adapters/lora/src/main/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2019, 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -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)) @@ -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); } diff --git a/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProviderTest.java b/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProviderTest.java index e3c796ac4a..230c59d745 100644 --- a/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProviderTest.java +++ b/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityEnterpriseProviderTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2019, 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -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); } } diff --git a/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProviderTest.java b/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProviderTest.java index d74a14be14..cdaf4c4ed0 100644 --- a/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProviderTest.java +++ b/adapters/lora/src/test/java/org/eclipse/hono/adapter/lora/providers/ActilityWirelessProviderTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2019, 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -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); } } diff --git a/adapters/lora/src/test/resources/payload/actilityEnterprise.uplink.json b/adapters/lora/src/test/resources/payload/actilityEnterprise.uplink.json index 58c98de7a5..5bf0caa31c 100644 --- a/adapters/lora/src/test/resources/payload/actilityEnterprise.uplink.json +++ b/adapters/lora/src/test/resources/payload/actilityEnterprise.uplink.json @@ -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": { diff --git a/adapters/lora/src/test/resources/payload/actilityWireless.uplink.json b/adapters/lora/src/test/resources/payload/actilityWireless.uplink.json index 5625f6e6f4..38cd42552a 100644 --- a/adapters/lora/src/test/resources/payload/actilityWireless.uplink.json +++ b/adapters/lora/src/test/resources/payload/actilityWireless.uplink.json @@ -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": { diff --git a/legal/src/main/resources/legal/NOTICE.md b/legal/src/main/resources/legal/NOTICE.md index 28fd084b0e..ce85748f7f 100644 --- a/legal/src/main/resources/legal/NOTICE.md +++ b/legal/src/main/resources/legal/NOTICE.md @@ -25,6 +25,7 @@ of the Eclipse Public License 2.0 which is available at https://www.eclipse.org/ * Copyright 2020 Lari Hotari * Copyright 2022-2023 SOTEC GmbH & Co KG * Copyright 2023 Controlant hf. +* Copyright 2023 Harri Smått # Third-party Content