Click or drag to resize

DiscoveryUtil Class

Defines functions used when discovering information about a printer.
Inheritance Hierarchy
SystemObject
  Zebra.Sdk.Printer.DiscoveryDiscoveryUtil

Namespace: Zebra.Sdk.Printer.Discovery
Assembly: SdkApi.Core (in SdkApi.Core.dll) Version: 3.0.3271
Syntax
public class DiscoveryUtil

The DiscoveryUtil type exposes the following members.

Constructors
 NameDescription
Public methodDiscoveryUtilInitializes a new instance of the DiscoveryUtil class
Top
Methods
 NameDescription
Public methodEquals
(Inherited from Object)
Public methodStatic memberGetDiscoveryDataMap Reads the discovery packet from the provided connection and returns a discovery data map
Public methodGetHashCode
(Inherited from Object)
Public methodGetType
(Inherited from Object)
Public methodStatic memberParseDiscoveryPacket Decodes the provided MIME encoded discovery packet and returns a discovery data map
Public methodToString
(Inherited from Object)
Top
Example
C#
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();
        }
    }
}
See Also