I am trying to control the Bluetooth LE devices connect/disconnect in my Win 10 IoT UWP C# application, running on Raspberry Pi 3 SBC. The Win 10 IoT is Windows Insiders Preview build 10.0.17035.1000. When I start my application, it recognizes the advertising BLE device, successfully connects and communicates with it . Then I try to disconnect this device by applying the recommended procedure:
device.Dispose();
device = null;
GC.Collect();
and even stop and start again the BluetoothLEAdvertisementWatcher. But when this device starts advertising again, it is not recognized. Of my understanding the reason is that the device was not actually disconnected (despite that it shows disconnected status) or some connection information is still pending, which prevents it to be recognized on a new advertisement.
Even if I don't apply the above procedure, a new device advertisement (from the same or other BLE device) is not recognized and in both cases the only resort is to restart the Win 10 IoT and restart the application in order a new advertisement from the same device to be recognized. After the communication with the device completes, an advertisement from different device of the same type can be recognized. But when the second device completes to communicate, no new advertisement from it or the first device can be recognized again. No exceptions or other problems were reported in debug mode. This is really inacceptable in an application production version.
Please advise me how to solve this problem. Thanks.