Skip to content

Commit

Permalink
lora-at2 accepts time in milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Dec 28, 2023
1 parent c858db1 commit 829e56a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public LoraStatus getStatus() {
public LoraResponse startObservation(LoraObservationRequest loraRequest) {
// make sure lora internal clock is OK
try {
sendRequest("AT+TIME=" + (clock.millis() / 1000));
sendRequest("AT+TIME=" + clock.millis());
} catch (LoraAtException e) {
return new LoraResponse(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void testFailToSetTime() {
LoraResponse response = client.startObservation(createRequest());
assertEquals(ResponseStatus.FAILURE, response.getStatus());
assertEquals("controlled failure", response.getFailureMessage());
assertEquals("AT+TIME=1649679986\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
assertEquals("AT+TIME=1649679986400\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
}

@Test
Expand All @@ -146,7 +146,7 @@ public void testFailToStart() {
LoraResponse response = client.startObservation(createRequest());
assertEquals(ResponseStatus.FAILURE, response.getStatus());
assertEquals("controlled failure", response.getFailureMessage());
assertEquals("AT+TIME=1649679986\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
assertEquals("AT+TIME=1649679986400\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
}

@Test
Expand All @@ -155,7 +155,7 @@ public void testRetryAfterFailure() {
LoraAtClient client = new LoraAtSerialClient2(UUID.randomUUID().toString(), 0, new SerialMock(true, new MultiStreamInputStream("loraat2/success.txt", "loraat2/failureAlreadyReceiving.txt", "loraat2/successStop.txt", "loraat2/success.txt"), baos), new SteppingClock(1649679986400L, 1000));
LoraResponse response = client.startObservation(createRequest());
assertEquals(ResponseStatus.SUCCESS, response.getStatus());
assertEquals("AT+TIME=1649679986\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\nAT+STOPRX\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
assertEquals("AT+TIME=1649679986400\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\nAT+STOPRX\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
}

@Test
Expand All @@ -164,7 +164,7 @@ public void testSuccessRx() {
LoraAtClient client = new LoraAtSerialClient2(UUID.randomUUID().toString(), 0, new SerialMock(true, new MultiStreamInputStream("loraat2/success.txt", "loraat2/success.txt"), baos), new SteppingClock(1649679986400L, 1000));
LoraResponse response = client.startObservation(createRequest());
assertEquals(ResponseStatus.SUCCESS, response.getStatus());
assertEquals("AT+TIME=1649679986\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
assertEquals("AT+TIME=1649679986400\r\nAT+LORARX=433125000,500000,9,7,18,8,0,0,1,1,255\r\n", new String(baos.toByteArray(), StandardCharsets.ISO_8859_1));
}

private static LoraObservationRequest createRequest() {
Expand Down

0 comments on commit 829e56a

Please sign in to comment.