Esempio n. 1
0
        private void buttonPair_Click(object sender, EventArgs e)
        {
            //wybieramy urządzenie z listy
            foreach (BluetoothDeviceInfo device in devices)
            {
                if (device.DeviceName.Equals(listBoxDevices.SelectedItem))
                {
                    deviceToPair = device;
                }
            }

            //nawiżaywanie połączneia z wybranym urządzeniem
            deviceToPair.Update();
            deviceToPair.Refresh();
            deviceToPair.SetServiceState(BluetoothService.ObexObjectPush, true);

            //wysłanie podłączenia
            string pin = "1234";

            isPaired = BluetoothSecurity.PairRequest(deviceToPair.DeviceAddress, pin);

            //wypisanie wszystkich sparowanych urządzeń
            if (isPaired)
            {
                connected.Add(deviceToPair);
                listBoxConnected.Items.Clear();
                foreach (var device in connected)
                {
                    listBoxConnected.Items.Add(device.DeviceName);
                }
            }
        }
Esempio n. 2
0
        //int index = listViewDevices.SelectedIndices[0];


        #region Connect
        private void button2_Click(object sender, EventArgs e)
        {
            if (listViewDevices.SelectedItems.Count > 0)
            {
                EventHandler <BluetoothWin32AuthenticationEventArgs> authHandler = new EventHandler <BluetoothWin32AuthenticationEventArgs>(handleAuthRequests);
                BluetoothWin32Authentication authenticator = new BluetoothWin32Authentication(authHandler);

                BluetoothDeviceInfo selectedDevice = devices[listViewDevices.SelectedIndices[0]];
                if (MessageBox.Show(String.Format("Would you like to attempt to pair with {0}?", selectedDevice.DeviceName), "Pair Device", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (BluetoothSecurity.PairRequest(selectedDevice.DeviceAddress, null))
                    {
                        MessageBox.Show("We paired!");
                    }
                    else
                    {
                        MessageBox.Show("Failed to pair!");
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a Device to Pair");
            }
        }
Esempio n. 3
0
        // Appaire si non appairé
        public bool PairIfNotAlreadyPaired(BluetoothDeviceInfo device)
        {
            BluetoothDeviceInfo[] paired = localClient.DiscoverDevices(255, false, true, false, false);

            bool isPaired = false;

            for (int i = 0; i < paired.Length; i++)
            {
                if (device.Equals(paired[i]))
                {
                    isPaired = true;
                    break;
                }
            }

            if (!isPaired)
            {
                Console.WriteLine("Trying to pair...");
                isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, "0000");
                if (isPaired)
                {
                    Console.WriteLine("Paired !");
                    return(true);
                }

                return(false);
            }

            return(true);
        }
Esempio n. 4
0
 private void PairBluetoothTask()
 {
     this.Invoke((MethodInvoker)(() => selectedDevice = devices[listBoxDevices.SelectedIndex]));
     if (isPaired)
     {
         if (MessageBox.Show("Device is already paired! Do you want to unpair?", "Pairing...", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             BluetoothSecurity.RemoveDevice(selectedDevice.DeviceAddress);
             isPaired = false;
         }
     }
     else
     {
         if (BluetoothSecurity.PairRequest(selectedDevice.DeviceAddress, "0000"))
         {
             isPaired = true;
             MessageBox.Show("We paired!");
             //Simulator.BTDevice = new BluetoothDeviceInfo(selectedDevice.DeviceAddress);
         }
         else
         {
             MessageBox.Show("Failed to pair!");
         }
     }
 }
Esempio n. 5
0
        public bool PairDevice(BluetoothDeviceInfo device)
        {
            //device.Update();
            if (device.Authenticated)
            {
                return(true);
            }
            // Check if PIN has been stored
            if (_bluetoothConfiguration.StoredDevicePins.ContainsKey(device.DeviceAddress))
            {
                if (BluetoothSecurity.PairRequest(device.DeviceAddress, _bluetoothConfiguration.StoredDevicePins[device.DeviceAddress]))
                {
                    device.Update();
                    return(device.Authenticated);
                }
            }

            // loop through common PIN numbers to see if they pair
            foreach (string devicePin in CommonDevicePins)
            {
                var isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, devicePin);
                if (isPaired)
                {
                    _bluetoothConfiguration.StoredDevicePins[device.DeviceAddress] = devicePin;
                    StoreSettings();
                    break;
                }
            }

            device.Update();
            return(device.Authenticated);
        }
Esempio n. 6
0
        private bool PairDevice()
        {
            using (var discoverForm = new SelectBluetoothDeviceDialog())
            {
                if (discoverForm.ShowDialog(this) != DialogResult.OK)
                {
                    return(false);
                }

                var deviceInfo = discoverForm.SelectedDevice;

                if (!deviceInfo.Authenticated) // previously paired?
                {
                    if (!BluetoothSecurity.PairRequest(deviceInfo.DeviceAddress, _myPin))
                    {
                        return(false);
                    }
                }

                // device should now be paired with the OS so make a connection to it asynchronously
                var client = new BluetoothClient();
                client.BeginConnect(deviceInfo.DeviceAddress, BluetoothService.SerialPort,
                                    BluetoothClientConnectCallback, client);

                return(true);
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            BluetoothClient client = new BluetoothClient();

            BluetoothDeviceInfo device = null;

            foreach (var dev in client.DiscoverDevices())
            {
                if (dev.DeviceName.Contains("PREFIX"))
                {
                    device = dev;
                    break;
                }
            }

            if (!device.Authenticated)
            {
                BluetoothSecurity.PairRequest(device.DeviceAddress, "1234");
            }

            device.Refresh();
            System.Diagnostics.Debug.WriteLine(device.Authenticated);

            client.Connect(device.DeviceAddress, BluetoothService.SerialPort);

            var          stream = client.GetStream();
            StreamWriter sw     = new StreamWriter(stream, System.Text.Encoding.ASCII);

            sw.WriteLine("Hello world!\r\n\r\n");
            sw.Close();

            client.Close();
        }
        /// <summary>
        /// This checks if the NCH is in the device's paired devices list and if not
        /// makes a pairing request to the NCH. When pairing occurs the Bluetooth_Maager's onPairSuccess()
        /// is called, if it fails onPairFailed() is called.
        /// </summary>
        public void isPaired()
        {
            foreach (BluetoothDeviceInfo dev in pairedDevices)
            {
                if (dev.Equals(nch.DeviceInfo))
                {
                    System.Diagnostics.Debug.WriteLine("Pairer: Paired");
                    bm.onPairSucess();
                    return;
                }
            }

            bool b = false;

            System.Diagnostics.Debug.WriteLine("It's not in paired devices so starting a pair request");
            pairingRequested = true;
            Task.Run(async() => {
                if (BluetoothSecurity.PairRequest(nch.DeviceInfo.DeviceAddress, null))
                {
                    System.Diagnostics.Debug.WriteLine("Pairer: Paired");
                    bm.onPairSucess();
                    b = true;
                    return;
                }
            }).GetAwaiter().GetResult();

            pairingRequested = false;

            if (!b)
            {
                bm.onPairFailed();
            }
        }
Esempio n. 9
0
        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Enabled = false;
            button2.Enabled  = false;
            textBox2.Enabled = true;

            using (BluetoothClient bc = new BluetoothClient())
            {
                string a = textBox1.Text;

                String choose = textBox1.Text;

                //Console.WriteLine("you chosed \n "+ choose);
                if (choose != null && int.Parse(choose) > 0 && int.Parse(choose) < myArray.Length + 1)
                {
                    phoneChoosed = int.Parse(choose) - 1;
                    Console.WriteLine("you choosed :" + choose);
                    BluetoothSecurity.PairRequest(myArray[phoneChoosed].DeviceAddress, "123456");
                }
                else
                {
                    textBox1.Clear();
                    textBox1.Enabled = true;
                    button2.Enabled  = true;
                    textBox2.Enabled = false;
                }
            }
        }
Esempio n. 10
0
        private void pairing()
        {
            // get a list of all paired devices
            BluetoothDeviceInfo[] paired = localClient.DiscoverDevices(255, false, true, false, false);
            // check every discovered device if it is already paired
            foreach (BluetoothDeviceInfo device in this.deviceList)
            {
                bool isPaired = false;
                for (int i = 0; i < paired.Length; i++)
                {
                    if (device.Equals(paired[i]))
                    {
                        isPaired = true;
                        break;
                    }
                }

                // if the device is not paired, pair it!
                if (!isPaired)
                {
                    // replace DEVICE_PIN here, synchronous method, but fast
                    isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, "1234");
                    if (isPaired)
                    {
                        // now it is paired
                        MessageBox.Show("now it is paired");
                    }
                    else
                    {
                        // pairing failed
                        MessageBox.Show("pairing failed");
                    }
                }
            }
        }
Esempio n. 11
0
        public static void AutoPairDevices()
        {
            // get a list of all paired devices
            var paired = LocalClient.DiscoverDevices(255, false, true, false, false);

            // check every discovered device if it is already paired
            foreach (var device in DeviceList)
            {
                var isPaired = paired.Any(t => device.Equals(t));

                // if the device is not paired, try to pair it
                if (!isPaired)
                {
                    // loop through common PIN numbers to see if they pair
                    foreach (var devicePin in CommonDevicePins)
                    {
                        isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, devicePin);
                        if (isPaired)
                        {
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        public bool ConnectDevice(string name, string pin)
        {
            BluetoothAddress arduinoAdress = null;

            _bluetoothClient = new BluetoothClient();
            var devices = _bluetoothClient.DiscoverDevices();

            foreach (var device in devices.Where(device => device.DeviceName == name))
            {
                arduinoAdress = device.DeviceAddress;
                logger.Info("Device found, Address is:" + arduinoAdress.ToString());
            }
            _bluetoothDevice = new BluetoothDeviceInfo(arduinoAdress);

            var pairResult = false;

            int count = 3;

            while (pairResult == false && count > 0)
            {
                pairResult = BluetoothSecurity.PairRequest(_bluetoothDevice.DeviceAddress, pin);
                Thread.Sleep(1000);
                count--;
            }

            if (pairResult)
            {
                logger.Info("Pair request success");

                if (_bluetoothDevice.Authenticated)
                {
                    logger.Info("Authenticated result: Cool :D");

                    _bluetoothClient.SetPin(pin);

                    var res = _bluetoothClient.BeginConnect(_bluetoothDevice.DeviceAddress, BluetoothService.SerialPort, Connect, _bluetoothDevice);
                    res.AsyncWaitHandle.WaitOne();
                    _connected = true;
                }
                else
                {
                    logger.Error("Authenticated: So sad :(");
                }
            }
            else
            {
                logger.Error("PairRequest: Sad :(");
            }

            if (_connected)
            {
                _bluetoothStream = _bluetoothClient.GetStream();
                if (_bluetoothStream != null)
                {
                    Task task = new Task(() => ReadFromDevice());
                    task.Start();
                }
            }
            return(_bluetoothStream != null);
        }
Esempio n. 13
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count == 0)
     {
         MessageBox.Show("Nie skanowano w poszukiwaniu urządzeń!", "BŁĄD!");
         return;
     }
     if (selectedDevice[0] == "<NULL>")
     {
         MessageBox.Show("Brak urzadzeń do sparowania!", "BŁĄD!");
         return;
     }
     if (isPaired)
     {
         BluetoothDeviceInfo[] paired = localClient.DiscoverDevices(255, false, true, false, false);
         if (paired[0].DeviceName == selectedDevice[1])
         {
             return;
         }
         BluetoothSecurity.RemoveDevice(paired[0].DeviceAddress);
     }
     selected.Update();
     selected.Refresh();
     selected.SetServiceState(BluetoothService.ObexObjectPush, true);
     //localClient.Connect(new BluetoothEndPoint(selected.DeviceAddress, BluetoothService.ObexFileTransfer));
     BluetoothSecurity.PairRequest(selected.DeviceAddress, null);
     isPaired = true;
 }
Esempio n. 14
0
        private void buttonPair_Click(object sender, EventArgs e)
        {
            Device device = (Device)comboBoxAvailableDevices.SelectedItem;

            BluetoothSecurity.PairRequest(device.DeviceInfo, null);
            findDevices();
        }
Esempio n. 15
0
        public void HandleThread(BluetoothDeviceInfo device)
        {
            //while (!this.findDevice(out device)) ;

            Console.WriteLine("About to pair");
            int count = 0;
            int max   = 5;

            while ((!(BluetoothSecurity.PairRequest(device.DeviceAddress, defpin))) && count < max)
            {
                Console.WriteLine("Pairing Failed, retrying");
                count++;
                Thread.Sleep(100);
            }

            if (count == max)
            {
                HandleThread(device);
            }
            else
            {
                Console.WriteLine("Paired..Beginning connect");
                client.BeginConnect(device.DeviceAddress, BluetoothService.SerialPort, this.callback, client);
            }
        }
Esempio n. 16
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            string selectedItem = DeviceLists.SelectedItem.ToString();
            string file         = Path.Combine(Directory.GetCurrentDirectory(), @"temp/generated.jpg");

            foreach (var device in deviceInfo)
            {
                var name    = new Regex(device.DeviceName);
                var address = new Regex(device.DeviceAddress.ToString());
                if (name.IsMatch(selectedItem) && address.IsMatch(selectedItem))
                {
                    device.SetServiceState(BluetoothService.ObexObjectPush, true);
                    if (!device.Authenticated)
                    {
                        if (!BluetoothSecurity.PairRequest(device.DeviceAddress, "0000"))
                        {
                            MessageBox.Show("Request failed");
                        }
                        else
                        {
                            BluetoothSecurity.PairRequest(device.DeviceAddress, "0000");
                        }
                    }

                    var uri     = new Uri("obex://" + device.DeviceAddress + "/" + file);
                    var request = new ObexWebRequest(uri);
                    request.ReadFile(file);
                    var response = (ObexWebResponse)request.GetResponse();
                    MessageBox.Show(response.StatusCode.ToString());

                    response.Close();
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// This method is called when the discovery process is completed.
        /// It attempts to create a Bluetooth connection the specified device
        /// </summary>
        private static void DiscoverDevicesComplete(object sender, DiscoverDevicesEventArgs e)
        {
            // Get a list of previously paired devices
            List <BluetoothDeviceInfo> devices = e.Devices.OfType <BluetoothDeviceInfo>().ToList();
            BluetoothDeviceInfo        device  = devices.Find(item => item.DeviceName.Equals("Shimmer3-" + SHIMMER_ID));

            if (device == null)
            {
                //Console.WriteLine("Shimmer3-" + SHIMMER_ID + " could not be discovered");
                connecting = false;
            }
            else
            {
                // Check if device can be paired
                if (BluetoothSecurity.PairRequest(device.DeviceAddress, SHIMMER_PIN))
                {
                    // set pin of device to connect with
                    localClient.SetPin(SHIMMER_PIN);
                    // async connection method
                    localClient.BeginConnect(device.DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connected_Callback), device);
                }
                else
                {
                    //Console.WriteLine("Shimmer3-" + SHIMMER_ID + " could not be paired");
                    connecting = false;
                }
            }
        }
Esempio n. 18
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (lstDevices.SelectedItem != null)
            {
                btSelectedDevice = null;
                foreach (BluetoothDeviceInfo btDevice in btDevList)
                {
                    if (btDevice.DeviceName.Equals(lstDevices.SelectedItem.ToString()))
                    {
                        btSelectedDevice = btDevice;
                        break;
                    }
                }

                if (btSelectedDevice != null)
                {
                    if (!btSelectedDevice.Authenticated)
                    {
                        bool isPaired = BluetoothSecurity.PairRequest(btSelectedDevice.DeviceAddress, txtPin.Text);
                        if (!isPaired)
                        {
                            txtPin.Text = "PIN_ERROR";
                            return;
                        }
                    }
                    else
                    {
                        //btClient.SetPin(txtPin.Text);
                        btClient.BeginConnect(btSelectedDevice.DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connect), btSelectedDevice);
                    }
                }
            }
        }
Esempio n. 19
0
 private void mnuPair_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         BluetoothSecurity.PairRequest(((BluetoothDeviceInfo)listBox1.SelectedItem).DeviceAddress, "1234");
     }
 }
        static void Main(string[] args)
        {
            if (BluetoothSecurity.PairRequest(BTDevice.DeviceAddress, MY_PAIRING_CODE))
            {
                Console.WriteLine("PairRequest: OK");

                if (BTDevice.Authenticated)
                {
                    Console.WriteLine("Authenticated: OK");

                    BC.SetPin(MY_PAIRING_CODE);

                    BC.BeginConnect(BTDevice.DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connect), BTDevice);
                }
                else
                {
                    Console.WriteLine("Authenticated: No");
                }
            }
            else
            {
                Console.WriteLine("PairRequest: No");
            }

            Console.ReadLine();
        }
