Scanning BLE beacons
-
It's your custom class of some sort! We can't know how to use a class we don't know :-)
-
@jsulm said in Scanning BLE beacons:
@jenya7 https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html has this.
What is this Device class? Its constructor takes a QBluetoothDeviceInfo instance, so it should have the information...I added it to a list
if (d->getName() == "MyDeviceName") devices.append(d);
How do I retrieve the device data?
No fields like
devices[i].Name
devices[i].Data@jenya7 said in Scanning BLE beacons:
How do I retrieve the device data?
Why do you ask us?
Device is your class, you did not even show its code - how should we know?! -
@jsulm said in Scanning BLE beacons:
@jenya7 https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html has this.
What is this Device class? Its constructor takes a QBluetoothDeviceInfo instance, so it should have the information...I added it to a list
if (d->getName() == "MyDeviceName") devices.append(d);
How do I retrieve the device data?
No fields like
devices[i].Name
devices[i].Data@jenya7 said in Scanning BLE beacons:
if (d->getName() == "MyDeviceName")
devices.append(d);According to this code you do it this way:
devices[i]->getName();
-
@jenya7 said in Scanning BLE beacons:
How do I retrieve the device data?
Why do you ask us?
Device is your class, you did not even show its code - how should we know?!@jsulm said in Scanning BLE beacons:
@jenya7 said in Scanning BLE beacons:
How do I retrieve the device data?
Why do you ask us?
Device is your class, you did not even show its code - how should we know?!Why? It's Qt class
QBluetoothDeviceInfo &info
Here
void BT_DEVICE::AddDevice(const QBluetoothDeviceInfo &info) { if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) { auto d = new DeviceInfo(info); if (d->getName() == "MyDeviceName") devices.append(d); } }
I see my device name (d->getName() ) so it probably should hold the beacon raw data (like d->data())
-
@jenya7 said in Scanning BLE beacons:
auto d = new DeviceInfo(info);
DeviceInfo
is NOTQBluetoothDeviceInfo
. It's some custom class you created. We don't know how to access it.If you are asking how to get data from
info
(which is an instance ofQBluetoothDeviceInfo
), then just read the docs we have already linked: https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html -
@jenya7 said in Scanning BLE beacons:
auto d = new DeviceInfo(info);
DeviceInfo
is NOTQBluetoothDeviceInfo
. It's some custom class you created. We don't know how to access it.If you are asking how to get data from
info
(which is an instance ofQBluetoothDeviceInfo
), then just read the docs we have already linked: https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html@sierdzio said in Scanning BLE beacons:
@jenya7 said in Scanning BLE beacons:
auto d = new DeviceInfo(info);
DeviceInfo
is NOTQBluetoothDeviceInfo
. It's some custom class you created. We don't know how to access it.If you are asking how to get data from
info
(which is an instance ofQBluetoothDeviceInfo
), then just read the docs we have already linked: https://doc.qt.io/qt-5/qbluetoothdeviceinfo.htmlI see. Yes I use this class (from an example - C:\Qt\Examples\Qt-5.12.0\bluetooth\lowenergyscanner)
class DeviceInfo: public QObject { Q_OBJECT Q_PROPERTY(QString deviceName READ getName NOTIFY deviceChanged) Q_PROPERTY(QString deviceAddress READ getAddress NOTIFY deviceChanged) public: DeviceInfo() = default; DeviceInfo(const QBluetoothDeviceInfo &d); QString getAddress() const; QString getName() const; QBluetoothDeviceInfo getDevice(); void setDevice(const QBluetoothDeviceInfo &dev); Q_SIGNALS: void deviceChanged(); private: QBluetoothDeviceInfo device; };
So it has
QString DeviceInfo::getName() const { return device.name(); }
What if I want to add
DeviceInfo::getData() const { return device. //???? - no data field }
-
But what data do you want to read? Manufacturer data? Device UUID? Address?
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
-
But what data do you want to read? Manufacturer data? Device UUID? Address?
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
@sierdzio said in Scanning BLE beacons:
But what data do you want to read? Manufacturer data? Device UUID? Address?
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
OK. I understand. I can use info directly like info.name, but how do I get data (no info.data).
Yes I want to se all beacon raw data - payload. I need no services. It's a remote sensor sending me temperature, humidity, pressure, etc. -
But what data do you want to read? Manufacturer data? Device UUID? Address?
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
@sierdzio said in Scanning BLE beacons:
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
not with beacon, beacons are not connectable. And the Qt Api gives no way to identify that.
what the op is looking for should be in
https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1 -
It's been a long time since I've done it, sorry I don't remember the details. Check the example docs above, it explains how to connect to various services and characteristics, then you can start receiving the data.
-
@sierdzio said in Scanning BLE beacons:
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
not with beacon, beacons are not connectable. And the Qt Api gives no way to identify that.
what the op is looking for should be in
https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1@J-Hilk said in Scanning BLE beacons:
@sierdzio said in Scanning BLE beacons:
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
not with beacon, beacons are not connectable. And the Qt Api gives no way to identify that.
what the op is looking for should be in
https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1No. It has to get a payload. Every beacon has a payload (20 bytes) of my own data. App. I wrote on my phone (Android) gets all beacons and I see my payload too.
Wat's the point to get a beacon? To see it's name, rssi, and other fields ? I need the data it sends. -
@J-Hilk said in Scanning BLE beacons:
@sierdzio said in Scanning BLE beacons:
Or you want to read the data that the device is sending? To do that, you need to connect to it first. https://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html#connecting-to-services
not with beacon, beacons are not connectable. And the Qt Api gives no way to identify that.
what the op is looking for should be in
https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1No. It has to get a payload. Every beacon has a payload (20 bytes) of my own data. App. I wrote on my phone (Android) gets all beacons and I see my payload too.
Wat's the point to get a beacon? To see it's name, rssi, and other fields ? I need the data it sends.@jenya7 I'm not sure to what you're replying ?
I said, your payload can be accessed via https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1
I do it too.
-
@jenya7 I'm not sure to what you're replying ?
I said, your payload can be accessed via https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1
I do it too.
@J-Hilk said in Scanning BLE beacons:
@jenya7 I'm not sure to what you're replying ?
I said, your payload can be accessed via https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1
I do it too.
I see. But info has no such field.
void BT_DEVICE::AddDevice(const QBluetoothDeviceInfo &info) { info. //no manufacturerData }
-
This function was introduced in Qt 5.12.
Maybe you are using older Qt version?
-
@J-Hilk said in Scanning BLE beacons:
@jenya7 I'm not sure to what you're replying ?
I said, your payload can be accessed via https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1
I do it too.
I see. But info has no such field.
void BT_DEVICE::AddDevice(const QBluetoothDeviceInfo &info) { info. //no manufacturerData }
@jenya7 said in Scanning BLE beacons:
@J-Hilk said in Scanning BLE beacons:
@jenya7 I'm not sure to what you're replying ?
I said, your payload can be accessed via https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1
I do it too.
I see. But info has no such field.
no, it does not, and here you come in and either
- expand DeviceInfo class that comes with the BTLE example and you're usingor
- create your own interface class that wraps around QBlueToothDeviceInfowritten before the edit of
void BT_DEVICE::AddDevice(const QBluetoothDeviceInfo &info)
{
info. //no manufacturerData
}@sierdzio is probably right, what version are you using?
-
@jenya7 said in Scanning BLE beacons:
@J-Hilk said in Scanning BLE beacons:
@jenya7 I'm not sure to what you're replying ?
I said, your payload can be accessed via https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#manufacturerData-1
I do it too.
I see. But info has no such field.
no, it does not, and here you come in and either
- expand DeviceInfo class that comes with the BTLE example and you're usingor
- create your own interface class that wraps around QBlueToothDeviceInfowritten before the edit of
void BT_DEVICE::AddDevice(const QBluetoothDeviceInfo &info)
{
info. //no manufacturerData
}@sierdzio is probably right, what version are you using?
-
@J-Hilk said in Scanning BLE beacons:
@sierdzio is probably right, what version are you using?
It is 5.11.3
-
@jenya7 If you follow the link from @J-Hilk you will see that you need Qt >= 5.12 for that method.
-
@jsulm said in Scanning BLE beacons:
@jenya7 If you follow the link from @J-Hilk you will see that you need Qt >= 5.12 for that method.
Wow. On Linux the latest available from repository is 5.11.3.
@jenya7 said in Scanning BLE beacons:
On Linux the latest available from repository is 5.11.3
You can install newer versions using Qt Online Installer...