Skip to content

Commit

Permalink
add support for rtl device id being serial number (SN)
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Jun 15, 2024
1 parent 5b1823a commit 79e6744
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/java/ru/r2cloud/sdr/RtlStatusProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ private SdrStatus getStatusInternally() {
if (m.find()) {
Integer actualDeviceId = parse(m.group(1));
if (actualDeviceId == null || actualDeviceId != expectedRtlDeviceId) {
continue;
actualDeviceId = parse(m.group(4));
if (actualDeviceId == null || actualDeviceId != expectedRtlDeviceId) {
continue;
}
}
result = new SdrStatus();
result.setStatus(DeviceConnectionStatus.CONNECTED);
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/ru/r2cloud/RtlStatusProcessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,19 @@ public void testSuccess() {
assertEquals(DeviceConnectionStatus.CONNECTED, result.getStatus());
assertEquals("Realtek, RTL2838UHIDIR, SN: 00000001", result.getModel());
}

@Test
public void testSerialNumber() {
rtlTestServer.mockTest(" 0: Realtek, RTL2838UHIDIR, SN: 00000400\n");
RtlStatusProcess dao = new RtlStatusProcess(config, new ProcessFactory(), 400, new ReentrantLock());
SdrStatus result = dao.getStatus();
assertEquals(DeviceConnectionStatus.CONNECTED, result.getStatus());
assertEquals("Realtek, RTL2838UHIDIR, SN: 00000400", result.getModel());
}

@Test
public void testAssertMultipleDongles() {
rtlTestServer.mockTest(" 1: Realtek, RTL2838UHIDIR, SN: 00000002\n 0: Realtek, RTL2838UHIDIR, SN: 00000001\n");
rtlTestServer.mockTest(" 1: Realtek, RTL2838UHIDIR, SN: 00000001\n 0: Realtek, RTL2838UHIDIR, SN: 00000001\n");
SdrStatus result = dao.getStatus();
assertEquals(DeviceConnectionStatus.CONNECTED, result.getStatus());
assertEquals("Realtek, RTL2838UHIDIR, SN: 00000001", result.getModel());
Expand Down

0 comments on commit 79e6744

Please sign in to comment.