Class SnmpPrinter

Object
com.zebra.sdk.printer.SnmpPrinter

public class SnmpPrinter extends Object
An instance of an SNMP only Zebra printer. The printer does not make a raw port connection.

package test.zebra.sdk.printer.examples;
 
 import com.zebra.sdk.printer.SnmpException;
 import com.zebra.sdk.printer.SnmpPrinter;
 
 public class SnmpPrinterExample {
 
     public static void main(String[] args) {
         try {
             SnmpPrinter myPrinter = new SnmpPrinter("1.2.3.4", "getCommunityName", "setCommunityName");
 
             String printAdjOid = "1.3.6.1.4.1.10642.6.4.0";
             String printAdjFromSnmp = myPrinter.getOidValue(printAdjOid);
             System.out.println("printAdj = " + printAdjFromSnmp);
 
             int newprintAdj = Integer.parseInt(printAdjFromSnmp) + 1;
             myPrinter.setOidValue(printAdjOid, newprintAdj);
 
             String friendlyNameOid = "1.3.6.1.4.1.10642.20.3.5.0";
             String friendlyNameFromSnmp = myPrinter.getOidValue(friendlyNameOid);
             System.out.println("friendlyName = " + friendlyNameFromSnmp);
 
             String newfriendlyName = "AwesomePrinter";
             myPrinter.setOidValue(friendlyNameOid, newfriendlyName);
 
         } catch (SnmpException e) {
             e.printStackTrace();
         }
     }
 }
 
  • Constructor Details

    • SnmpPrinter

      public SnmpPrinter(String address) throws SnmpException
      Creates an instance of a Zebra printer which is limited to only SNMP operations. The SNMP get and set community names default to "public". If you wish to use other community names, use SnmpPrinter(String, String, String)
      Parameters:
      address - the IP Address or DNS Hostname.
      Throws:
      SnmpException - if there was an exception communicating over SNMP
    • SnmpPrinter

      public SnmpPrinter(String address, String getCommunityName, String setCommunityName) throws SnmpException
      Creates an instance of a Zebra printer, with the given community names, which is limited to only SNMP operations.
      Parameters:
      address - the IP Address or DNS Hostname.
      getCommunityName - SNMP get community name
      setCommunityName - SNMP set community name
      Throws:
      SnmpException - if there was an exception communicating over SNMP
  • Method Details

    • getOidValue

      public String getOidValue(String oid) throws SnmpException
      Gets the value of the specified oid.
      Parameters:
      oid - Object identifier.
      Returns:
      The value of the OID.
      Throws:
      SnmpException - if there was an exception communicating over SNMP
    • setOidValue

      public void setOidValue(String oid, String valueToSet) throws SnmpException
      Sets the value of the specified oid to valueToSet.
      Parameters:
      oid - Object identifier.
      valueToSet - the value to set the OID to.
      Throws:
      SnmpException - if there was an exception communicating over SNMP
    • setOidValue

      public void setOidValue(String oid, int valueToSet) throws SnmpException
      Sets the value of the specified oid to valueToSet.
      Parameters:
      oid - Object identifier.
      valueToSet - the value to set the OID to.
      Throws:
      SnmpException - if there was an exception communicating over SNMP
    • getGetCommunityName

      public String getGetCommunityName()
      Returns the SNMP get community name
      Returns:
      the getCommunityName
    • getSetCommunityName

      public String getSetCommunityName()
      Returns the SNMP set community name
      Returns:
      the setCommunityName