Fix parsing of mac address in SDDP Discovery (#4284)

* Fix SDDP mac address

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
mlobstein 2024-07-01 10:56:08 -05:00 committed by GitHub
parent d2489bb65e
commit 425d0f43f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -35,8 +35,8 @@ public class SddpDevice {
/**
* The host address of the device.
* For example: JVC_PROJECTOR-E0DADC152802
* Note: the last 12 characters represent the MAC address of the device.
* For example: JVC_PROJECTOR-E0DADC152802 or JVC_PROJECTOR-E0:DA:DC:15:28:02
* Note: the last 12 resp. 17 characters represent the MAC address of the device.
*/
public final String host;
@ -131,7 +131,7 @@ public class SddpDevice {
String[] hostParts = host.split("-|_");
macAddress = hostParts.length <= 1 ? ""
: hostParts[hostParts.length - 1].replaceAll("(..)(?!$)", "$1-").toLowerCase();
: hostParts[hostParts.length - 1].replace(":", "").replaceAll("(..)(?!$)", "$1-").toLowerCase();
expireInstant = offline ? Instant.now().minusMillis(1)
: Instant.now().plusSeconds(maxAge.isBlank() ? 0 : Integer.parseInt(maxAge));

View File

@ -57,7 +57,7 @@ public class SddpDiscoveryServiceTests {
private static final String IDENTIFY_NOTIFICATION = """
NOTIFY IDENTIFY SDDP/1.0
From: "192.168.4.237:1902"
Host: "JVC_PROJECTOR-E0DADC152802"
Host: "JVC_PROJECTOR-E0:DA:DC:15:28:02"
Type: "JVCKENWOOD:Projector"
Primary-Proxy: "projector"
Proxies: "projector"
@ -136,7 +136,7 @@ public class SddpDiscoveryServiceTests {
SddpDevice device = deviceOptional.orElse(null);
assertNotNull(device);
assertEquals("192.168.4.237:1902", device.from);
assertEquals("JVC_PROJECTOR-E0DADC152802", device.host);
assertEquals("JVC_PROJECTOR-E0:DA:DC:15:28:02", device.host);
assertTrue(device.maxAge.isBlank());
assertEquals("JVCKENWOOD:Projector", device.type);
assertEquals("projector", device.primaryProxy);