initial commit
This commit is contained in:
parent
32d2e27a88
commit
8cc71db6e2
7 changed files with 874 additions and 0 deletions
32
QBluetoothLeUart.pri
Normal file
32
QBluetoothLeUart.pri
Normal file
|
@ -0,0 +1,32 @@
|
|||
!isEmpty(QBLUETOOTHLEUART_LIB):error("QBluetoothLeUart.pri already included")
|
||||
QBLUETOOTHLEUART_LIB = 1
|
||||
|
||||
QBluetoothLeUart_QML {
|
||||
QT += qml quickcontrols2
|
||||
DEFINES += QBluetoothLeUart_QML
|
||||
}
|
||||
|
||||
QT += core bluetooth
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
# 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 += \
|
||||
qbluetoothleuart.cpp \
|
||||
qbluetoothleuartdevice.cpp
|
||||
|
||||
HEADERS += \
|
||||
qbluetoothleuart.h \
|
||||
qbluetoothleuartdevice.h
|
||||
|
||||
# Default rules for deployment.
|
||||
unix {
|
||||
target.path = $$[QT_INSTALL_PLUGINS]/generic
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
34
QBluetoothLeUart.pro
Normal file
34
QBluetoothLeUart.pro
Normal file
|
@ -0,0 +1,34 @@
|
|||
!isEmpty(QBLUETOOTHLEUART_LIB):error("QBluetoothLeUart.pri already included")
|
||||
QBLUETOOTHLEUART_LIB = 1
|
||||
|
||||
CONFIG += QBluetoothLeUart_QML
|
||||
|
||||
QBluetoothLeUart_QML {
|
||||
QT += qml quickcontrols2
|
||||
DEFINES += QBluetoothLeUart_QML
|
||||
}
|
||||
|
||||
QT += core bluetooth
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
# 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 += \
|
||||
qbluetoothleuart.cpp \
|
||||
qbluetoothleuartdevice.cpp
|
||||
|
||||
HEADERS += \
|
||||
qbluetoothleuart.h \
|
||||
qbluetoothleuartdevice.h
|
||||
|
||||
# Default rules for deployment.
|
||||
unix {
|
||||
target.path = $$[QT_INSTALL_PLUGINS]/generic
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
355
QBluetoothLeUart.pro.user
Normal file
355
QBluetoothLeUart.pro.user
Normal file
|
@ -0,0 +1,355 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.13.1, 2020-10-08T19:56:41. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{8b2b329f-2b96-47e0-8e3b-213b44b4afec}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
|
||||
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.Questionable</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.6 GCC 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.6 GCC 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5126.gcc_64_kit</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="bool">true</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dorian/Qt/builds/build-QBluetoothLeUart-Desktop_Qt_5_12_6_GCC_64bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/dorian/Qt/builds/build-QBluetoothLeUart-Desktop_Qt_5_12_6_GCC_64bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="int" key="QtQuickCompiler">2</value>
|
||||
<value type="int" key="SeparateDebugInfo">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="bool">true</value>
|
||||
<value type="int" key="EnableQmlDebugging">2</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dorian/Qt/builds/build-QBluetoothLeUart-Desktop_Qt_5_12_6_GCC_64bit-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/dorian/Qt/builds/build-QBluetoothLeUart-Desktop_Qt_5_12_6_GCC_64bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="bool">true</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dorian/Qt/builds/build-QBluetoothLeUart-Desktop_Qt_5_12_6_GCC_64bit-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/dorian/Qt/builds/build-QBluetoothLeUart-Desktop_Qt_5_12_6_GCC_64bit-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">0</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||
<value type="QString">cpu-cycles</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
|
||||
<value type="QString">-e</value>
|
||||
<value type="QString">cpu-cycles</value>
|
||||
<value type="QString">--call-graph</value>
|
||||
<value type="QString">dwarf,4096</value>
|
||||
<value type="QString">-F</value>
|
||||
<value type="QString">250</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
278
qbluetoothleuart.cpp
Normal file
278
qbluetoothleuart.cpp
Normal file
|
@ -0,0 +1,278 @@
|
|||
#include "qbluetoothleuart.h"
|
||||
|
||||
QBluetoothLeUart::QBluetoothLeUart(QObject *parent) : QObject(parent)
|
||||
{
|
||||
currentBluetoothDevice = nullptr;
|
||||
bluetoothController = nullptr;
|
||||
bluetoothService = nullptr;
|
||||
|
||||
state = Idle;
|
||||
|
||||
/* 1 Step: Bluetooth LE Device Discovery */
|
||||
this->bluetoothDeviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
|
||||
|
||||
|
||||
/* Device Discovery Initialization */
|
||||
connect(this->bluetoothDeviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &QBluetoothLeUart::handleDeviceDiscovered);
|
||||
connect(bluetoothDeviceDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
|
||||
this, SLOT(handleDeviceScanError(QBluetoothDeviceDiscoveryAgent::Error)));
|
||||
connect(this->bluetoothDeviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &QBluetoothLeUart::handleScanFinished);
|
||||
}
|
||||
|
||||
QBluetoothLeUart::~QBluetoothLeUart(){
|
||||
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::init() {
|
||||
#ifdef QBluetoothLeUart_QML
|
||||
qmlRegisterUncreatableType<QBluetoothLeUartDevice>("de.itsblue.bluetoothleuart", 1, 0, "BluetoothDeviceInfo", "BluetoothDeviceInfo cannot be created");
|
||||
qmlRegisterType<QBluetoothLeUart>("de.itsblue.bluetoothleuart", 1, 0, "BluetoothLeUART");
|
||||
qRegisterMetaType<QBluetoothLeUart::BluetoothLeUartState>("QBluetoothLeUart::BluetoothLeUartState");
|
||||
qRegisterMetaType<QBluetoothLeUart::BluetoothScanError>("QBluetoothLeUart::BluetoothScanError");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void QBluetoothLeUart::startScanningForDevices(){
|
||||
|
||||
foreach(QBluetoothLeUartDevice* oldDevice, this->availableDevices)
|
||||
oldDevice->deleteLater();
|
||||
|
||||
this->availableDevices.clear();
|
||||
|
||||
setState(Scanning);
|
||||
bluetoothDeviceDiscoveryAgent->start();
|
||||
|
||||
qDebug()<< "Searching for low energy devices..." ;
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::stopScanningForDevices() {
|
||||
this->bluetoothDeviceDiscoveryAgent->stop();
|
||||
this->setState(ScanFinished);
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleDeviceDiscovered(const QBluetoothDeviceInfo &device)
|
||||
{
|
||||
// Is it a BLE device?
|
||||
if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) {
|
||||
//qWarning() << "Discovered BLE Device: name: " << device.name() << " Address: " << device.address().toString();
|
||||
QBluetoothLeUartDevice *dev = new QBluetoothLeUartDevice(device, this);
|
||||
availableDevices.append(dev);
|
||||
emit this->foundNewDevice(dev);
|
||||
emit this->avaliableDevicesChanged(this->availableDevices);
|
||||
}
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleScanFinished()
|
||||
{
|
||||
if (availableDevices.size() == 0)
|
||||
{
|
||||
qWarning() << "No Low Energy devices found" << endl;
|
||||
}
|
||||
|
||||
setState(ScanFinished);
|
||||
}
|
||||
|
||||
QList<QBluetoothLeUartDevice*> QBluetoothLeUart::getAvailableDevices() {
|
||||
return this->availableDevices;
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleDeviceScanError(QBluetoothDeviceDiscoveryAgent::Error error)
|
||||
{
|
||||
if (error == QBluetoothDeviceDiscoveryAgent::PoweredOffError)
|
||||
emit this->scanningErrorOccured(AdapterTurnedOffError);
|
||||
else if (error == QBluetoothDeviceDiscoveryAgent::InputOutputError)
|
||||
emit this->scanningErrorOccured(InputOutputError);
|
||||
else
|
||||
emit this->scanningErrorOccured(UnknownError);
|
||||
}
|
||||
|
||||
|
||||
void QBluetoothLeUart::connectToDevice(QBluetoothLeUartDevice *device){
|
||||
|
||||
m_qvMeasurements.clear();
|
||||
|
||||
this->currentBluetoothDevice = device;
|
||||
|
||||
if (bluetoothController) {
|
||||
bluetoothController->disconnectFromDevice();
|
||||
delete bluetoothController;
|
||||
bluetoothController = 0;
|
||||
}
|
||||
|
||||
/* 2 Step: QLowEnergyController */
|
||||
bluetoothController = new QLowEnergyController(currentBluetoothDevice->getDevice(), this);
|
||||
bluetoothController ->setRemoteAddressType(QLowEnergyController::RandomAddress);
|
||||
|
||||
connect(this->bluetoothController, &QLowEnergyController::serviceDiscovered, this, &QBluetoothLeUart::handleServiceDiscovered);
|
||||
connect(this->bluetoothController, &QLowEnergyController::discoveryFinished, this, &QBluetoothLeUart::handleServiceScanDone);
|
||||
connect(bluetoothController, SIGNAL(error(QLowEnergyController::Error)),
|
||||
this, SLOT(handleControllerError(QLowEnergyController::Error)));
|
||||
connect(this->bluetoothController, &QLowEnergyController::connected, this, &QBluetoothLeUart::handleDeviceConnected);
|
||||
connect(this->bluetoothController, &QLowEnergyController::disconnected, this, &QBluetoothLeUart::handleDeviceDisconnected);
|
||||
|
||||
/* Start connecting to device */
|
||||
bluetoothController->connectToDevice();
|
||||
setState(Connecting);
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::disconnectFromDevice() {
|
||||
this->bluetoothController->disconnectFromDevice();
|
||||
|
||||
disconnect(this->bluetoothController, &QLowEnergyController::serviceDiscovered, this, &QBluetoothLeUart::handleServiceDiscovered);
|
||||
disconnect(this->bluetoothController, &QLowEnergyController::discoveryFinished, this, &QBluetoothLeUart::handleServiceScanDone);
|
||||
disconnect(bluetoothController, SIGNAL(error(QLowEnergyController::Error)),
|
||||
this, SLOT(handleControllerError(QLowEnergyController::Error)));
|
||||
disconnect(this->bluetoothController, &QLowEnergyController::connected, this, &QBluetoothLeUart::handleDeviceConnected);
|
||||
disconnect(this->bluetoothController, &QLowEnergyController::disconnected, this, &QBluetoothLeUart::handleDeviceDisconnected);
|
||||
|
||||
this->bluetoothController->deleteLater();
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleDeviceDisconnected()
|
||||
{
|
||||
this->setState(Idle);
|
||||
qDebug() << "UART service disconnected";
|
||||
qWarning() << "Remote device disconnected";
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleDeviceConnected()
|
||||
{
|
||||
qDebug() << "Device connected";
|
||||
bluetoothController->discoverServices();
|
||||
setState(Connected);
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleControllerError(QLowEnergyController::Error error)
|
||||
{
|
||||
qDebug() << "Cannot connect to remote device.";
|
||||
qWarning() << "Controller Error:" << error;
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleServiceDiscovered(const QBluetoothUuid &gatt){
|
||||
|
||||
qDebug() << "Found service with ID: " << gatt;
|
||||
|
||||
if(gatt==QBluetoothUuid(QUuid(UARTSERVICEUUID))){
|
||||
foundValidUARTService =true;
|
||||
qDebug() << "UART service found!";
|
||||
}
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleServiceScanDone(){
|
||||
|
||||
delete bluetoothService;
|
||||
bluetoothService=0;
|
||||
|
||||
if(foundValidUARTService){
|
||||
qDebug() << "Connecting to UART service...";
|
||||
bluetoothService = bluetoothController->createServiceObject(QBluetoothUuid(QUuid(UARTSERVICEUUID)),this);
|
||||
}
|
||||
|
||||
if(!bluetoothService){
|
||||
qDebug() <<"UART service not found";
|
||||
this->disconnectFromDevice();
|
||||
return;
|
||||
}
|
||||
|
||||
/* 3 Step: Service Discovery */
|
||||
connect(this->bluetoothService, &QLowEnergyService::stateChanged, this, &QBluetoothLeUart::handleServiceStateChange);
|
||||
connect(this->bluetoothService, &QLowEnergyService::characteristicChanged, this, &QBluetoothLeUart::handleServiceCharacteristicChange);
|
||||
connect(this->bluetoothService, &QLowEnergyService::descriptorWritten, this, &QBluetoothLeUart::handleServiceDescriptorWritten);
|
||||
|
||||
bluetoothService->discoverDetails();
|
||||
setState(ServiceFound);
|
||||
}
|
||||
|
||||
/* Slots for QLowEnergyService */
|
||||
void QBluetoothLeUart::handleServiceStateChange(QLowEnergyService::ServiceState s)
|
||||
{
|
||||
|
||||
// A descriptoc can only be written if the service is in the ServiceDiscovered state
|
||||
switch (s) {
|
||||
case QLowEnergyService::ServiceDiscovered:
|
||||
{
|
||||
|
||||
//looking for the TX characteristic
|
||||
const QLowEnergyCharacteristic TxChar = bluetoothService->characteristic(QBluetoothUuid(QUuid(TXUUID)));
|
||||
if (!TxChar.isValid()){
|
||||
qDebug() << "Tx characteristic not found";
|
||||
this->disconnectFromDevice();
|
||||
return;
|
||||
}
|
||||
|
||||
//looking for the RX characteristic
|
||||
const QLowEnergyCharacteristic RxChar = bluetoothService->characteristic(QBluetoothUuid(QUuid(RXUUID)));
|
||||
if (!RxChar.isValid()) {
|
||||
qDebug() << "Rx characteristic not found";
|
||||
this->disconnectFromDevice();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Bluetooth LE spec Where a characteristic can be notified, a Client Characteristic Configuration descriptor
|
||||
// shall be included in that characteristic as required by the Bluetooth Core Specification
|
||||
// Tx notify is enabled
|
||||
const QLowEnergyDescriptor m_notificationDescTx = TxChar.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
|
||||
|
||||
if (m_notificationDescTx.isValid()) {
|
||||
// enable notification
|
||||
bluetoothService->writeDescriptor(m_notificationDescTx, QByteArray::fromHex("0100"));
|
||||
setState(AcquireData);
|
||||
emit this->connectedToDevice();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
//nothing for now
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleServiceCharacteristicChange(const QLowEnergyCharacteristic &c,const QByteArray &value)
|
||||
{
|
||||
// ignore any other characteristic change
|
||||
if (c.uuid() != QBluetoothUuid(QUuid(TXUUID)))
|
||||
return;
|
||||
|
||||
emit dataReceived((QString) value);
|
||||
}
|
||||
|
||||
void QBluetoothLeUart::handleServiceDescriptorWritten(const QLowEnergyDescriptor &d,
|
||||
const QByteArray &value)
|
||||
{
|
||||
if (d.isValid() && d == bluetoothTransmissionDescriptor && value == QByteArray("0000")) {
|
||||
//disabled notifications -> assume disconnect intent
|
||||
bluetoothController->disconnectFromDevice();
|
||||
delete bluetoothService;
|
||||
bluetoothService = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QBluetoothLeUart::sendData(QString s){
|
||||
|
||||
const QLowEnergyCharacteristic RxChar = bluetoothService->characteristic(QBluetoothUuid(QUuid(RXUUID)));
|
||||
|
||||
qDebug()<< s;
|
||||
QByteArray Data;
|
||||
Data.append(s);
|
||||
|
||||
bluetoothService->writeCharacteristic(RxChar, Data,QLowEnergyService::WriteWithoutResponse);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QBluetoothLeUart::setState(QBluetoothLeUart::BluetoothLeUartState newState)
|
||||
{
|
||||
if (state == newState)
|
||||
return;
|
||||
|
||||
state = newState;
|
||||
emit stateChanged(newState);
|
||||
}
|
||||
|
||||
QBluetoothLeUart::BluetoothLeUartState QBluetoothLeUart::getState() const {
|
||||
return state;
|
||||
}
|
106
qbluetoothleuart.h
Normal file
106
qbluetoothleuart.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
#ifndef BLUETOOTHLEUART_H
|
||||
#define BLUETOOTHLEUART_H
|
||||
|
||||
#include <QBluetoothDeviceDiscoveryAgent>
|
||||
#include <QBluetoothDeviceInfo>
|
||||
#include <QLowEnergyController>
|
||||
#include <QLowEnergyService>
|
||||
|
||||
#ifdef QBluetoothLeUart_QML
|
||||
#include <QQmlApplicationEngine>
|
||||
#endif
|
||||
|
||||
#include "qbluetoothleuartdevice.h"
|
||||
|
||||
#define UARTSERVICEUUID "6e400001-b5a3-f393-e0a9-e50e24dcca9e"
|
||||
#define RXUUID "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
|
||||
#define TXUUID "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
|
||||
|
||||
class QBluetoothLeUart : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QList<QBluetoothLeUartDevice*> avaliableDevices READ getAvailableDevices NOTIFY avaliableDevicesChanged)
|
||||
Q_PROPERTY(BluetoothLeUartState state READ getState NOTIFY stateChanged)
|
||||
|
||||
public:
|
||||
enum BluetoothLeUartState {
|
||||
Idle = 0,
|
||||
Scanning,
|
||||
ScanFinished,
|
||||
Connecting,
|
||||
Connected,
|
||||
ServiceFound,
|
||||
AcquireData
|
||||
};
|
||||
Q_ENUM(BluetoothLeUartState)
|
||||
|
||||
enum BluetoothScanError {
|
||||
UnknownError,
|
||||
AdapterTurnedOffError,
|
||||
InputOutputError
|
||||
};
|
||||
Q_ENUM(BluetoothScanError);
|
||||
|
||||
QBluetoothLeUart(QObject *parent = nullptr);
|
||||
~QBluetoothLeUart();
|
||||
|
||||
static void init();
|
||||
|
||||
private:
|
||||
QBluetoothLeUartDevice *currentBluetoothDevice;
|
||||
QBluetoothDeviceDiscoveryAgent *bluetoothDeviceDiscoveryAgent;
|
||||
//QList<QObject*> m_qlDevices;
|
||||
QList<QBluetoothLeUartDevice*> availableDevices;
|
||||
//QList<QString> m_qlFoundDevices;
|
||||
QVector<quint16> m_qvMeasurements;
|
||||
QLowEnergyController *bluetoothController;
|
||||
QLowEnergyService *bluetoothService;
|
||||
QLowEnergyDescriptor bluetoothTransmissionDescriptor;
|
||||
bool foundValidUARTService;
|
||||
|
||||
QBluetoothLeUart::BluetoothLeUartState state;
|
||||
|
||||
public slots:
|
||||
|
||||
/* Slots for user */
|
||||
Q_INVOKABLE QBluetoothLeUart::BluetoothLeUartState getState() const;
|
||||
|
||||
Q_INVOKABLE void startScanningForDevices();
|
||||
Q_INVOKABLE void stopScanningForDevices();
|
||||
Q_INVOKABLE QList<QBluetoothLeUartDevice*> getAvailableDevices();
|
||||
Q_INVOKABLE void connectToDevice(QBluetoothLeUartDevice *device);
|
||||
Q_INVOKABLE void sendData(QString s);
|
||||
Q_INVOKABLE void disconnectFromDevice();
|
||||
|
||||
private slots:
|
||||
void setState(QBluetoothLeUart::BluetoothLeUartState newState);
|
||||
|
||||
/* Slots for QBluetothDeviceDiscoveryAgent */
|
||||
void handleDeviceDiscovered(const QBluetoothDeviceInfo&);
|
||||
void handleScanFinished();
|
||||
void handleDeviceScanError(QBluetoothDeviceDiscoveryAgent::Error);
|
||||
|
||||
/* Slots for QLowEnergyController */
|
||||
void handleServiceDiscovered(const QBluetoothUuid &);
|
||||
void handleServiceScanDone();
|
||||
void handleControllerError(QLowEnergyController::Error);
|
||||
void handleDeviceConnected();
|
||||
void handleDeviceDisconnected();
|
||||
|
||||
/* Slotes for QLowEnergyService */
|
||||
void handleServiceStateChange(QLowEnergyService::ServiceState s);
|
||||
void handleServiceCharacteristicChange(const QLowEnergyCharacteristic &c, const QByteArray &value);
|
||||
void handleServiceDescriptorWritten(const QLowEnergyDescriptor &d, const QByteArray &value);
|
||||
|
||||
signals:
|
||||
/* Signals for user */
|
||||
void stateChanged(QBluetoothLeUart::BluetoothLeUartState newState);
|
||||
void avaliableDevicesChanged(QList<QBluetoothLeUartDevice*> avaliableDevices);
|
||||
void foundNewDevice(QBluetoothLeUartDevice* device);
|
||||
void scanningErrorOccured(QBluetoothLeUart::BluetoothScanError error);
|
||||
void dataReceived(QString s);
|
||||
void connectedToDevice();
|
||||
|
||||
};
|
||||
|
||||
#endif // BLUETOOTHLEUART_H
|
34
qbluetoothleuartdevice.cpp
Normal file
34
qbluetoothleuartdevice.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "qbluetoothleuartdevice.h"
|
||||
|
||||
QBluetoothLeUartDevice::QBluetoothLeUartDevice(QBluetoothDeviceInfo info, QObject *parent) : QObject(parent)
|
||||
{
|
||||
this->bluetoothDeviceInfo = info;
|
||||
}
|
||||
|
||||
QString QBluetoothLeUartDevice::getName()
|
||||
{
|
||||
return bluetoothDeviceInfo.name();
|
||||
}
|
||||
|
||||
QBluetoothDeviceInfo QBluetoothLeUartDevice::getDevice()
|
||||
{
|
||||
return bluetoothDeviceInfo;
|
||||
}
|
||||
|
||||
QString QBluetoothLeUartDevice::getAddress()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
// workaround for Core Bluetooth:
|
||||
return m_device->deviceUuid().toString();
|
||||
#else
|
||||
return bluetoothDeviceInfo.address().toString();
|
||||
#endif
|
||||
}
|
||||
|
||||
void QBluetoothLeUartDevice::setDevice(QBluetoothDeviceInfo device)
|
||||
{
|
||||
if(device != this->bluetoothDeviceInfo) {
|
||||
bluetoothDeviceInfo = device;
|
||||
emit deviceChanged();
|
||||
}
|
||||
}
|
35
qbluetoothleuartdevice.h
Normal file
35
qbluetoothleuartdevice.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef DEVICEINFO_H
|
||||
#define DEVICEINFO_H
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <qbluetoothdeviceinfo.h>
|
||||
#include <qbluetoothaddress.h>
|
||||
#include <qbluetoothuuid.h>
|
||||
|
||||
class QBluetoothLeUartDevice: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ getName NOTIFY deviceChanged)
|
||||
Q_PROPERTY(QString address READ getAddress NOTIFY deviceChanged)
|
||||
|
||||
public:
|
||||
QBluetoothLeUartDevice(QBluetoothDeviceInfo device, QObject *parent = nullptr);
|
||||
|
||||
friend class QBluetoothLeUart;
|
||||
|
||||
QString getName();
|
||||
QString getAddress();
|
||||
|
||||
protected:
|
||||
QBluetoothDeviceInfo getDevice();
|
||||
|
||||
private:
|
||||
void setDevice(QBluetoothDeviceInfo device);
|
||||
QBluetoothDeviceInfo bluetoothDeviceInfo;
|
||||
|
||||
signals:
|
||||
void deviceChanged();
|
||||
};
|
||||
|
||||
#endif // DEVICEINFO_H
|
Loading…
Reference in a new issue