DiscoveryUtil Class |
Namespace: Zebra.Sdk.Printer.Discovery
The DiscoveryUtil type exposes the following members.
Name | Description | |
---|---|---|
DiscoveryUtil | Initializes a new instance of the DiscoveryUtil class |
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetDiscoveryDataMap |
Reads the discovery packet from the provided connection and returns a discovery data map
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ParseDiscoveryPacket |
Decodes the provided MIME encoded discovery packet and returns a discovery data map
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
using System; using System.Collections.Generic; using Zebra.Sdk.Comm; using Zebra.Sdk.Printer.Discovery; public class DiscoveryUtilExample { public static void Main(string[] args) { // Instantiate connection for ZPL TCP port at given address Connection connection = new TcpConnection("192.168.1.1", TcpConnection.DEFAULT_ZPL_TCP_PORT); try { // Open the connection - physical connection is established here. connection.Open(); Dictionary<string, string> discoveryData = DiscoveryUtil.GetDiscoveryDataMap(connection); Console.WriteLine($"The printer's firmware version is: {discoveryData["FIRMWARE_VER"]}"); } catch (ConnectionException e) { // Handle communications error here. Console.WriteLine(e.ToString()); } catch (DiscoveryPacketDecodeException e) { Console.WriteLine(e.ToString()); } finally { // Close the connection to release resources. connection.Close(); } } }