Skip to content

Commit 156b6ae

Browse files
migrate ook tests to java
1 parent dc9a238 commit 156b6ae

4 files changed

Lines changed: 22 additions & 107 deletions

File tree

test/test_app/pytest_fsk.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

test/test_app/pytest_ook.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/test_app/src/test/java/com/leosatdata/sx127x/FskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public void testRegisters() {
245245
assertEquals(preamble, rx.sx127x_fsk_ook_rx_get_preamble_detector());
246246
}
247247

248-
private static String createRandom(int length) {
248+
public static String createRandom(int length) {
249249
StringBuilder result = new StringBuilder();
250250
for (int i = 0; i < length; i++) {
251251
result.append(String.format("%02x", i % 255));

test/test_app/src/test/java/com/leosatdata/sx127x/OokTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ public void testReset() {
7070
assertEquals(new PeakMode(sx127x_ook_peak_thresh_step_t.SX127X_0_5_DB, 12, sx127x_ook_peak_thresh_dec_t.SX127X_1_1_CHIP), rx.sx127x_ook_rx_get_peak_mode());
7171
}
7272

73+
@Test
74+
public void testVariableLength() {
75+
rx.sx127x_fsk_ook_set_packet_format(new PacketFormat(sx127x_packet_format_t.VARIABLE, 255));
76+
rx.sx127x_set_opmod(new OpMode(sx127x_mode_t.RXCONT, sx127x_modulation_t.OOK));
77+
78+
tx.sx127x_set_opmod(new OpMode(sx127x_mode_t.SLEEP, sx127x_modulation_t.OOK));
79+
// it looks like some boards don't have RFO pin connected to the antenna
80+
tx.sx127x_tx_set_pa_config(new PaConfig(sx127x_pa_pin_t.BOOST, 4));
81+
tx.sx127x_fsk_ook_set_packet_format(new PacketFormat(sx127x_packet_format_t.VARIABLE, 255));
82+
83+
String small = FskTest.createRandom(2);
84+
tx.sx127x_fsk_ook_tx_set_for_transmission(small);
85+
tx.tx(sx127x_modulation_t.OOK);
86+
LoraTest.assertFrames(rx, small);
87+
88+
String maxSingleBatch = FskTest.createRandom(63);
89+
tx.sx127x_fsk_ook_tx_set_for_transmission(maxSingleBatch);
90+
tx.tx(sx127x_modulation_t.OOK);
91+
LoraTest.assertFrames(rx, maxSingleBatch);
92+
}
93+
7394
@Before
7495
public void start() {
7596
rx.reset();

0 commit comments

Comments
 (0)