Esempio n. 21
0
        /// <summary>
        /// 连接函数
        /// </summary>
        /// <returns></连接失败返回false>
        private bool connect()
        {
            // 创建选择框选择要连接的设备
            using (SelectBluetoothDeviceDialog bldialog = new SelectBluetoothDeviceDialog())
            {
                bldialog.ShowRemembered = false;
                if (bldialog.ShowDialog() == DialogResult.OK)
                {
                    if (bldialog.SelectedDevice == null)
                    {
                        MessageBox.Show("No device selected");
                        return(false);
                    }

                    BluetoothDeviceInfo selecteddevice = bldialog.SelectedDevice;

                    if (!selecteddevice.Authenticated)
                    {
                        if (!BluetoothSecurity.PairRequest(selecteddevice.DeviceAddress, "0000"))
                        {
                            MessageBox.Show("PairRequest Error");
                            return(false);
                        }
                    }

                    try
                    {
                        // 对指定的目标进行蓝牙连接请求
                        client = new BluetoothClient();
                        client.Connect(selecteddevice.DeviceAddress, BluetoothService.SerialPort);
                        stream = client.GetStream();
                        stream.Write(System.Text.Encoding.ASCII.GetBytes("teacher"), 0, 7);
                    }

                    catch
                    {
                        return(false);
                    }

                    StateOfRunning();

                    stream = client.GetStream();
                    // 标记stream已经接受对象实例化
                    SIGN_STREAMSETUP = true;
                    // 启动接收图片的线程
                    receiving     = true;
                    ReceiveThread = new System.Threading.Thread(ReceiveLoop);
                    ReceiveThread.Start();
                    // 启动信息发送线程
                    sendDataThread = new System.Threading.Thread(SendDataLoop);
                    closeSendData();
                    sendDataThread.Start();

                    sendfileThread = new System.Threading.Thread(SendFileLoop);
                    return(true);
                }
                return(false);
            }
        }
