Skip to content

Commit

Permalink
Store internal measurement as Number. Check URL when starting uploaders.
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrik committed Nov 18, 2023
1 parent 2a73ef0 commit aeff242
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ private SensorDataBridge(SensorDataBridgeConfig config) {
String version = getVersion();
LOG.info("Initializing SensorDataBridge application, version '{}'", version);

uploaders.add(SensComUploader.create(config.getSensComConfig(), version));
uploaders.add(OpenSenseUploader.create(config.getOpenSenseConfig()));

if (!config.getSensComConfig().getUrl().isEmpty()) {
uploaders.add(SensComUploader.create(config.getSensComConfig(), version));
}
if (!config.getOpenSenseConfig().getUrl().isEmpty()) {
uploaders.add(OpenSenseUploader.create(config.getOpenSenseConfig()));
}

geoLocationService = GeoLocationService.create(config.getGeoLocationConfig());

TtnConfig ttnConfig = config.getTtnConfig();
Expand Down Expand Up @@ -129,7 +133,7 @@ SensorData decodeTtnMessage(DecoderConfig config, TtnUplinkMessage uplink) throw
sensorData.addValue(ESensorItem.LORA_SNR, uplink.getSNR());
}
if (uplink.getSF() > 0) {
sensorData.addValue(ESensorItem.LORA_SF, (double) uplink.getSF());
sensorData.addValue(ESensorItem.LORA_SF, uplink.getSF());
}

// SPS30 specific decoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*/
public final class SensorData {

// start with a simple map containing one Double value per item
private final Map<ESensorItem, Double> items = new LinkedHashMap<>();
// start with a simple map containing one Number value per item
private final Map<ESensorItem, Number> items = new LinkedHashMap<>();

public boolean addValue(ESensorItem item, Double value) {
if (!item.inRange(value)) {
public boolean addValue(ESensorItem item, Number value) {
if ((value instanceof Double) && !item.inRange(value.doubleValue())) {
return false;
}
items.put(item, value);
Expand All @@ -24,6 +24,10 @@ public boolean hasValue(ESensorItem item) {
}

public Double getValue(ESensorItem item) {
return items.get(item).doubleValue();
}

public Number get(ESensorItem item) {
return items.get(item);
}

Expand Down

0 comments on commit aeff242

Please sign in to comment.