From 0a199e2c204946309fef8a564c75b817329971cf Mon Sep 17 00:00:00 2001 From: saransh14 Date: Tue, 16 Apr 2024 02:20:02 +0530 Subject: [PATCH] Support for fetching the VendorIdentifier and SerialNumber information from BACnet device Added support for extracting deviceIdentifier and serialNumber from actual device. --- .../bacnet4j/wrapper/api/Device.java | 18 ++++++++++++++++++ .../wrapper/api/DiscoveryEventAdapter.java | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/api/src/main/java/org/code_house/bacnet4j/wrapper/api/Device.java b/api/src/main/java/org/code_house/bacnet4j/wrapper/api/Device.java index 3917e01..9f83ade 100644 --- a/api/src/main/java/org/code_house/bacnet4j/wrapper/api/Device.java +++ b/api/src/main/java/org/code_house/bacnet4j/wrapper/api/Device.java @@ -39,6 +39,8 @@ public class Device { private String modelName = ""; private String vendorName = ""; + private int vendorIdentifier ; + private String serialNumber = ""; private String name = ""; private boolean readMultiple; @@ -85,6 +87,22 @@ public String getVendorName() { return vendorName; } + public int getVendorIdentifier() { + return vendorIdentifier; + } + + public void setVendorIdentifier(int vendorIdentifier) { + this.vendorIdentifier = vendorIdentifier; + } + + public String getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } + public void setName(String name) { this.name = name; } diff --git a/api/src/main/java/org/code_house/bacnet4j/wrapper/api/DiscoveryEventAdapter.java b/api/src/main/java/org/code_house/bacnet4j/wrapper/api/DiscoveryEventAdapter.java index 9fe848f..4f4a32f 100644 --- a/api/src/main/java/org/code_house/bacnet4j/wrapper/api/DiscoveryEventAdapter.java +++ b/api/src/main/java/org/code_house/bacnet4j/wrapper/api/DiscoveryEventAdapter.java @@ -95,6 +95,13 @@ protected Device createDevice(RemoteDevice d) { if (d.getVendorName() != null && !d.getVendorName().isEmpty()) { device.setVendorName(d.getVendorName()); } + if (d.getVendorIdentifier() != -1) { + device.setVendorName(d.getVendorName()); + } + if (d.getCharacterStringProperty(PropertyIdentifier.serialNumber) != null + && !d.getCharacterStringProperty(PropertyIdentifier.serialNumber).isEmpty()) { + device.setSerialNumber(d.getCharacterStringProperty(PropertyIdentifier.serialNumber)); + } if (d.getName() != null && !d.getName().isEmpty()) { device.setName(d.getName()); }