kopia lustrzana https://github.com/bertrik/ttnhabbridge
Don't bother with application id
rodzic
69ccd9f000
commit
99953281c4
|
@ -12,9 +12,6 @@ import nl.sikken.bertrik.hab.lorawan.LoraWanUplinkMessage.ILoraWanUplink;
|
|||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public final class HeliumUplinkMessage implements ILoraWanUplink {
|
||||
|
||||
@JsonProperty("app_eui")
|
||||
String appEui = "";
|
||||
|
||||
@JsonProperty("fcnt")
|
||||
int fcnt;
|
||||
|
||||
|
@ -54,8 +51,8 @@ public final class HeliumUplinkMessage implements ILoraWanUplink {
|
|||
|
||||
@Override
|
||||
public LoraWanUplinkMessage toLoraWanUplinkMessage() {
|
||||
LoraWanUplinkMessage uplink = new LoraWanUplinkMessage("Helium", Instant.ofEpochMilli(reportedAt), appEui, name,
|
||||
fcnt, port, payload);
|
||||
LoraWanUplinkMessage uplink = new LoraWanUplinkMessage("Helium", Instant.ofEpochMilli(reportedAt), name, fcnt,
|
||||
port, payload);
|
||||
for (HotSpot hotSpot : hotSpots) {
|
||||
uplink.addGateway(hotSpot.name.trim(), hotSpot.latitude, hotSpot.longitude, Double.NaN);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ public final class LoraWanUplinkMessage {
|
|||
|
||||
private final String network;
|
||||
private final Instant time;
|
||||
private final String appId;
|
||||
private final String deviceId;
|
||||
private final int fcnt;
|
||||
private final int port;
|
||||
|
@ -25,10 +24,9 @@ public final class LoraWanUplinkMessage {
|
|||
private final byte[] payloadRaw;
|
||||
private final List<GatewayInfo> gateways = new ArrayList<>();
|
||||
|
||||
public LoraWanUplinkMessage(String network, Instant time, String appId, String deviceId, int fcnt, int port, byte[] payloadRaw) {
|
||||
public LoraWanUplinkMessage(String network, Instant time, String deviceId, int fcnt, int port, byte[] payloadRaw) {
|
||||
this.network = network;
|
||||
this.time = Instant.from(time);
|
||||
this.appId = appId;
|
||||
this.deviceId = deviceId;
|
||||
this.fcnt = fcnt;
|
||||
this.port = port;
|
||||
|
@ -47,10 +45,6 @@ public final class LoraWanUplinkMessage {
|
|||
return Instant.from(time);
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public String getDevId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
|
|
@ -91,8 +91,8 @@ public final class Ttnv3UplinkMessage implements ILoraWanUplink {
|
|||
@Override
|
||||
public LoraWanUplinkMessage toLoraWanUplinkMessage() {
|
||||
LoraWanUplinkMessage uplink = new LoraWanUplinkMessage("TheThingsNetwork", Instant.parse(receivedAt),
|
||||
endDeviceIds.applicationIds.applicationId, endDeviceIds.deviceId, uplinkMessage.fcnt,
|
||||
uplinkMessage.fport, uplinkMessage.payload);
|
||||
endDeviceIds.deviceId, uplinkMessage.fcnt, uplinkMessage.fport,
|
||||
uplinkMessage.payload);
|
||||
for (RxMetadata metadata : uplinkMessage.rxMetadata) {
|
||||
String id = metadata.gatewayIds.gatewayId.trim();
|
||||
if (id.isEmpty()) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public final class PayloadDecoderTest {
|
|||
@Test
|
||||
public void testCayenne2() throws DecodeException {
|
||||
LoraWanUplinkMessage message = new LoraWanUplinkMessage("LoRaWAN", Instant.parse("2020-02-05T22:00:58.930936Z"),
|
||||
"test", "test", 123, 1, Base64.getDecoder().decode("AYgH1ecAzV4AC7gCZwArAwIBhg=="));
|
||||
"test", 123, 1, Base64.getDecoder().decode("AYgH1ecAzV4AC7gCZwArAwIBhg=="));
|
||||
// decode payload
|
||||
PayloadDecoder decoder = new PayloadDecoder(EPayloadEncoding.CAYENNE);
|
||||
Sentence sentence = decoder.decode(message);
|
||||
|
|
|
@ -25,7 +25,6 @@ public final class HeliumUplinkMessageTest {
|
|||
}
|
||||
Assert.assertNotNull(helium);
|
||||
|
||||
Assert.assertEquals("6081F9D16837130E", helium.appEui);
|
||||
Assert.assertEquals(0, helium.fcnt);
|
||||
Assert.assertEquals("kissmapper", helium.name);
|
||||
Assert.assertEquals(1, helium.port);
|
||||
|
@ -42,7 +41,6 @@ public final class HeliumUplinkMessageTest {
|
|||
// decode to LoRaWAN message
|
||||
LoraWanUplinkMessage lorawan = helium.toLoraWanUplinkMessage();
|
||||
Assert.assertEquals(Instant.parse("2021-09-12T14:39:25.832Z"), lorawan.getTime());
|
||||
Assert.assertEquals("6081F9D16837130E", lorawan.getAppId());
|
||||
Assert.assertEquals("kissmapper", lorawan.getDevId());
|
||||
Assert.assertEquals(0, lorawan.getFcnt());
|
||||
Assert.assertEquals(1, lorawan.getPort());
|
||||
|
|
|
@ -22,7 +22,6 @@ public final class Ttnv3UplinkMessageTest {
|
|||
|
||||
LoraWanUplinkMessage uplinkMessage = message.toLoraWanUplinkMessage();
|
||||
|
||||
Assert.assertEquals("test2id", uplinkMessage.getAppId());
|
||||
Assert.assertEquals("v3demo1", uplinkMessage.getDevId());
|
||||
Assert.assertEquals(1, uplinkMessage.getPort());
|
||||
Assert.assertEquals(84, uplinkMessage.getFcnt());
|
||||
|
|
Ładowanie…
Reference in New Issue