100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Updated SNMPClientAgent and SNMPClientProtocol to use bind host and bind port instead of host and port
Michael Rademaker634741986a3d
diff --git a/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientAgent.java b/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientAgent.javaindex 072c30f6e..bbdbff9d2 100644--- a/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientAgent.java+++ b/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientAgent.java@@ -64,8 +64,8 @@ public class SNMPClientAgent extends Agent<SNMPClientAgent, SNMPClientProtocol,public static final ValueDescriptor<SNMPVersion> VALUE_SNMP_VERSION = new ValueDescriptor<>("sNMPVersion", SNMPVersion.class);public static final AttributeDescriptor<SNMPVersion> SNMP_VERSION = new AttributeDescriptor<>("sNMPVersionValue", VALUE_SNMP_VERSION);- public static final AttributeDescriptor<String> SNMP_HOST = HOST.withOptional(false);- public static final AttributeDescriptor<Integer> SNMP_PORT = PORT.withOptional(false);+ public static final AttributeDescriptor<String> SNMP_BIND_HOST = BIND_HOST.withOptional(false);+ public static final AttributeDescriptor<Integer> SNMP_BIND_PORT = BIND_PORT.withOptional(false);public static final AgentDescriptor<SNMPClientAgent, SNMPClientProtocol, SNMPAgentLink> DESCRIPTOR = new AgentDescriptor<>(diff --git a/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientProtocol.javaindex ecf67e083..5d3af7e48 100644--- a/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/snmp/SNMPClientProtocol.java@@ -40,24 +40,24 @@ public class SNMPClientProtocol extends AbstractProtocol<SNMPClientAgent, SNMPCl@Overridepublic String getProtocolInstanceUri() {- return String.format("snmp:%s:%d?protocol=udp&type=TRAP&snmpVersion=%d",- agent.getHost().orElse(""),- agent.getPort().orElse(162),- agent.getSNMPVersion().orElse(SNMPClientAgent.SNMPVersion.V2c).getVersion());+ return String.format("snmp:%s:%d?protocol=udp&type=TRAP&snmpVersion=%s",+ agent.getBindHost().orElse(""),+ agent.getBindPort().orElse(162),+ agent.getSNMPVersion().orElse(SNMPClientAgent.SNMPVersion.V2c).getValue());}@Overrideprotected void doStart(Container container) throws Exception {- String snmpHost = agent.getHost().orElseThrow(() -> {- String msg = "No SNMP host provided for protocol: " + this;+ String snmpBindHost = agent.getBindHost().orElseThrow(() -> {+ String msg = "No SNMP bind host provided for protocol: " + this;LOG.info(msg);return new IllegalArgumentException(msg);});- Integer snmpPort = agent.getPort().orElse(162);+ Integer snmpBindPort = agent.getBindPort().orElse(162);SNMPClientAgent.SNMPVersion snmpVersion = agent.getSNMPVersion().orElse(SNMPClientAgent.SNMPVersion.V2c);- String snmpUri = String.format("snmp:%s:%d?protocol=udp&type=TRAP&snmpVersion=%d", snmpHost, snmpPort, snmpVersion.getVersion());+ String snmpUri = String.format("snmp:%s:%d?protocol=udp&type=TRAP&snmpVersion=%d", snmpBindHost, snmpBindPort, snmpVersion.getVersion());messageBrokerContext.addRoutes(new RouteBuilder() {@Override@@ -65,8 +65,7 @@ public class SNMPClientProtocol extends AbstractProtocol<SNMPClientAgent, SNMPClfrom(snmpUri).routeId(getProtocolName() + getAgent().getId()).process(exchange -> {- // Since we are using Snmp, we get SnmpMessage object, we need to typecast from Message- SnmpMessage msg = (SnmpMessage) exchange.getIn();+ SnmpMessage msg = exchange.getIn(SnmpMessage.class);PDU pdu = msg.getSnmpMessage();pdu.getVariableBindings().forEach(variableBinding -> {AttributeRef attributeRef = oidMap.get(variableBinding.getOid().format());