summaryrefslogtreecommitdiffstats
path: root/core/qt-ble.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/qt-ble.h')
-rw-r--r--core/qt-ble.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/core/qt-ble.h b/core/qt-ble.h
new file mode 100644
index 000000000..b819b0123
--- /dev/null
+++ b/core/qt-ble.h
@@ -0,0 +1,38 @@
+#ifndef QT_BLE_H
+#define QT_BLE_H
+
+#include <QLowEnergyController>
+#include <QEventLoop>
+
+class BLEObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ BLEObject(QLowEnergyController *c);
+ ~BLEObject();
+ dc_status_t write(const void* data, size_t size, size_t *actual);
+ dc_status_t read(void* data, size_t size, size_t *actual);
+ QLowEnergyService *service;
+
+public slots:
+ void addService(const QBluetoothUuid &newService);
+ void serviceStateChanged(QLowEnergyService::ServiceState s);
+ void characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value);
+ void writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value);
+
+private:
+ QLowEnergyController *controller;
+ QList<QByteArray> receivedPackets;
+ QEventLoop waitForPacket;
+};
+
+
+extern "C" {
+dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *name);
+dc_status_t qt_ble_read(dc_custom_io_t *io, void* data, size_t size, size_t *actual);
+dc_status_t qt_ble_write(dc_custom_io_t *io, const void* data, size_t size, size_t *actual);
+dc_status_t qt_ble_close(dc_custom_io_t *io);
+}
+
+#endif