summaryrefslogtreecommitdiff
path: root/gatocentralmanager.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-12-07 01:51:59 +0100
committerJavier S. Pedro <maemo@javispedro.com>2013-12-07 01:51:59 +0100
commit55496b91d2b144c5b8aafd20a8c8332aee4607ab (patch)
tree877b7ae6e8ea63000272270e54e665ecdb8d80f3 /gatocentralmanager.cpp
parenta7161d92f965848049dbb2eaa80cce0aa178c0ed (diff)
downloadlibgato-55496b91d2b144c5b8aafd20a8c8332aee4607ab.tar.gz
libgato-55496b91d2b144c5b8aafd20a8c8332aee4607ab.zip
add a method to retrieve a known device from a manager
Diffstat (limited to 'gatocentralmanager.cpp')
-rw-r--r--gatocentralmanager.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/gatocentralmanager.cpp b/gatocentralmanager.cpp
index 00dd531..0d3efd9 100644
--- a/gatocentralmanager.cpp
+++ b/gatocentralmanager.cpp
@@ -51,6 +51,20 @@ GatoCentralManager::~GatoCentralManager()
delete d_ptr;
}
+GatoPeripheral * GatoCentralManager::getPeripheral(const GatoAddress &address)
+{
+ Q_D(GatoCentralManager);
+
+ GatoPeripheral *peripheral = d->peripherals.value(address);
+ if (peripheral) {
+ return peripheral;
+ } else {
+ peripheral = new GatoPeripheral(address, this);
+ d->peripherals.insert(address, peripheral);
+ return peripheral;
+ }
+}
+
void GatoCentralManager::scanForPeripherals(PeripheralScanOptions options)
{
scanForPeripheralsWithServices(QList<GatoUUID>(), options);
@@ -215,5 +229,20 @@ void GatoCentralManagerPrivate::handleAdvertising(le_advertising_info *info, int
peripheral->parseEIR(info->data, info->length);
}
- emit q->discoveredPeripheral(peripheral, rssi);
+ bool passes_filter;
+ if (filter_uuids.isEmpty()) {
+ passes_filter = true;
+ } else {
+ passes_filter = false;
+ foreach (const GatoUUID & filter_uuid, filter_uuids) {
+ if (peripheral->advertisesService(filter_uuid)) {
+ passes_filter = true;
+ break;
+ }
+ }
+ }
+
+ if (passes_filter) {
+ emit q->discoveredPeripheral(peripheral, rssi);
+ }
}