Esempio n. 22
0
        public static void PairWithDevice(BluetoothAddress address, String passCode)
        {
            //Set the pin for device.
            //BluetoothSecurity.SetPin(address, Pin);

            //Pair with device.
            bool ret = BluetoothSecurity.PairRequest(address, Pin);
        }
Esempio n. 23
0
        private void pairBtnClick(object sender, RoutedEventArgs e)
        {
            string myPin      = "1234";
            Device device     = (Device)deviceList.SelectedItem;
            var    deviceInfo = device.DeviceInfo;

            BluetoothSecurity.PairRequest(deviceInfo, myPin);
        }
Esempio n. 24
0
 /// <summary>
 /// Starts a pairing request for this device.
 /// </summary>
 /// <param name="pin">Optional pin code.</param>
 /// <returns>True, if successful.</returns>
 public bool PairRequest(String pin = null)
 {
     if (_deviceInfo == null)
     {
         return(false);
     }
     return(BluetoothSecurity.PairRequest(_deviceInfo.DeviceAddress, pin));
 }
 private bool checkDevicePaired()
 {
     if (!deviceInfo.Authenticated && !BluetoothSecurity.PairRequest(deviceInfo.DeviceAddress, myPin))
     {
         return(false);
     }
     return(true);
 }
Esempio n. 26
0
        private void bpair_Click(object sender, EventArgs e)
        {
            string pin = "4321";
            BluetoothDeviceInfo device = list[listBox1.SelectedIndex];

            BluetoothSecurity.PairRequest(device.DeviceAddress, pin);
            adres = device.DeviceAddress;
        }
