From c858db1e216bfacd5fa5eecac0bd994b3fedf91b Mon Sep 17 00:00:00 2001 From: dernasherbrezon Date: Fri, 22 Dec 2023 22:30:48 +0000 Subject: [PATCH] fix unit test --- .../lora/loraat/gatt/GattServerTest.java | 12 ++++++----- .../gatt/LoraBleObservationRequest.java | 20 +++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/test/java/ru/r2cloud/lora/loraat/gatt/GattServerTest.java b/src/test/java/ru/r2cloud/lora/loraat/gatt/GattServerTest.java index 3e40a951..153b04d3 100644 --- a/src/test/java/ru/r2cloud/lora/loraat/gatt/GattServerTest.java +++ b/src/test/java/ru/r2cloud/lora/loraat/gatt/GattServerTest.java @@ -120,7 +120,7 @@ public void testInvalidArguments() throws Exception { byte[] empty = readValue(app.getSource(), application, GattServer.SCHEDULE_CHARACTERISTIC_UUID); assertEquals(0, empty.length); - + LoraFrame frame = createFrame(); writeValue(app.getSource(), application, serialize(frame), GattServer.SCHEDULE_CHARACTERISTIC_UUID); assertTrue(device.getFrames().isEmpty()); @@ -221,8 +221,8 @@ private void assertLoraRequest(Transmitter transmitter, long startTime, long end assertEquals(startTime, actual.getStartTimeMillis()); assertEquals(endTime, actual.getEndTimeMillis()); assertEquals(time, actual.getCurrentTime()); - assertEquals(transmitter.getFrequency() / 1_000_000.0f, actual.getFrequency(), 0.0f); - assertEquals(transmitter.getLoraBandwidth() / 1_000.0f, actual.getLoraBandwidth(), 0.0f); + assertEquals(transmitter.getFrequency(), actual.getFrequency()); + assertEquals(transmitter.getLoraBandwidth(), actual.getLoraBandwidth()); assertEquals(transmitter.getLoraSpreadFactor(), actual.getLoraSpreadFactor()); assertEquals(transmitter.getLoraCodingRate(), actual.getLoraCodingRate()); assertEquals(transmitter.getLoraSyncword(), actual.getLoraSyncword()); @@ -242,8 +242,8 @@ private static LoraBleObservationRequest deserialize(byte[] readValue) throws IO result.setStartTimeMillis(dis.readLong()); result.setEndTimeMillis(dis.readLong()); result.setCurrentTime(dis.readLong()); - result.setFrequency(dis.readFloat()); - result.setLoraBandwidth(dis.readFloat()); + result.setFrequency(dis.readLong()); + result.setLoraBandwidth(dis.readInt()); result.setLoraSpreadFactor(dis.readUnsignedByte()); result.setLoraCodingRate(dis.readUnsignedByte()); result.setLoraSyncword(dis.readUnsignedByte()); @@ -254,6 +254,8 @@ private static LoraBleObservationRequest deserialize(byte[] readValue) throws IO result.setLoraCrc(dis.readUnsignedByte()); result.setLoraExplicitHeader(dis.readUnsignedByte()); result.setBeaconSizeBytes(dis.readUnsignedByte()); + dis.skipBytes(2); // ocp + dis.skipBytes(1); // tx pin return result; } diff --git a/src/test/java/ru/r2cloud/lora/loraat/gatt/LoraBleObservationRequest.java b/src/test/java/ru/r2cloud/lora/loraat/gatt/LoraBleObservationRequest.java index e9685bb5..690bef07 100644 --- a/src/test/java/ru/r2cloud/lora/loraat/gatt/LoraBleObservationRequest.java +++ b/src/test/java/ru/r2cloud/lora/loraat/gatt/LoraBleObservationRequest.java @@ -5,8 +5,8 @@ public class LoraBleObservationRequest { private long startTimeMillis; private long endTimeMillis; private long currentTime; - private float frequency; - private float loraBandwidth; + private long frequency; + private long loraBandwidth; private int loraSpreadFactor; private int loraCodingRate; private int loraSyncword; @@ -42,22 +42,22 @@ public void setCurrentTime(long currentTime) { this.currentTime = currentTime; } - public float getFrequency() { + public long getFrequency() { return frequency; } - - public void setFrequency(float frequency) { + + public void setFrequency(long frequency) { this.frequency = frequency; } - - public float getLoraBandwidth() { + + public long getLoraBandwidth() { return loraBandwidth; } - - public void setLoraBandwidth(float loraBandwidth) { + + public void setLoraBandwidth(long loraBandwidth) { this.loraBandwidth = loraBandwidth; } - + public int getLoraSpreadFactor() { return loraSpreadFactor; }