inthehand / 32feet

Personal Area Networking for .NET. Open source and professionally supported
https://inthehand.com/components/32feet/
MIT License
842 stars 208 forks source link

Unable to reconnect to disconnected devices #281

Open vikramtamboli opened 1 year ago

vikramtamboli commented 1 year ago

When I connect to the device then disconnect then again try to reconnect I am unable to do so it throws an exception cannot connect to disposed object

this i am able to reproduce always on windows 11 machine

also, this issue was not present in v4.0.24.525

Chris-656 commented 1 year ago

same for me getting the device name and connect works fine ans i get data over BT

private BluetoothDeviceInfo getBTDevice(string BTDeviceName)
        {
            //BluetoothDeviceInfo _btDevice = null;
            // Device Search Startet

            foreach (BluetoothDeviceInfo bdi in BTClient.DiscoverDevices())
            {

                System.Diagnostics.Debug.WriteLine(bdi.DeviceName + " " + bdi.DeviceAddress);
                if (bdi.DeviceName == BTDeviceName)
                {
                    _btDevice = bdi;
                    BTClient.Connect(_btDevice.DeviceAddress, BluetoothService.SerialPort);

                    break;
                }
            }
            return _btDevice;
        }

Bute when I close the connection

BTClient.close();    // or BTClient.Dispose();
BTClient.Connect(BTDevice.DeviceAddress, BluetoothService.SerialPort);

The reconnection doesnt work. BTClient.Connected is always false.

best regards Chris