replace flatpak config with published one. Only builds from git now.
Made large progress on getting history from device.
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
#include <QtBluetooth/QLowEnergyCharacteristic>
|
||||
#include "bluetoothdevices.h"
|
||||
#include <QQmlListProperty>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDateTime>
|
||||
#include <QStandardItemModel>
|
||||
#include "florahistory.h"
|
||||
|
||||
/**
|
||||
* Class using QtBluetooth to find and retrive info from Mi Flora devices.
|
||||
@@ -39,6 +43,7 @@ class MiFlora : public QObject
|
||||
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)
|
||||
Q_PROPERTY(QAbstractTableModel* model READ getModel NOTIFY historyUpdated)
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void startSearch();
|
||||
@@ -46,10 +51,11 @@ public:
|
||||
|
||||
Q_INVOKABLE void updateDataFromDevice(QString mac);
|
||||
QQmlListProperty<BluetoothDevices> getDeviceList();
|
||||
//TODO:History?
|
||||
QAbstractTableModel* getModel();
|
||||
|
||||
signals:
|
||||
void newDeviceFound();
|
||||
void historyUpdated();
|
||||
void temperatureChanged(float temperature);
|
||||
void brightnessChanged(quint32 brightness);
|
||||
void moistureChanged(quint8 moisture);
|
||||
@@ -61,19 +67,33 @@ private:
|
||||
void serviceDiscovered(const QBluetoothUuid &gatt);
|
||||
void logControllerError(QLowEnergyController::Error err);
|
||||
void logServiceError(QLowEnergyService::ServiceError err);
|
||||
void serviceStateChanges(QLowEnergyService::ServiceState state);
|
||||
void sensorServiceStateChanges(QLowEnergyService::ServiceState state);
|
||||
void historyServiceStateChanges(QLowEnergyService::ServiceState state);
|
||||
void serviceCharWritten(QLowEnergyCharacteristic changedChar, QByteArray value);
|
||||
void serviceCharRead(QLowEnergyCharacteristic readChar, QByteArray value);
|
||||
void historyServiceCharWritten(QLowEnergyCharacteristic changedChar, QByteArray value);
|
||||
void historyServiceCharWrittenData(QLowEnergyCharacteristic changedChar, QByteArray value);
|
||||
void historyServiceCharRead(QLowEnergyCharacteristic readChar, QByteArray value);
|
||||
void historyServiceCharReadData(QLowEnergyCharacteristic readChar, QByteArray value);
|
||||
QLowEnergyCharacteristic getCharFromValue(QLowEnergyService *service, quint16 characteristic);
|
||||
|
||||
QBluetoothDeviceDiscoveryAgent *agent;
|
||||
QList<BluetoothDevices*> devices;
|
||||
QLowEnergyController *currentController;
|
||||
QLowEnergyService *sensorService;
|
||||
QLowEnergyService *historyService;
|
||||
|
||||
const quint16 dataService = 4612; //0x1204
|
||||
const quint16 dataServiceChar = 4612; //0x1204
|
||||
const quint16 historyServiceChar = 4614; //0x1206
|
||||
const quint16 batteryFirmwareChar = 6658;//0x1a02
|
||||
const quint16 sensorsChar = 6657; //0x1a01
|
||||
const quint16 magicChar = 6656; //0x1a00
|
||||
const quint16 historyControllerChar = 6672; //0x1a10
|
||||
const quint16 historyReaderChar = 6673; //0x1a11
|
||||
const quint16 historyTimeChar = 6674; //0x1a12
|
||||
const QByteArray magicBytes = QByteArray::fromHex("a01f");
|
||||
const QByteArray historyReadInit = QByteArray::fromHex("a00000");
|
||||
|
||||
|
||||
float temp = 0.0;
|
||||
quint32 bright = 0;
|
||||
@@ -81,6 +101,11 @@ private:
|
||||
quint16 conduct = 0;
|
||||
quint8 battery = 0;
|
||||
QString version;
|
||||
qint64 deviceStartTime;
|
||||
qint16 currentHistoryEntry;
|
||||
qint16 lastHistoryEntry;
|
||||
|
||||
FloraHistory *floraModel = new FloraHistory();
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user