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 <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2018-09-25 15:20:33 -07:00 committed by Dirk Hohndel
parent b19fe27e19
commit 0ba105d2a7

View file

@ -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;
}