当前位置: 首页>>代码示例>>C#>>正文


C# BluetoothClient.DiscoverDevicesInRange方法代码示例

本文整理汇总了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();
 }
开发者ID:joshuaskling,项目名称:smartphone_game_controller,代码行数:14,代码来源:Form1.cs

示例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);
            }
        }
开发者ID:retrogamer80s,项目名称:jbrick-for-ios,代码行数:62,代码来源:NXT.cs

示例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();
     }
 }
开发者ID:jcarlos7121,项目名称:KinestiControl,代码行数:22,代码来源:MainWindow.xaml.cs

示例4: scanRemoteDevices

 public void scanRemoteDevices()
 {
     BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
     BluetoothClient client = new BluetoothClient();
     _devices = client.DiscoverDevicesInRange();
 }
开发者ID:evelan,项目名称:BluetoothConnector,代码行数:6,代码来源:BluetoothConnector.cs

示例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);
            }
        }
开发者ID:nmplcpimenta,项目名称:scmu_project,代码行数:32,代码来源:MainWindow.xaml.cs

示例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;
        }
开发者ID:AlexEmashev,项目名称:ZeeClient,代码行数:25,代码来源:ZeemoteListener.cs


注:本文中的InTheHand.Net.Sockets.BluetoothClient.DiscoverDevicesInRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。