mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-02-10 19:52:24 +00:00
Remove old devices
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
#include <QBluetoothDeviceDiscoveryAgent>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
class QTimer;
|
||||
|
||||
class DeviceInfo
|
||||
{
|
||||
@@ -41,6 +44,8 @@ public:
|
||||
UNKNOWN
|
||||
};
|
||||
LidState lidState = LidState::UNKNOWN;
|
||||
|
||||
QDateTime lastSeen; // Timestamp of last detection
|
||||
};
|
||||
|
||||
class BleManager : public QObject
|
||||
@@ -58,10 +63,15 @@ private slots:
|
||||
void onDeviceDiscovered(const QBluetoothDeviceInfo &info);
|
||||
void onScanFinished();
|
||||
void onErrorOccurred(QBluetoothDeviceDiscoveryAgent::Error error);
|
||||
void pruneOldDevices();
|
||||
|
||||
private:
|
||||
QBluetoothDeviceDiscoveryAgent *discoveryAgent;
|
||||
QMap<QString, DeviceInfo> devices;
|
||||
|
||||
QTimer *pruneTimer; // Timer for periodic pruning
|
||||
static const int PRUNE_INTERVAL_MS = 5000; // Check every 5 seconds
|
||||
static const int DEVICE_TIMEOUT_MS = 10000; // Remove after 10 seconds
|
||||
};
|
||||
|
||||
#endif // BLEMANAGER_H
|
||||
Reference in New Issue
Block a user