A class that discovers Bluetooth(R) devices.
Namespace:
ZSDK_API.DiscoveryAssembly: ZSDK_API (in ZSDK_API.dll) Version: 1.1.123.0
Syntax
C# |
---|
public static class BluetoothDiscoverer |
Visual Basic (Declaration) |
---|
Public NotInheritable Class BluetoothDiscoverer |
Examples
The following examples demonstrate how to discover Bluetooth(R) devices.
CopyC#
using ZSDK_API.Discovery; using ZSDK_API.Comm; using System.Diagnostics; private static void testAutomaticDiscovery() { // FindPrinters will automatically detect which Bluetooth(R) stack is present on the mobile device DiscoveredPrinter[] printers = BluetoothDiscoverer.FindPrinters(); foreach (DiscoveredPrinter p in printers) { Debug.WriteLine("Discovered " + p.ToString()); } } private static void testMicrosoftDiscovery() { // Override the automatic Bluetooth(R) stack detection - use the Microsoft(R) stack BluetoothStackDescriptor stackType = new BluetoothStackDescriptorMicrosoft(); DiscoveredPrinter[] printers = BluetoothDiscoverer.FindPrinters(stackType); foreach (DiscoveredPrinter p in printers) { Debug.WriteLine("Discovered " + p.ToString()); } } private static void testStonestreetOneDiscovery() { // Override the automatic Bluetooth(R) stack detection - use the Stonestreet One(R) stack with serial port COM5 int commPort = 5; BluetoothStackDescriptor stackType = new BluetoothStackDescriptorStonestreetOne(commPort); DiscoveredPrinter[] printers = BluetoothDiscoverer.FindPrinters(stackType); foreach (DiscoveredPrinter p in printers) { Debug.WriteLine("Discovered " + p.ToString()); } }
CopyVB.NET
Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.Reflection Imports ZSDK_API.Discovery Imports ZSDK_API.Comm Private Shared Sub testAutomaticDiscovery() ' FindPrinters will automatically detect which Bluetooth(R) stack is present on the mobile device Dim line As String Dim printers As DiscoveredPrinter() = BluetoothDiscoverer.FindPrinters() For Each p As DiscoveredPrinter In printers line = "Discovered" & p.ToString() Next End Sub Private Shared Sub testMicrosoftDiscovery() ' Override the automatic Bluetooth(R) stack detection - use the Microsoft(R) stack Dim line As String Dim stackType As BluetoothStackDescriptor = New BluetoothStackDescriptorMicrosoft() Dim printers As DiscoveredPrinter() = BluetoothDiscoverer.FindPrinters(stackType) For Each p As DiscoveredPrinter In printers line = "Discovered" & p.ToString() Next End Sub Private Shared Sub testStonestreetOneDiscovery() ' Override the automatic Bluetooth(R) stack detection - use the Stonestreet One(R) stack with serial port COM5 Dim line As String Dim commPort As Integer = 5 Dim stackType As BluetoothStackDescriptor = New BluetoothStackDescriptorStonestreetOne(commPort) Dim printers As DiscoveredPrinter() = BluetoothDiscoverer.FindPrinters(stackType) For Each p As DiscoveredPrinter In printers line = "Discovered" & p.ToString() Next End Sub