1

I'm using inTheHand library (32feet.NET).

I have a device with bluetooth enabled and I want to connect with the device to my computer and than send data from the device to computer. I then want to catch that information with my program and process it. The device will send me 3 variables (all 3 float).

How do I catch that information with bluetooth? I never worked with bluetooth on a computer before.

I tried like this post said: Pair bluetooth devices to a computer with 32feet .NET Bluetooth library

But don't know what I'm doing, so I can't make it work.

I'm using Visual Studio 2017 and Windows 10. I heard there are problems for Windows 10 and authenticating bluetooth devices.

Thanks for all the help!

UPDATE:

        static string domaciaddress = "MY_ADDRESS";
        static string tujadress = "DEVICE_ADDRESS";
        //reciever
        private static BluetoothEndPoint EP = new BluetoothEndPoint(BluetoothAddress.Parse(domaciaddress), BluetoothService.BluetoothBase);
        private static BluetoothClient BC = new BluetoothClient(EP);

        //sender
        private static BluetoothDeviceInfo BTDevice = new BluetoothDeviceInfo(BluetoothAddress.Parse(tujadress));

        private static NetworkStream stream = null;

        static void neke231(string[] args)
        {
            string paircode = "paircode";
            if (BluetoothSecurity.PairRequest(BTDevice.DeviceAddress, paircode))
            {
                Console.WriteLine("PairRequest: OK");

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

                    BC.SetPin(paircode);

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

            Console.ReadLine();
        }

I now connect to my bluetooth like this. But I still don't know how to get those 3 floats that my device sends, and save it here in float, so I can later in program use them.

EDIT: This code in fact doesn't work exactly... I don't know why, but it won't connect to android phone. When I run program instead of getting what I write into console, I get only BluetoothGetDeviceInfo returned: 0x80070057

0 Answers0