mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
Add support for SDDP IDENTIFY packets (#4263)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
parent
8aa6b28104
commit
940a9905db
@ -85,6 +85,7 @@ public class SddpDiscoveryService extends AbstractDiscoveryService
|
||||
private static final String SEARCH_RESPONSE_HEADER = "SDDP/1.0 200 OK";
|
||||
|
||||
private static final String NOTIFY_ALIVE_HEADER = "NOTIFY ALIVE SDDP/1.0";
|
||||
private static final String NOTIFY_IDENTIFY_HEADER = "NOTIFY IDENTIFY SDDP/1.0";
|
||||
private static final String NOTIFY_OFFLINE_HEADER = "NOTIFY OFFLINE SDDP/1.0";
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SddpDiscoveryService.class);
|
||||
@ -160,7 +161,7 @@ public class SddpDiscoveryService extends AbstractDiscoveryService
|
||||
if (lines.size() > 1) {
|
||||
String statement = lines.get(0).strip();
|
||||
boolean offline = statement.startsWith(NOTIFY_OFFLINE_HEADER);
|
||||
if (offline || statement.startsWith(NOTIFY_ALIVE_HEADER)
|
||||
if (offline || statement.startsWith(NOTIFY_ALIVE_HEADER) || statement.startsWith(NOTIFY_IDENTIFY_HEADER)
|
||||
|| statement.startsWith(SEARCH_RESPONSE_HEADER)) {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
|
@ -54,6 +54,18 @@ public class SddpDiscoveryServiceTests {
|
||||
Driver: "projector_JVCKENWOOD_DLA-RS3100_NZ8.c4i"
|
||||
""";
|
||||
|
||||
private static final String IDENTIFY_NOTIFICATION = """
|
||||
NOTIFY IDENTIFY SDDP/1.0
|
||||
From: "192.168.4.237:1902"
|
||||
Host: "JVC_PROJECTOR-E0DADC152802"
|
||||
Type: "JVCKENWOOD:Projector"
|
||||
Primary-Proxy: "projector"
|
||||
Proxies: "projector"
|
||||
Manufacturer: "JVCKENWOOD"
|
||||
Model: "DLA-RS3100_NZ8"
|
||||
Driver: "projector_JVCKENWOOD_DLA-RS3100_NZ8.c4i"
|
||||
""";
|
||||
|
||||
private static final String BAD_HEADER = """
|
||||
SDDP/1.0 404 NOT FOUND\r
|
||||
From: "192.168.4.237:1902"\r
|
||||
@ -115,6 +127,29 @@ public class SddpDiscoveryServiceTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIdentifyNotification() throws Exception {
|
||||
try (SddpDiscoveryService service = new SddpDiscoveryService(null, networkAddressService,
|
||||
mock(TranslationProvider.class), mock(LocaleProvider.class))) {
|
||||
Optional<SddpDevice> deviceOptional = service.createSddpDevice(IDENTIFY_NOTIFICATION);
|
||||
assertTrue(deviceOptional.isPresent());
|
||||
SddpDevice device = deviceOptional.orElse(null);
|
||||
assertNotNull(device);
|
||||
assertEquals("192.168.4.237:1902", device.from);
|
||||
assertEquals("JVC_PROJECTOR-E0DADC152802", device.host);
|
||||
assertTrue(device.maxAge.isBlank());
|
||||
assertEquals("JVCKENWOOD:Projector", device.type);
|
||||
assertEquals("projector", device.primaryProxy);
|
||||
assertEquals("projector", device.proxies);
|
||||
assertEquals("JVCKENWOOD", device.manufacturer);
|
||||
assertEquals("DLA-RS3100_NZ8", device.model);
|
||||
assertEquals("projector_JVCKENWOOD_DLA-RS3100_NZ8.c4i", device.driver);
|
||||
assertEquals("192.168.4.237", device.ipAddress);
|
||||
assertEquals("e0-da-dc-15-28-02", device.macAddress);
|
||||
assertEquals("1902", device.port);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBadHeader() throws Exception {
|
||||
try (SddpDiscoveryService service = new SddpDiscoveryService(null, networkAddressService,
|
||||
|
Loading…
Reference in New Issue
Block a user