ConnectionManager::~ConnectionManager() {
	// De-initialize the btdevice library.
	bt_device_deinit();

	// De-initialize the library.
	bt_spp_deinit();

	s_cm = 0;
}
BlueToothManager::~BlueToothManager() {
	Gate g(this, "~BlueToothManager()");
	{
		QMutexLocker lock(&threadLock);
		if (thread != NULL) {
			thread->close();
		}
	}
	g.log() << "spp_deinit" << bt_spp_deinit();
	bt_device_deinit();
}
QBluetoothSocketPrivate::~QBluetoothSocketPrivate()
{
#ifdef QT_QNX_BT_BLUETOOTH
    if (initCounter == 1 && (bt_spp_deinit() == -1))
        qCDebug(QT_BT_QNX) << "Could not deinitialize Bluetooth library."
                              "SPP connection is still open.";

    initCounter--;
#else
    ppsUnregisterControl(this);
#endif
    close();
}
ArduinoBTController::~ArduinoBTController()
{

    int closeFD = m_sppDataThread.getFD();
    m_sppDataThread.resetFD();
    bt_spp_close(closeFD);

    int errorCode;
    errorCode = bt_spp_deinit();
    qDebug() << "bt_spp_deinit" << errorCode;



}