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


C# BluetoothClient.BeginConnect方法代码示例

本文整理汇总了C#中InTheHand.Net.Sockets.BluetoothClient.BeginConnect方法的典型用法代码示例。如果您正苦于以下问题:C# BluetoothClient.BeginConnect方法的具体用法?C# BluetoothClient.BeginConnect怎么用?C# BluetoothClient.BeginConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InTheHand.Net.Sockets.BluetoothClient的用法示例。


在下文中一共展示了BluetoothClient.BeginConnect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: connect_to_be

        /// <summary>
        /// Asynchrones Verbinden zu dem Client.
        /// </summary>
        /// <param name="dev_name">Der Name des Geräts.</param>
        public void connect_to_be(string dev_name)
        {
            add = get_device_address(dev_name);

            BluetoothEndPoint BEP = new BluetoothEndPoint(add, BluetoothUUID);

            client = new BluetoothClient();

            object connection = false;
            try
            {
                client.BeginConnect(BEP, new AsyncCallback(start_read), client);
            }
            catch (Exception excep)
            {
                Debug.WriteLine(excep.ToString());
            }
        }
开发者ID:BI-LedTable,项目名称:LedTable,代码行数:22,代码来源:Bluetooth.cs

示例2: ThreadedSender

        public void ThreadedSender()
        {
            BTClient = new BluetoothClient();
            // Connect to a remote device.
            try
            {
                BTClient.BeginConnect(BTAddress, _N2FServiceGUID, new AsyncCallback(ConnectCallback), BTClient);
                connectDone.WaitOne();

                // Send test data to the remote device.
                Send(BTClient, "TagValidationString!<EOF>");
                sendDone.WaitOne();

            }
            catch (Exception ex)
            {
                KillEmAll();
            }
            finally
            {
                KillEmAll();
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:23,代码来源:AsynchronousClient.cs

示例3: ConnectSocket

        /// <summary>
        /// If we were not provided with a btClient on creation we need to create one
        /// </summary>
        private void ConnectSocket()
        {
            try
            {
                if (NetworkComms.LoggingEnabled) NetworkComms.Logger.Trace("Connecting bluetooth client with " + ConnectionInfo);

                bool connectSuccess = true;

                //We now connect to our target
                btClient = new BluetoothClient();

                //Start the connection using the async version
                //This allows us to choose our own connection establish timeout
                IAsyncResult ar = btClient.BeginConnect((ConnectionInfo.RemoteEndPoint as BluetoothEndPoint), null, null);
                WaitHandle connectionWait = ar.AsyncWaitHandle;
                try
                {
                    if (!ar.AsyncWaitHandle.WaitOne(NetworkComms.ConnectionEstablishTimeoutMS, false))
                    {
                        btClient.Close();
                        connectSuccess = false;
                    }

                    btClient.EndConnect(ar);
                }
                finally
                {
                    connectionWait.Close();
                }

                if (!connectSuccess) throw new ConnectionSetupException("Timeout waiting for remoteEndPoint to accept bluetooth connection.");
            }
            catch (Exception ex)
            {
                CloseConnection(true, 17);
                throw new ConnectionSetupException("Error during bluetooth connection establish with destination (" + ConnectionInfo + "). Destination may not be listening or connect timed out. " + ex.ToString());
            }
        }
开发者ID:MarcFletcher,项目名称:NetworkComms.Net,代码行数:41,代码来源:BluetoothConnection.cs

示例4: conectio

 private void conectio()
 {
     BluetoothClient cliento = new BluetoothClient();
     cliento.BeginConnect(dispositivomeromero.DeviceAddress,mUUID,this.callbacko,cliento);
 }
开发者ID:jcarlos7121,项目名称:KinestiControl,代码行数:5,代码来源:MainWindow.xaml.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: bt_pair

        private void bt_pair()
        {
            BluetoothAddress BtAdress = null;
            BluetoothClient _blueToothClient;
            bool _beginConnect;
            int c = 0;
            string selDev = null;

            try
            {
                _blueToothClient = new BluetoothClient();
            }
            catch { MessageBox.Show("Bluetooth модуль не подключен!"); return; }

            button7.BeginInvoke((MethodInvoker)(() => { button7.Text = "Wait..."; button7.Enabled = false; }));
            comboBox6.BeginInvoke((MethodInvoker)(() => selDev = comboBox6.SelectedItem.ToString()));

            var devices = _blueToothClient.DiscoverDevices();

            while (BtAdress == null)
            {

                foreach (var device in devices.Where(device => device.DeviceName == selDev))
                {
                    BtAdress = device.DeviceAddress;
                    Console.WriteLine("Device found, Address:" + BtAdress.ToString());
                }

                if (BtAdress != null)
                    break;

                if (c > 2)
                {
                    MessageBox.Show("Невозможно подключиться к устройству!");
                    button7.BeginInvoke((MethodInvoker)(() => { button7.Text = "Open"; button7.Enabled = true; }));
                    return;
                }

                devices = _blueToothClient.DiscoverDevices();

                c++;
            }

            BluetoothDeviceInfo _bluetoothDevice = null;

            try
            {
                 _bluetoothDevice = new BluetoothDeviceInfo(BtAdress);
            }
            catch (System.ArgumentNullException) { }

            if (BluetoothSecurity.PairRequest(_bluetoothDevice.DeviceAddress, "1111"))
            {
                Console.WriteLine("Pair request result: :D");

                if (_bluetoothDevice.Authenticated)
                {
                    Console.WriteLine("Authenticated result: Cool :D");

                    _blueToothClient.SetPin("1111");

                    _blueToothClient.BeginConnect(_bluetoothDevice.DeviceAddress, BluetoothService.SerialPort, null, _bluetoothDevice);
                    _beginConnect = true;

                    bt_serial(BtAdress.ToString()); // Open Serial port for Bluetooth

                    if (btSerialPort != null)
                    {
                        button7.BeginInvoke((MethodInvoker)(() => button7.Text = "Open"));
                        button6.BeginInvoke((MethodInvoker)(() => button6.Enabled = true));
                        groupBox6.BeginInvoke((MethodInvoker)(() => groupBox6.Enabled = true));
                    }
                }
                else
                {
                    Console.WriteLine("Authenticated: So sad :(");

                    bt_pair();
                }
            }
            else
            {
                Console.WriteLine("PairRequest: Sad :(");

                MessageBox.Show("Невозможно подключиться к устройству!");
                button7.BeginInvoke((MethodInvoker)(() => { button7.Text = "Open"; button7.Enabled = true; }));
                return;
            }
        }
开发者ID:seaker000,项目名称:ModbusTerm,代码行数:89,代码来源:GUI.cs

示例7: ClientconnectThread

 private void ClientconnectThread()
 {
     BluetoothClient client = new BluetoothClient();
     updateUI("attempting connect");
     client.BeginConnect(deviceInfo.DeviceAddress, mUUID,this.bluetoothClientConnectCallback,client);
 }
开发者ID:joshuaskling,项目名称:smartphone_game_controller,代码行数:6,代码来源:Form1.cs


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