Click or drag to resize

BluetoothDiscoverer Class

A class that discovers Bluetooth® devices.
Inheritance Hierarchy
SystemObject
  Zebra.Sdk.Printer.DiscoveryBluetoothDiscoverer

Namespace: Zebra.Sdk.Printer.Discovery
Assembly: SdkApi.Desktop (in SdkApi.Desktop.dll) Version: 4.0.3435
Syntax
public class BluetoothDiscoverer

The BluetoothDiscoverer type exposes the following members.

Methods
 NameDescription
Public methodEquals
(Inherited from Object)
Public methodStatic memberFindPrinters(DiscoveryHandler) Find Bluetooth® devices that are discoverable.
Public methodStatic memberFindPrinters(DiscoveryHandler, Int32) Find Bluetooth® devices that are discoverable.
Public methodStatic memberFindPrinters(DiscoveryHandler, DeviceFilter) Find Bluetooth® devices that are discoverable.
Public methodStatic memberFindPrinters(DiscoveryHandler, DeviceFilter, Int32) Find Bluetooth® devices that are discoverable.
Public methodStatic memberFindServices Find services (ConnectionChannels) that are supported by the device at macAddress.
Public methodGetHashCode
(Inherited from Object)
Public methodGetType
(Inherited from Object)
Public methodToString
(Inherited from Object)
Top
Example
C#
using System;
using System.Collections.Generic;
using Zebra.Sdk.Printer.Discovery;

class BluetoothDiscovererExample {

    public static void Main(string[] args) {
        try {
            Console.WriteLine("Starting printer discovery.");

            BluetoothDiscoveryHandler discoveryHandler = new BluetoothDiscoveryHandler();
            BluetoothDiscoverer.FindPrinters(discoveryHandler);
            while (!discoveryHandler.DiscoveryComplete) {
                System.Threading.Thread.Sleep(10);
            }
        } catch (DiscoveryException e) {
            Console.WriteLine(e.ToString());
        }
    }

    private class BluetoothDiscoveryHandler : DiscoveryHandler {

        private bool discoveryComplete = false;
        List<DiscoveredPrinter> printers = new List<DiscoveredPrinter>();

        public void DiscoveryError(string message) {
            Console.WriteLine($"An error occurred during discovery: {message}.");
            discoveryComplete = true;
        }

        public void DiscoveryFinished() {
            foreach (DiscoveredPrinter printer in printers) {
                Console.WriteLine(printer);
            }
            Console.WriteLine($"Discovered {printers.Count} Bluetooth printers.");
            discoveryComplete = true;
        }

        public void FoundPrinter(DiscoveredPrinter printer) {
            printers.Add(printer);
        }

        public bool DiscoveryComplete {
            get => discoveryComplete;
        }
    }
}
See Also