I have an application which uses the BLE DLL. The BLE library will take care of the device scan, connection, etc.
I have tried to link the BLE DLL dynamically. The Bluetooth scanning is completed without any issue. When I tried to call the connection API from the BLE DLL. the issue occurs.
fire_and_forget SensorDeviceInfo::ConnectToDevice(condition_variable& signal, bool& bConnected)
{
// Returns a BluetoothLEDevice object for the given Id and initiate a connection
m_BluetoothLEDevice = co_await BluetoothLEDevice::FromIdAsync(GetId());
if (m_BluetoothLEDevice == nullptr)
{
LogError(m_Log, __func__, "Failed to connect to device.");
}
if (m_BluetoothLEDevice != nullptr)
{
m_ConnectionStatusEventToken = m_BluetoothLEDevice.ConnectionStatusChanged({ this, &SensorDeviceInfo::ConnectionStatusChangeHandler });
}
signal.notify_one();
}
Above is the code snippet. Since this is a asynchronous call, I have used condition variable to block the thread until the function completes. Because I need the call like synchronous.
mutex mtxConnect;
unique_lock lockConnect(mtxConnect);
condition_variable cvConnect;
// Connect to the sensor ble device
m_CurrentDevice->ConnectToDevice(cvConnect, bConnected);
cvConnect.wait(lockConnect);
While debugging the application, the call enter in the FromIdAsync place, but after some time it is getting hanged. The callstack disappeared..
I can see the mfc10.dll having some issue in Dependencies tool. Which have dependency with api-ms-win-core-wow64-l1-1-0.dll,
api-ms-win-core-wow64-l1-1-1.dll, api-ms-win-core-winrt-string-l1-1-0.dll
I am using VS2019 and latest redistributable files.
