diff --git a/OmobiDisplayApp/OmobiDisplayApp.pro b/OmobiDisplayApp/OmobiDisplayApp.pro new file mode 100644 index 0000000..cbb9d46 --- /dev/null +++ b/OmobiDisplayApp/OmobiDisplayApp.pro @@ -0,0 +1,31 @@ +QT += quick bluetooth + +CONFIG += c++11 console + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + bluetoothdeviceinfo.cpp \ + main.cpp \ + omobidisplaybackend.cpp \ + qbluetoothleuart.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Additional import path used to resolve QML modules just for Qt Quick Designer +QML_DESIGNER_IMPORT_PATH = + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +HEADERS += \ + bluetoothdeviceinfo.h \ + omobidisplaybackend.h \ + qbluetoothleuart.h diff --git a/OmobiDisplayApp/OmobiDisplayApp.pro.user b/OmobiDisplayApp/OmobiDisplayApp.pro.user new file mode 100644 index 0000000..0e13899 --- /dev/null +++ b/OmobiDisplayApp/OmobiDisplayApp.pro.user @@ -0,0 +1,653 @@ + + + + + + EnvironmentId + {8b2b329f-2b96-47e0-8e3b-213b44b4afec} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + true + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 5.12.6 GCC 64bit + Desktop Qt 5.12.6 GCC 64bit + qt.qt5.5126.gcc_64_kit + 0 + 0 + 0 + + true + 0 + /home/dorian/Qt/builds/build-OmobiDisplayApp-Desktop_Qt_5_12_6_GCC_64bit-Debug + /home/dorian/Qt/builds/build-OmobiDisplayApp-Desktop_Qt_5_12_6_GCC_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 2 + 2 + + + true + 2 + /home/dorian/Qt/builds/build-OmobiDisplayApp-Desktop_Qt_5_12_6_GCC_64bit-Release + /home/dorian/Qt/builds/build-OmobiDisplayApp-Desktop_Qt_5_12_6_GCC_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 2 + + + true + 0 + /home/dorian/Qt/builds/build-OmobiDisplayApp-Desktop_Qt_5_12_6_GCC_64bit-Profile + /home/dorian/Qt/builds/build-OmobiDisplayApp-Desktop_Qt_5_12_6_GCC_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/dorian/Documents/Programmieren/Qt/OmobiDisplayApp/OmobiDisplayApp.pro + /home/dorian/Documents/Programmieren/Qt/OmobiDisplayApp/OmobiDisplayApp.pro + + false + + false + true + true + false + false + true + + /home/dorian/Qt/builds/build-OmobiDisplayApp-Desktop_Qt_5_12_6_GCC_64bit-Debug + + 1 + + + + ProjectExplorer.Project.Target.1 + + Android.Device.Type + Android Qt 5.12.6 Clang armeabi-v7a + Android Qt 5.12.6 Clang armeabi-v7a + {9a47ee8f-1702-4ae9-96f9-7c13c7a1f9b3} + 0 + 0 + 0 + + true + 0 + /home/dorian/Qt/builds/build-OmobiDisplayApp-Android_Qt_5_12_6_Clang_armeabi_v7a-Debug + /home/dorian/Qt/builds/build-OmobiDisplayApp-Android_Qt_5_12_6_Clang_armeabi_v7a-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + + true + Qt4ProjectManager.AndroidPackageInstallationStep + + + android-29 + + true + QmakeProjectManager.AndroidBuildApkStep + false + + 4 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 2 + 2 + + + true + 2 + /home/dorian/Qt/builds/build-OmobiDisplayApp-Android_Qt_5_12_6_Clang_armeabi_v7a-Release + /home/dorian/Qt/builds/build-OmobiDisplayApp-Android_Qt_5_12_6_Clang_armeabi_v7a-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + + true + Qt4ProjectManager.AndroidPackageInstallationStep + + + android-29 + + true + QmakeProjectManager.AndroidBuildApkStep + false + + 4 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 2 + + + true + 0 + /home/dorian/Qt/builds/build-OmobiDisplayApp-Android_Qt_5_12_6_Clang_armeabi_v7a-Profile + /home/dorian/Qt/builds/build-OmobiDisplayApp-Android_Qt_5_12_6_Clang_armeabi_v7a-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + + true + Qt4ProjectManager.AndroidPackageInstallationStep + + + android-29 + + true + QmakeProjectManager.AndroidBuildApkStep + false + + 4 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + + true + Qt4ProjectManager.AndroidDeployQtStep + false + + 1 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + Qt4ProjectManager.AndroidDeployConfiguration2 + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + + + + 0 + + OmobiDisplayApp + Qt4ProjectManager.AndroidRunConfiguration:/home/dorian/Documents/Programmieren/Qt/OmobiDisplayApp/OmobiDisplayApp.pro + /home/dorian/Documents/Programmieren/Qt/OmobiDisplayApp/OmobiDisplayApp.pro + + false + + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/OmobiDisplayApp/main.cpp b/OmobiDisplayApp/main.cpp new file mode 100644 index 0000000..dfe87bb --- /dev/null +++ b/OmobiDisplayApp/main.cpp @@ -0,0 +1,26 @@ +#include +#include + +#include "omobidisplaybackend.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + + QGuiApplication app(argc, argv); + + OmobiDisplayBackend b; + b.startScanning(); + + /* + QQmlApplicationEngine engine; + const QUrl url(QStringLiteral("qrc:/main.qml")); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, + &app, [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, Qt::QueuedConnection); + engine.load(url); +*/ + return app.exec(); +} diff --git a/OmobiDisplayApp/main.qml b/OmobiDisplayApp/main.qml new file mode 100644 index 0000000..564b258 --- /dev/null +++ b/OmobiDisplayApp/main.qml @@ -0,0 +1,10 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.0 +import QtQuick.Window 2.12 + +ApplicationWindow { + width: 640 + height: 480 + visible: true + title: qsTr("Hello World") +} diff --git a/OmobiDisplayApp/omobidisplaybackend.cpp b/OmobiDisplayApp/omobidisplaybackend.cpp new file mode 100644 index 0000000..67e691b --- /dev/null +++ b/OmobiDisplayApp/omobidisplaybackend.cpp @@ -0,0 +1,85 @@ +#include "omobidisplaybackend.h" + +OmobiDisplayBackend::OmobiDisplayBackend(QObject *parent) : QObject(parent) +{ + + this->ble = new QBluetoothLeUart(); + + connect(this->ble, &QBluetoothLeUart::stateChanged, this, &OmobiDisplayBackend::handleBluetoothStateChange); + connect(this->ble, &QBluetoothLeUart::foundNewDevice, this, &OmobiDisplayBackend::handleFoundNewDevice); + connect(this->ble, &QBluetoothLeUart::dataReceived, this, &OmobiDisplayBackend::DataHandler); + +} + + +void OmobiDisplayBackend::startScanning() { + this->ble->startScanningForDevices(); +} + +void OmobiDisplayBackend::handleBluetoothStateChange(QBluetoothLeUart::BluetoothLeUartState state){ + + qDebug() << state; + + switch(state){ + + case QBluetoothLeUart::Scanning: + { + qDebug() << "Now scanning"; + break; + } + + + case QBluetoothLeUart::ScanFinished: + { + qDebug() << "Scan finished"; + + break; + } + + case QBluetoothLeUart::Connecting: + { + qDebug() << "Now connecting"; + break; + } + case QBluetoothLeUart::Connected: + { + qDebug() << "Connected."; + break; + } + case QBluetoothLeUart::ServiceFound: + { + qDebug() << "Service found!"; + break; + } + case QBluetoothLeUart::AcquireData: + { + qDebug() << "Now acquiring data!"; + + /* Initialise Slot DataHandler(QString) - gets new data */ + + this->ble->sendData("Hat geklappt"); + break; + } + default: + //nothing for now + break; + + + } +} + +void OmobiDisplayBackend::handleFoundNewDevice(BluetoothDeviceInfo* device) { + qDebug() << "Found a device: name: " << device->getName() << " address: " << device->getAddress(); + + if(device->getName() == "ESP32 Chat Test") { + this->ble->stopScanningForDevices(); + this->ble->connectToDevice(device); + } +} + +void OmobiDisplayBackend::DataHandler(const QString &s){ + + qDebug() << "NEw data: " << s; + +} + diff --git a/OmobiDisplayApp/omobidisplaybackend.h b/OmobiDisplayApp/omobidisplaybackend.h new file mode 100644 index 0000000..94979e7 --- /dev/null +++ b/OmobiDisplayApp/omobidisplaybackend.h @@ -0,0 +1,27 @@ +#ifndef OMOBIDISPLAYBACKEND_H +#define OMOBIDISPLAYBACKEND_H + +#include +#include "qbluetoothleuart.h" + +class OmobiDisplayBackend : public QObject +{ + Q_OBJECT +public: + explicit OmobiDisplayBackend(QObject *parent = nullptr); + + void startScanning(); + +private: + QBluetoothLeUart *ble; + +private slots: + void handleBluetoothStateChange(QBluetoothLeUart::BluetoothLeUartState state); + void handleFoundNewDevice(BluetoothDeviceInfo* device); + void DataHandler(const QString &s); + +signals: + +}; + +#endif // OMOBIDISPLAYBACKEND_H diff --git a/OmobiDisplayApp/qml.qrc b/OmobiDisplayApp/qml.qrc new file mode 100644 index 0000000..5f6483a --- /dev/null +++ b/OmobiDisplayApp/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + +