-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce value objects for Lora meta data
Added value objects to represent common meta data instead of using a generic map. Signed-off-by: Kai Hudalla <[email protected]>
- Loading branch information
1 parent
4e62471
commit 5c455da
Showing
34 changed files
with
1,533 additions
and
646 deletions.
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
adapters/lora-vertx/src/main/java/org/eclipse/hono/adapter/lora/GatewayInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/** | ||
* Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
|
||
package org.eclipse.hono.adapter.lora; | ||
|
||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A container for meta information about a Lora gateway. | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class GatewayInfo { | ||
|
||
@JsonProperty(LoraConstants.APP_PROPERTY_SNR) | ||
private Double snr; | ||
@JsonProperty(LoraConstants.APP_PROPERTY_RSS) | ||
private Integer rssi; | ||
@JsonProperty(LoraConstants.GATEWAY_ID) | ||
private String gatewayId; | ||
@JsonProperty(LoraConstants.APP_PROPERTY_CHANNEL) | ||
private Integer channel; | ||
@JsonProperty(LoraConstants.LOCATION) | ||
private Location location; | ||
|
||
/** | ||
* Gets the gateway's identifier. | ||
* | ||
* @return The identifier or {@code null} if unknown. | ||
* @throws NullPointerException if id is {@code null}. | ||
*/ | ||
public String getGatewayId() { | ||
return gatewayId; | ||
} | ||
|
||
/** | ||
* Sets the gateway's identifier. | ||
* | ||
* @param id The identifier or {@code null} if unknown. | ||
* @throws NullPointerException if id is {@code null}. | ||
*/ | ||
public void setGatewayId(final String id) { | ||
this.gatewayId = Objects.requireNonNull(id); | ||
} | ||
|
||
/** | ||
* Gets the concentrator IF channel that the gateway used for receiving | ||
* the data. | ||
* | ||
* @return The channel or {@code null} if unknown. | ||
*/ | ||
public Integer getChannel() { | ||
return channel; | ||
} | ||
|
||
/** | ||
* Sets the concentrator IF channel that the gateway used for receiving | ||
* the data. | ||
* | ||
* @param channel The channel or {@code null} if unknown. | ||
* @return This object for command chaining. | ||
*/ | ||
public GatewayInfo setChannel(final Integer channel) { | ||
this.channel = channel; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets the location of the receiving gateway. | ||
* | ||
* @return The location or {@code null} if unknown. | ||
*/ | ||
public Location getLocation() { | ||
return location; | ||
} | ||
|
||
/** | ||
* Sets the location of the receiving gateway. | ||
* | ||
* @param location The location or {@code null} if unknown. | ||
* @return This object for command chaining. | ||
*/ | ||
public GatewayInfo setLocation(final Location location) { | ||
this.location = location; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets the signal-to-noise ratio (SNR) detected by the | ||
* gateway when receiving the data. | ||
* | ||
* @return The ratio in dB or {@code null} if unknown. | ||
*/ | ||
public Double getSnr() { | ||
return snr; | ||
} | ||
|
||
/** | ||
* Sets the signal-to-noise ratio (SNR) detected by the | ||
* gateway when receiving the data. | ||
* | ||
* @param snr The ratio in dB or {@code null} if unknown. | ||
* @return This object for command chaining. | ||
*/ | ||
public GatewayInfo setSnr(final Double snr) { | ||
this.snr = snr; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets the received signal strength indicator (RSSI) detected by the | ||
* gateway when receiving the data. | ||
* | ||
* @return The RSSI value in dBm or {@code null} if unknown. | ||
*/ | ||
public Integer getRssi() { | ||
return rssi; | ||
} | ||
|
||
/** | ||
* Sets the received signal strength indicator (RSSI) detected by the | ||
* gateway when receiving the data. | ||
* | ||
* @param rssi The RSSI value in dBm or {@code null} if unknown. | ||
* @return This object for command chaining. | ||
* @throws IllegalArgumentException if the rssi value is positive. | ||
*/ | ||
public GatewayInfo setRssi(final Integer rssi) { | ||
if (rssi != null && rssi.intValue() > 0) { | ||
throw new IllegalArgumentException("RSSI value must be a negative integer"); | ||
} | ||
this.rssi = rssi; | ||
return this; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
adapters/lora-vertx/src/main/java/org/eclipse/hono/adapter/lora/Location.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
|
||
package org.eclipse.hono.adapter.lora; | ||
|
||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A 3D geo-location that consists of longitude, latitude and (optional) altitude. | ||
* | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public final class Location { | ||
|
||
@JsonProperty(LoraConstants.APP_PROPERTY_FUNCTION_LONGITUDE) | ||
private Double longitude; | ||
@JsonProperty(LoraConstants.APP_PROPERTY_FUNCTION_LATITUDE) | ||
private Double latitude; | ||
@JsonProperty(LoraConstants.APP_PROPERTY_FUNCTION_ALTITUDE) | ||
private Double altitude; | ||
|
||
/** | ||
* Creates a new location for coordinates. | ||
* | ||
* @param longitude The longitude in decimal degrees. | ||
* @param latitude The latitude in decimal degrees. | ||
* @param altitude The altitude in meters or {@code null} if unknown. | ||
* @throws NullPointerException if longitude or latitude are {@code null}. | ||
*/ | ||
public Location( | ||
@JsonProperty(value = LoraConstants.APP_PROPERTY_FUNCTION_LONGITUDE, required = true) final Double longitude, | ||
@JsonProperty(value = LoraConstants.APP_PROPERTY_FUNCTION_LATITUDE, required = true) final Double latitude, | ||
@JsonProperty(LoraConstants.APP_PROPERTY_FUNCTION_ALTITUDE) final Double altitude) { | ||
this.longitude = Objects.requireNonNull(longitude); | ||
this.latitude = Objects.requireNonNull(latitude); | ||
this.altitude = altitude; | ||
} | ||
|
||
/** | ||
* Gets the longitude of the location. | ||
* | ||
* @return The longitude in decimal degrees. | ||
*/ | ||
public Double getLongitude() { | ||
return longitude; | ||
} | ||
|
||
/** | ||
* Gets the latitude of the location. | ||
* | ||
* @return The latitude in decimal degrees. | ||
*/ | ||
public Double getLatitude() { | ||
return latitude; | ||
} | ||
|
||
/** | ||
* Gets the altitude of the location. | ||
* | ||
* @return The altitude in meters. | ||
*/ | ||
public Double getAltitude() { | ||
return altitude; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.