This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-core/libguh/bluetooth/bluetoothlowenergymanager.cpp
2019-04-02 01:02:45 +02:00

52 lines
1.5 KiB
C++

#include "bluetoothlowenergymanager.h"
#include "loggingcategories.h"
BluetoothLowEnergyManager::BluetoothLowEnergyManager(QObject *parent) :
HardwareResource(HardwareResource::TypeBluetoothLE, "Bluetooth LE manager", parent)
{
// Check which bluetooth adapter are available
QList<QBluetoothHostInfo> bluetoothAdapters = QBluetoothLocalDevice::allDevices();
if (bluetoothAdapters.isEmpty()) {
qCWarning(dcHardware()) << name() << "No bluetooth adapter found. Resource not available.";
setAvailable(false);
return;
}
// Create a scanner for each adapter
foreach (const QBluetoothHostInfo &hostInfo, bluetoothAdapters) {
qCDebug(dcHardware()) << name() << "Adapter:" << hostInfo.name() << hostInfo.address().toString();
m_bluetoothScanners.append(new BluetoothScanner(hostInfo.address(), this));
}
// // Check if Bluetooth is available on this device
// if (!localDevice.isValid()) {
// qCWarning(dcHardware()) << "No Bluetooth device found.";
// setAvailable(false);
// return false;
// }
// // Turn Bluetooth on
// localDevice.powerOn();
// // Make it visible to others
// localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
qCDebug(dcHardware()) << "-->" << name() << "created successfully.";
setAvailable(true);
}
bool BluetoothLowEnergyManager::enable()
{
// TODO: enable all devices created by this
return true;
}
bool BluetoothLowEnergyManager::disable()
{
return true;
}