本文整理汇总了C#中InTheHand.Net.Sockets.BluetoothClient.DiscoverDevicesInRange方法的典型用法代码示例。如果您正苦于以下问题:C# BluetoothClient.DiscoverDevicesInRange方法的具体用法?C# BluetoothClient.DiscoverDevicesInRange怎么用?C# BluetoothClient.DiscoverDevicesInRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InTheHand.Net.Sockets.BluetoothClient
的用法示例。
在下文中一共展示了BluetoothClient.DiscoverDevicesInRange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Scanner
private void Scanner()
{
updateUI("Starting Scan...");
BluetoothClient client = new BluetoothClient();
devices = client.DiscoverDevicesInRange();
updateUI("Scan complete");
updateUI(devices.Length.ToString() + " devices discovered");
foreach(BluetoothDeviceInfo d in devices)
{
items.Add(d.DeviceName);
}
updateDeviceList();
}
示例2: FindNXTDevices
public static void FindNXTDevices(object sender, DoWorkEventArgs eventArgs)
{
while (continueDeviceDiscovery)
{
if (!availableRobots.ContainsKey("USB")) // If a usb was not connected before test it now
{
NXT usbNXT = new NXT("USB", new NXTUsbConnection());
if (usbNXT.nxtConn.IsConnected)
{
availableRobots.Add("USB", usbNXT);
OnDeviceAdded(usbNXT);
}
}
var btClient = new BluetoothClient();
List<BluetoothClient> btRobots = new List<BluetoothClient>();
btClient.InquiryLength = new TimeSpan(0, 0, 4);
BluetoothDeviceInfo[] btDevices = btClient.DiscoverDevicesInRange();
foreach (BluetoothDeviceInfo btDevice in btDevices)
{
try
{
// The property InstalledServices only lists services for devices that have been paired with
// the computer already (rather than requesting it from the device). This is fine in our
// scenario since you cant get a service list off the devices unless it is already paired.
if (btDevice.InstalledServices.Contains(NXT32FeetBT.NXT_BT_SERVICE))
{
String nxtIdentifier = btDevice.DeviceAddress.ToString();
if (!availableRobots.ContainsKey(nxtIdentifier))
{
NXT foundNXT = new NXT(nxtIdentifier, new NXT32FeetBT(btDevice.DeviceAddress));
availableRobots.Add(nxtIdentifier, foundNXT);
OnDeviceAdded(foundNXT);
}
else
{
if (!availableRobots[nxtIdentifier].connected)
{
availableRobots[nxtIdentifier].Reconnect();
}
}
}
}
catch (SocketException e) { } // Socket exception occurs if the device is not an nxt
}
// Check if any previously found devices were lost
var btAddresses = from btDevice in btDevices
select btDevice.DeviceAddress.ToString();
foreach (NXT nxt in AvailableRobots.Values)
{
if (!btAddresses.Contains(nxt.uniqueID))
{
nxt.connected = false;
nxt.OnDeviceDisconnected();
}
}
// Sleep for the designated poll interval
Thread.Sleep(DEVICE_DISCOVERY_POLL_RATE);
}
}
示例3: escaneo
private void escaneo()
{
Debug.WriteLine("Inicio de escaneo");
BluetoothClient cliente = new BluetoothClient();
BluetoothDeviceInfo[] dispositivos = cliente.DiscoverDevicesInRange();
Debug.WriteLine("\n"+dispositivos.Length.ToString() + " numero de dispositivos");
foreach (BluetoothDeviceInfo blue in dispositivos)
{
Debug.WriteLine(blue.DeviceAddress + " " + blue.DeviceName);
if (blue.DeviceAddress.ToString().Equals("0015FFF21179"))
{
Debug.WriteLine("tenemos un ganador!! " + blue.DeviceAddress.ToString());
dispositivomeromero = blue;
}
}
//201308021034
if (parear()){
Debug.WriteLine("Conectado!!");
Thread tredi = new Thread(new ThreadStart(conectio));
tredi.Start();
}
}
示例4: scanRemoteDevices
public void scanRemoteDevices()
{
BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
BluetoothClient client = new BluetoothClient();
_devices = client.DiscoverDevicesInRange();
}
示例5: Discovery
private void Discovery(Object sender, DoWorkEventArgs e)
{
InfoMessage("Starting Discovery Round");
var client = new BluetoothClient();
BluetoothDeviceInfo[] availableDevices = client.DiscoverDevicesInRange(); // I've found this to be SLOW!
String deviceList = "";
BluetoothDeviceInfo tmpDI = null;
foreach (BluetoothDeviceInfo device in availableDevices)
{
//ServiceRecord[] devServices = device.GetServiceRecords(OurServiceClassId);
if (!device.Authenticated/* || devServices.Count() == 0*/)
continue;
if (tmpDI == null)
tmpDI = device;
deviceList += device.DeviceName + " : " + device.DeviceAddress + " : " + (device.Authenticated ? "Paired" : "Not Paired") + /*" : " + devServices.Count() + */"\n";
}
UpdateDiscoveryDevices(deviceList);
if (tmpDI != null)
{
var peerclient = new BluetoothClient();
peerclient.BeginConnect(tmpDI.DeviceAddress, OurServiceClassId, DiscoveryDeviceConnectCallback, peerclient);
}
}
示例6: ScanForDevice
/// <summary>
/// Scan for Zeemote
/// <returns>true if device in range</returns>
/// </summary>
private bool ScanForDevice()
{
// ToDo: move btClient to the class level
bgWorkerProcessData.ReportProgress(0, "Searching for the device...");
BluetoothClient btClient = new BluetoothClient();
BluetoothDeviceInfo[] devices = btClient.DiscoverDevicesInRange();
//bgWorkerProcessData.ReportProgress(0, "Search complete");
//bgWorkerProcessData.ReportProgress(0, "Devices discovered:");
foreach (BluetoothDeviceInfo device in devices)
{
if (device.DeviceName == deviceName)
{
deviceAddress = device.DeviceAddress;
bgWorkerProcessData.ReportProgress(0, deviceName + " found");
return true;
}
}
return false;
}