From 0ba105d2a71d65fb272837a753bf54c3e5094f8f Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 25 Sep 2018 15:20:33 -0700 Subject: qt-ble: only connect the signals to the preferred service We used to just find all services and connect the characteristics change signal etc to them all, but we really only care about the actual preferred service that we'll be using. So move the qt ble signal connection to after we've selected the preferred service that we will actually be enabling notifications on and do the writes to. Signed-off-by: Linus Torvalds --- core/qt-ble.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 6ddc1a9b8..4fc2cd5df 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -100,10 +100,6 @@ void BLEObject::addService(const QBluetoothUuid &newService) qDebug() << " .. created service object" << service; if (service) { services.append(service); - connect(service, &QLowEnergyService::stateChanged, this, &BLEObject::serviceStateChanged); - connect(service, &QLowEnergyService::characteristicChanged, this, &BLEObject::characteristcStateChanged); - connect(service, &QLowEnergyService::characteristicWritten, this, &BLEObject::characteristicWritten); - connect(service, &QLowEnergyService::descriptorWritten, this, &BLEObject::writeCompleted); service->discoverDetails(); } } @@ -285,6 +281,11 @@ dc_status_t BLEObject::select_preferred_service(void) return DC_STATUS_IO; } + connect(preferred, &QLowEnergyService::stateChanged, this, &BLEObject::serviceStateChanged); + connect(preferred, &QLowEnergyService::characteristicChanged, this, &BLEObject::characteristcStateChanged); + connect(preferred, &QLowEnergyService::characteristicWritten, this, &BLEObject::characteristicWritten); + connect(preferred, &QLowEnergyService::descriptorWritten, this, &BLEObject::writeCompleted); + return DC_STATUS_SUCCESS; } -- cgit v1.2.3-70-g09d2