PDA

View Full Version : Bluetooth low energy private service support



user03
19th August 2016, 21:06
As per the examples provided on the Qt website, UUIDs of the adopted services can be used, however, is it possible to search a private service on the basis of UUID?
Below is the snippet of the code that is used to access the heart rate service:
void HeartRate::serviceDiscovered(const QBluetoothUuid &gatt)
{
if (gatt == QBluetoothUuid(QBluetoothUuid::HeartRate)) {
setMessage("Heart Rate service discovered. Waiting for service scan to be done...");
foundHeartRateService = true;
}
}

Is it possible to replace HeartRate with another private service, if yes, then could anyone provide the steps to achieve the same.

anda_skoa
20th August 2016, 11:29
What kind of information do you have?

QBluetoothUuid has plenty of constructors, doesn't any of them match what you have?

Cheers,
_

user03
20th August 2016, 18:56
I have the UUID of the service and the characteristic. Could you please illustrate the same using the existing constructor or provide some information about the relevant constructor to be utilised.
Thank you.

ChrisW67
21st August 2016, 05:43
If you have the UUID as a string then I guess the obvious place to start would be:


namespace {
QString const privateServiceUUID("b3deffdf-5346-4b50-ab23-6cb32cc56bcc");
}

void HeartRate::serviceDiscovered(const QBluetoothUuid &gatt)
{
if (gatt == QBluetoothUuid(privateServiceUUID)) {
setMessage("Heart Rate service discovered. Waiting for service scan to be done...");
foundHeartRateService = true;
}
}

anda_skoa
21st August 2016, 11:26
I have the UUID of the service and the characteristic.

You already wrote that, but how do you have the UUID, which datatype.
As a string? As a QUuid?



Could you please illustrate the same using the existing constructor
You are not seriously asking on how to pass arugments to constructor, are you?

Cheers,
_