Example #1
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);
        }