简体   繁体   中英

C# connection via Bluetooth with 32feet library

I am writting console Application using C# and 32feet library. I want connect via bluetooth to phone device. I was following this code : link I came across a problem while pairing two devices. I am using this line to request connection:

bool isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, DEVICE_PIN);

Now auth request shows up on my phone, but there is a problem, becouse auth-code on phone is slighlty different than DEVICE_PIN. Computer trying to connect with phone, but after few minutes I get "Connection failed" info. This is my method to pair

public void  pair(int index)
        {
      BluetoothClient client = new BluetoothClient();
            devices = client.DiscoverDevices();

            BluetoothDeviceInfo device = devices[index];
            bool isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, "8080");
            if (isPaired)
            {
                Console.WriteLine("Paired: ");
            }
            else
            {
                Console.WriteLine("Not paired: ");
            }
        }

Try stopping the Bluetooth Windows services on your computer one by one and test. After you stop a Windows Service, make sure to disable/enable the Bluetooth radio on your computer to take effect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM