0 Replies Latest reply on Jan 31, 2018 3:53 AM by Samyak Upadhyay

    Unable to discover printer

    Samyak Upadhyay

      I am unable to discover my zebra printer in the same subnet based on the java code but if I provide the list of IP address then I am able to discover it. Below I am adding the code that I used to discover the device.

       

      import java.util.ArrayList;

      import java.util.List;

       

       

      import com.zebra.sdk.printer.discovery.DiscoveredPrinter;

      import com.zebra.sdk.printer.discovery.DiscoveryException;

      import com.zebra.sdk.printer.discovery.DiscoveryHandler;

      import com.zebra.sdk.printer.discovery.NetworkDiscoverer;

       

       

      /**

      *

      *

      */

      public class NetworkCardDiscovererExample {

          public static void main(String[] args) {

              List<String> printersToFind = new ArrayList<String>();

              printersToFind.add("aaa.aaa.aaa.aaa");

              DiscoveryHandler discoveryhandler = new DiscoveryHandler() {

                  List<DiscoveredPrinter> printers = new ArrayList<DiscoveredPrinter>();

       

       

                  @Override

                  public void foundPrinter(DiscoveredPrinter printer) {

                      // TODO Auto-generated method stub

                      System.out.print("Adding printer" + printer);

                      printers.add(printer);

                  }

       

       

                  @Override

                  public void discoveryFinished() {

                      // TODO Auto-generated method stub0

                      for (DiscoveredPrinter printer : printers) {

                          System.out.println(printer);

                      }

                      System.out.println("Discovered " + printers.size() + " printers.");

                  }

       

       

                  @Override

                  public void discoveryError(String message) {

                      // TODO Auto-generated method stub

                      System.out.println("An error occured during discovery : " + message);

                  }

              };

              try {

       

       

                  int timeout = 3000;

       

       

                  List<String> ipList = new ArrayList<String>();

       

       

                  ipList.add("aaa.aaa.aaa.aaa");

       

       

                  System.out.println("Starting printer discovery.");

       

       

                  NetworkDiscoverer.findPrinters(discoveryhandler, ipList, timeout);

       

       

              } catch (DiscoveryException e) {

       

       

                  e.printStackTrace();

       

       

              }

          }

      }

       

      In the above code it's not possible to discover if I remove the iplist.