Add new bluetooth class as model for scanning. Add UI to show scanned devices on top of page.

This commit is contained in:
2019-11-07 23:05:56 -05:00
parent 62bf803c71
commit e0689cc7e8
7 changed files with 231 additions and 11 deletions

View File

@@ -24,6 +24,8 @@
#include <QtBluetooth/QLowEnergyController>
#include <QtBluetooth/QLowEnergyService>
#include <QtBluetooth/QLowEnergyCharacteristic>
#include "bluetoothdevices.h"
#include <QQmlListProperty>
/**
* Class using QtBluetooth to find and retrive info from Mi Flora devices.
@@ -36,16 +38,18 @@ class MiFlora : public QObject
Q_PROPERTY(quint8 moisture NOTIFY moistureChanged MEMBER moisture)
Q_PROPERTY(quint16 conduction NOTIFY conductionChanged MEMBER conduct)
Q_PROPERTY(quint8 battery NOTIFY batteryChanged MEMBER battery)
Q_PROPERTY(QQmlListProperty<BluetoothDevices> devices READ getDeviceList NOTIFY newDeviceFound)
public:
Q_INVOKABLE void startSearch();
Q_INVOKABLE void stopSearch();
Q_INVOKABLE void updateDataFromDevice(QString mac);
QQmlListProperty<BluetoothDevices> getDeviceList();
//TODO:History?
signals:
void newDeviceFound(QString name, QString address);
void newDeviceFound();
void temperatureChanged(float temperature);
void brightnessChanged(quint32 brightness);
void moistureChanged(quint8 moisture);
@@ -62,7 +66,7 @@ private:
void serviceCharRead(QLowEnergyCharacteristic readChar, QByteArray value);
QBluetoothDeviceDiscoveryAgent *agent;
QList<QBluetoothDeviceInfo> devices;
QList<BluetoothDevices*> devices;
QLowEnergyController *currentController;
QLowEnergyService *sensorService;