Esempio n. 27
0
        static void Connect(bool onlyPair = false)
        {
            bool connected = false;

            while (!connected)
            {
                try
                {
                    bluetoothClient = new BluetoothClient();

                    BluetoothDeviceInfo hcInfo = new BluetoothDeviceInfo(new BluetoothAddress(0));

                    while (!hcFound)
                    {
                        var devices = bluetoothClient.DiscoverDevices();
                        foreach (var device in devices)
                        {
                            if (device.DeviceName.Equals("HC-05"))
                            {
                                hcInfo = device;
                                Console.WriteLine("Bluetooth-Empfänger gefunden");
                                hcFound = true;
                                break;
                            }
                        }
                        if (!hcFound)
                        {
                            Console.WriteLine("Bluetooth-Empfänger wurde nicht gefunden, suche erneut...");
                        }
                    }

                    bool paired = false;
                    while (!paired)
                    {
                        paired = BluetoothSecurity.PairRequest(hcInfo.DeviceAddress, "1234");
                        if (paired)
                        {
                            Console.WriteLine("Bluetooth-Empfänger erfolgreich gepaart");
                        }
                        else
                        {
                            Console.WriteLine("Bluetooth-Empfänger konnte nicht gepaart werden");
                        }
                    }

                    Guid             serviceClass = BluetoothService.SerialPort;
                    BluetoothAddress addr         = BluetoothAddress.Parse(hcInfo.DeviceAddress.ToString());
                    var endpoint = new BluetoothEndPoint(addr, serviceClass);
                    bluetoothClient.Connect(endpoint);
                    connected = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    connected = false;
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Pairs a bluetooth device
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public async Task <bool> PairDevice(BluetoothAddress device)
        {
            var paired = false;
            await Task.Run(() =>
            {
                paired = BluetoothSecurity.PairRequest(device, null);
            });

            return(paired);
        }
Esempio n. 29
0
        private void workerDoWork(object sender, DoWorkEventArgs e)
        {
            do
            {
                //Console.WriteLine(BTDevice.Connected);
                // If Scanner is connected
                BTDevice.Refresh();
                if (BTDevice.Connected)
                {
                    this.DeviceFound = true;
                    //this.OnPropertyChanged("DeviceFound");
                    Console.WriteLine("Device connected");
                    if (!BC.Connected)
                    {
                        this.DeviceConnected = true;
                        Console.WriteLine("BC Connected");
                        if (BluetoothSecurity.PairRequest(BTDevice.DeviceAddress, "1234"))
                        {
                            Console.WriteLine("PairRequest: OK");

                            if (BTDevice.Authenticated)
                            {
                                Console.WriteLine("Authenticated: OK");

                                //BC.SetPin("1234");

                                BC.BeginConnect(BTDevice.DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connect), BTDevice);

                                System.Threading.Thread.Sleep(200);
                                //BC.Close();
                            }
                            else
                            {
                                Console.WriteLine("Authenticated: No");
                            }
                        }
                        else
                        {
                            Console.WriteLine("PairRequest: No");
                        }
                    }
                    this.DeviceConnected = false;
                    System.Threading.Thread.Sleep(5000);
                }
                else
                {
                    this.DeviceFound = false;
                    //this.OnPropertyChanged("DeviceFound");
                    Console.WriteLine("Refresh Device Status");
                    BTDevice.Refresh();
                    System.Threading.Thread.Sleep(5000);
                }
            } while (true);
        }
Esempio n. 30
0
 /// <summary>
 /// Ensures bluetooth device is paired
 /// </summary>
 private bool PairDevice()
 {
     if (!deviceInfo.Authenticated)
     {
         if (!BluetoothSecurity.PairRequest(deviceInfo.DeviceAddress, myPIN))
         {
             return(false);
         }
     }
     return(true);
 }