From 55496b91d2b144c5b8aafd20a8c8332aee4607ab Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sat, 7 Dec 2013 01:51:59 +0100 Subject: add a method to retrieve a known device from a manager --- gatocentralmanager.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'gatocentralmanager.cpp') 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(), 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); + } } -- cgit v1.2.3