Skip to content

Commit

Permalink
more accurate handling of gateways status
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoder committed Sep 26, 2024
1 parent 64fc06f commit b36e375
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 220 deletions.
2 changes: 1 addition & 1 deletion java/github-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>github-proxy</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-acs-switch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-acs-switch</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-atim-th/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-atim-th</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-atim-tm2d/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-atim-tm2d</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-atim-tmxd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-atim-tmxd</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-axioma/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-axioma</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-c8y/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-c8y</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-cayennelpp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-cayennelpp</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-elsys/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-elsys</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-example</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-lansitec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-lansitec</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-ms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-ms</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-nke/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-nke</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-pyrescom-classair/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-pyrescom</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-semtech/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-semtech</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-codec-senlab/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-codec-senlab</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-actility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-actility</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-chirpstack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-chirpstack</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-generic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-generic</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-kerlink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-kerlink</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-liveobjects/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-liveobjects</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-loriot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-loriot</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-ms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-ms</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.joda.time.DateTime;
import org.springframework.stereotype.Service;

import com.cumulocity.microservice.context.ContextService;
import com.cumulocity.microservice.context.credentials.MicroserviceCredentials;
import com.cumulocity.model.event.CumulocityAlarmStatuses;
import com.cumulocity.rest.representation.alarm.AlarmRepresentation;
import com.cumulocity.rest.representation.event.EventRepresentation;
Expand All @@ -18,6 +20,7 @@
import com.cumulocity.sdk.client.inventory.InventoryApi;
import com.cumulocity.sdk.client.measurement.MeasurementApi;

import c8y.ConnectionState;
import c8y.Hardware;
import c8y.IsDevice;
import c8y.Position;
Expand All @@ -43,8 +46,21 @@ public class LNSGatewayService {
private final MeasurementApi measurementApi;
private final LNSConnectorService lnsConnectorManager;
private final LoraContextService loraContextService;
private final ContextService<MicroserviceCredentials> contextService;
public static final String GATEWAY_ID_TYPE = "LoRa Gateway Id";

private MicroserviceCredentials createContextWithoutApiKey(MicroserviceCredentials source) {
return new MicroserviceCredentials(
source.getTenant(),
source.getUsername(),
source.getPassword(),
source.getOAuthAccessToken(),
"NOT_EXISTING", // added to replace context, check:
// com.cumulocity.microservice.context.annotation.EnableContextSupportConfiguration.contextScopeConfigurer
source.getTfaToken(),
null);
}

public void upsertGateways(LNSConnector connector) {
List<Gateway> gateways = connector.getGateways();
for (Gateway gateway : gateways) {
Expand Down Expand Up @@ -73,6 +89,10 @@ public void upsertGateways(LNSConnector connector) {
}
inventoryApi.update(mor);
loraContextService.log("Processing data for gateway {}", gateway.getName());
MicroserviceCredentials noAppKeyContext = createContextWithoutApiKey(contextService.getContext());
if (gateway.getStatus() == ConnectionState.AVAILABLE) {
contextService.runWithinContext(noAppKeyContext, () -> processData(mor, gateway.getData()));
}
processData(mor, gateway.getData());
}
}
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-objenious/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-objenious</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-orbiwise/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-orbiwise</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/lora-ns-ttn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
</parent>

<artifactId>lora-ns-ttn</artifactId>
Expand Down
6 changes: 2 additions & 4 deletions java/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<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>com.softwareag</groupId>
<artifactId>lora</artifactId>
<version>1.1.0</version>
<version>1.1.2</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Loading

0 comments on commit b36e375

Please sign in to comment.