Package com.zebra.sdk.printer
Class SnmpPrinter
Object
com.zebra.sdk.printer.SnmpPrinter
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 Summary
ConstructorsConstructorDescriptionSnmpPrinter(String address) Creates an instance of a Zebra printer which is limited to only SNMP operations.SnmpPrinter(String address, String getCommunityName, String setCommunityName) Creates an instance of a Zebra printer, with the given community names, which is limited to only SNMP operations. -
Method Summary
Modifier and TypeMethodDescriptionReturns the SNMP get community namegetOidValue(String oid) Gets the value of the specifiedoid.Returns the SNMP set community namevoidsetOidValue(String oid, int valueToSet) Sets the value of the specifiedoidtovalueToSet.voidsetOidValue(String oid, String valueToSet) Sets the value of the specifiedoidtovalueToSet.
-
Constructor Details
-
SnmpPrinter
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, useSnmpPrinter(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 namesetCommunityName- SNMP set community name- Throws:
SnmpException- if there was an exception communicating over SNMP
-
-
Method Details
-
getOidValue
Gets the value of the specifiedoid.- Parameters:
oid- Object identifier.- Returns:
- The value of the OID.
- Throws:
SnmpException- if there was an exception communicating over SNMP
-
setOidValue
Sets the value of the specifiedoidtovalueToSet.- Parameters:
oid- Object identifier.valueToSet- the value to set the OID to.- Throws:
SnmpException- if there was an exception communicating over SNMP
-
setOidValue
Sets the value of the specifiedoidtovalueToSet.- Parameters:
oid- Object identifier.valueToSet- the value to set the OID to.- Throws:
SnmpException- if there was an exception communicating over SNMP
-
getGetCommunityName
Returns the SNMP get community name- Returns:
- the getCommunityName
-
getSetCommunityName
Returns the SNMP set community name- Returns:
- the setCommunityName
-