Examples of SnmpBindingProvider


Examples of org.openhab.binding.snmp.SnmpBindingProvider

   */
  @Override
  public void internalReceiveCommand(String itemName, Command command) {
    logger.debug("SNMP receive command {} from {}", itemName, command);
   
    SnmpBindingProvider providerCmd = null;
   
    for (SnmpBindingProvider provider : this.providers) {
      OID oid = provider.getOID(itemName, command);
      if (oid != null) {
        providerCmd = provider;
        break;
      }
    }

    if (providerCmd == null) {
      logger.warn("No match for binding provider [itemName={}, command={}]", itemName, command);
      return;
    }

    logger.debug("SNMP command for {} to {}", itemName, providerCmd.toString());

    // Set up the target
    CommunityTarget target = new CommunityTarget();
      target.setCommunity(providerCmd.getCommunity(itemName, command));
      target.setAddress(providerCmd.getAddress(itemName, command));
      target.setRetries(retries);
      target.setTimeout(timeout);
      target.setVersion(SnmpConstants.version1);

    Variable var = providerCmd.getValue(itemName, command);
    OID oid = providerCmd.getOID(itemName, command);
      VariableBinding varBind = new VariableBinding(oid,var);

    // Create the PDU
    PDU pdu = new PDU();
      pdu.add(varBind);
      pdu.setType(PDU.SET);
      pdu.setRequestID(new Integer32(1));

    logger.debug("SNMP: Send CMD PDU {} {}", providerCmd.getAddress(itemName, command), pdu);

    if (snmp == null) {
      logger.error("SNMP: snmp not initialised - aborting request");
    }
    else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.