diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | client/Client.cpp | 3 | ||||
-rw-r--r-- | client/Client.h | 8 | ||||
-rw-r--r-- | client/client.pro.user | 262 | ||||
-rw-r--r-- | client/consts.h | 11 | ||||
-rw-r--r-- | client/dbconnector.cpp | 2 | ||||
-rw-r--r-- | client/ui_dbconnector.h | 163 | ||||
-rw-r--r-- | client/ui_mainwindow.h | 110 | ||||
-rw-r--r-- | readme.md | 6 | ||||
-rw-r--r-- | shared/wifi.def.h (renamed from stm32f091/wifi.def.h) | 1 | ||||
-rw-r--r-- | stm32f091/consts.h | 5 | ||||
-rw-r--r-- | stm32f091/esp8266.c | 2 | ||||
-rw-r--r-- | stm32f091/readme.md | 3 | ||||
-rw-r--r-- | stm32f091/server.c | 3 | ||||
-rw-r--r-- | stm32f091/util.h | 4 | ||||
-rw-r--r-- | todo.md (renamed from stm32f091/todo.md) | 10 |
16 files changed, 31 insertions, 566 deletions
@@ -6,14 +6,16 @@ # stm32-specific files stm32f091/main.elf stm32f091/main.bin -stm32f091/wifi.h # client-specific files client/makefile client/client client/moc_* +client/ui_* +**/.user # others +shared/wifi.h shared/main .qmake.stash .vscode/.cortex-debug.registers.state.json diff --git a/client/Client.cpp b/client/Client.cpp index 01c3867..10d288e 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -44,8 +44,7 @@ void Client::timeFunction() QTime time = QTime::currentTime(); qint16 currentSeconds = time.second(); - auto _intervals = intervals; - if(currentSeconds % _intervals==0){ + if((currentSeconds % WS_CLIENT_STATION_POLL_INTERVAL) == 1){ socket->connectToHost(networkAddress, tcpPortAddress); socket->write(msgToSend); diff --git a/client/Client.h b/client/Client.h index 38419a8..f675a89 100644 --- a/client/Client.h +++ b/client/Client.h @@ -8,6 +8,7 @@ #include <QSqlQuery> #include "HandleMessage.h" +#include "../shared/wifi.h" // class client for wheather station class Client : public QObject @@ -31,15 +32,12 @@ private: // qint16 currentMinute; // timing for currentMinute HandleMessage Handlemsg; // add HandleMessage to Client.h - int tcpPortAddress = 80; // port of communication via tcp - QString networkAddress = "192.168.137.76"; // network address for commincation via tcp + int tcpPortAddress = WS_SERVER_PORT; // port of communication via tcp + QString networkAddress = WS_ESP8266_WLAN_IP; // network address for commincation via tcp QString msg = "last-records "; // part of mesage to send to wheather staion char totalRecords = '1'; // total records to ask wheather station char offsetRecords = '0'; // offset from reqeusting records - - - }; #endif // CLIENT_H diff --git a/client/client.pro.user b/client/client.pro.user deleted file mode 100644 index 78fe5c2..0000000 --- a/client/client.pro.user +++ /dev/null @@ -1,262 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 8.0.1, 2022-10-30T09:30:24. --> -<qtcreator> - <data> - <variable>EnvironmentId</variable> - <value type="QByteArray">{aa240e53-c124-4cf0-84a8-30bfe8a2cf83}</value> - </data> - <data> - <variable>ProjectExplorer.Project.ActiveTarget</variable> - <value type="qlonglong">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="qlonglong" 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.PreferSingleLineComments">false</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="bool" key="EditorConfiguration.UseIndenter">false</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.CTest">false</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> - <valuemap type="QVariantMap" key="ClangTools"> - <value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value> - <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 6.4.0 MinGW 64-bit</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.4.0 MinGW 64-bit</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.640.win64_mingw_kit</value> - <value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> - <value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> - <value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> - <value type="int" key="EnableQmlDebugging">0</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Debug</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-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="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> - </valuemap> - <value type="qlonglong" 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> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> - </valuemap> - <value type="qlonglong" 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"/> - <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> - <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> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Release</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-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="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> - </valuemap> - <value type="qlonglong" 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> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> - </valuemap> - <value type="qlonglong" 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"/> - <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> - <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> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> - <value type="int" key="EnableQmlDebugging">0</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Profile</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-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="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> - </valuemap> - <value type="qlonglong" 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> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> - </valuemap> - <value type="qlonglong" 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"/> - <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> - <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="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> - <value type="qlonglong" 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="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> - <value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value> - <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value> - <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> - <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.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Github2/avans-whether-station/client/client.pro</value> - <value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">D:/Github2/avans-whether-station/client/client.pro</value> - <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> - <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> - <value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value> - <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> - <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> - <value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Debug</value> - </valuemap> - <value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value> - </valuemap> - </data> - <data> - <variable>ProjectExplorer.Project.TargetCount</variable> - <value type="qlonglong">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> diff --git a/client/consts.h b/client/consts.h index 1bc6040..7ee81c8 100644 --- a/client/consts.h +++ b/client/consts.h @@ -1,10 +1,5 @@ -#ifndef CONSTS_H -#define CONSTS_H +#pragma once +// delay between new record request in seconds +#define WS_CLIENT_STATION_POLL_INTERVAL 10 - - -#define intervals 10; - - -#endif // CONSTS_H diff --git a/client/dbconnector.cpp b/client/dbconnector.cpp index 8643014..186f8f7 100644 --- a/client/dbconnector.cpp +++ b/client/dbconnector.cpp @@ -3,7 +3,7 @@ #include "main.h" #include "mainwindow.h" -# + dbConnector::dbConnector(QWidget *parent) : QDialog(parent), ui(new Ui::dbConnector) diff --git a/client/ui_dbconnector.h b/client/ui_dbconnector.h deleted file mode 100644 index dec4d7b..0000000 --- a/client/ui_dbconnector.h +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'dbconnector.ui' -** -** Created by: Qt User Interface Compiler version 5.15.6 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_DBCONNECTOR_H -#define UI_DBCONNECTOR_H - -#include <QtCore/QVariant> -#include <QtWidgets/QApplication> -#include <QtWidgets/QDialog> -#include <QtWidgets/QFormLayout> -#include <QtWidgets/QFrame> -#include <QtWidgets/QHBoxLayout> -#include <QtWidgets/QLabel> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QPushButton> -#include <QtWidgets/QWidget> - -QT_BEGIN_NAMESPACE - -class Ui_dbConnector -{ -public: - QWidget *formLayoutWidget; - QFormLayout *formLayout; - QLabel *label_3; - QLineEdit *lineEdit_adress; - QLabel *label_4; - QLineEdit *lineEdit_database; - QFrame *line; - QLabel *label; - QLineEdit *lineEdit_username; - QLabel *label_2; - QLineEdit *lineEdit_password; - QLabel *connectLabel; - QHBoxLayout *horizontalLayout; - QPushButton *pushButton_login; - QPushButton *pushButton_cancel; - - void setupUi(QDialog *dbConnector) - { - if (dbConnector->objectName().isEmpty()) - dbConnector->setObjectName(QString::fromUtf8("dbConnector")); - dbConnector->resize(362, 273); - formLayoutWidget = new QWidget(dbConnector); - formLayoutWidget->setObjectName(QString::fromUtf8("formLayoutWidget")); - formLayoutWidget->setGeometry(QRect(60, 60, 241, 173)); - formLayout = new QFormLayout(formLayoutWidget); - formLayout->setObjectName(QString::fromUtf8("formLayout")); - formLayout->setContentsMargins(0, 0, 0, 0); - label_3 = new QLabel(formLayoutWidget); - label_3->setObjectName(QString::fromUtf8("label_3")); - - formLayout->setWidget(0, QFormLayout::LabelRole, label_3); - - lineEdit_adress = new QLineEdit(formLayoutWidget); - lineEdit_adress->setObjectName(QString::fromUtf8("lineEdit_adress")); - - formLayout->setWidget(0, QFormLayout::FieldRole, lineEdit_adress); - - label_4 = new QLabel(formLayoutWidget); - label_4->setObjectName(QString::fromUtf8("label_4")); - - formLayout->setWidget(1, QFormLayout::LabelRole, label_4); - - lineEdit_database = new QLineEdit(formLayoutWidget); - lineEdit_database->setObjectName(QString::fromUtf8("lineEdit_database")); - - formLayout->setWidget(1, QFormLayout::FieldRole, lineEdit_database); - - line = new QFrame(formLayoutWidget); - line->setObjectName(QString::fromUtf8("line")); - line->setFrameShape(QFrame::HLine); - line->setFrameShadow(QFrame::Sunken); - - formLayout->setWidget(2, QFormLayout::SpanningRole, line); - - label = new QLabel(formLayoutWidget); - label->setObjectName(QString::fromUtf8("label")); - - formLayout->setWidget(3, QFormLayout::LabelRole, label); - - lineEdit_username = new QLineEdit(formLayoutWidget); - lineEdit_username->setObjectName(QString::fromUtf8("lineEdit_username")); - lineEdit_username->setEchoMode(QLineEdit::PasswordEchoOnEdit); - - formLayout->setWidget(3, QFormLayout::FieldRole, lineEdit_username); - - label_2 = new QLabel(formLayoutWidget); - label_2->setObjectName(QString::fromUtf8("label_2")); - - formLayout->setWidget(4, QFormLayout::LabelRole, label_2); - - lineEdit_password = new QLineEdit(formLayoutWidget); - lineEdit_password->setObjectName(QString::fromUtf8("lineEdit_password")); - QFont font; - font.setUnderline(false); - font.setStrikeOut(false); - font.setKerning(true); - lineEdit_password->setFont(font); - lineEdit_password->setEchoMode(QLineEdit::Password); - - formLayout->setWidget(4, QFormLayout::FieldRole, lineEdit_password); - - connectLabel = new QLabel(formLayoutWidget); - connectLabel->setObjectName(QString::fromUtf8("connectLabel")); - - formLayout->setWidget(5, QFormLayout::LabelRole, connectLabel); - - horizontalLayout = new QHBoxLayout(); - horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); - pushButton_login = new QPushButton(formLayoutWidget); - pushButton_login->setObjectName(QString::fromUtf8("pushButton_login")); - - horizontalLayout->addWidget(pushButton_login); - - pushButton_cancel = new QPushButton(formLayoutWidget); - pushButton_cancel->setObjectName(QString::fromUtf8("pushButton_cancel")); - - horizontalLayout->addWidget(pushButton_cancel); - - - formLayout->setLayout(5, QFormLayout::FieldRole, horizontalLayout); - - - retranslateUi(dbConnector); - - QMetaObject::connectSlotsByName(dbConnector); - } // setupUi - - void retranslateUi(QDialog *dbConnector) - { - dbConnector->setWindowTitle(QCoreApplication::translate("dbConnector", "Dialog", nullptr)); - label_3->setText(QCoreApplication::translate("dbConnector", "Adress", nullptr)); - lineEdit_adress->setText(QCoreApplication::translate("dbConnector", "localhost", nullptr)); - lineEdit_adress->setPlaceholderText(QCoreApplication::translate("dbConnector", "Hostname/IP-Adress", nullptr)); - label_4->setText(QCoreApplication::translate("dbConnector", "Database", nullptr)); - lineEdit_database->setText(QCoreApplication::translate("dbConnector", "WSdb", nullptr)); - lineEdit_database->setPlaceholderText(QCoreApplication::translate("dbConnector", "Database name", nullptr)); - label->setText(QCoreApplication::translate("dbConnector", "Username", nullptr)); - lineEdit_username->setText(QCoreApplication::translate("dbConnector", "root", nullptr)); - lineEdit_username->setPlaceholderText(QCoreApplication::translate("dbConnector", "Username", nullptr)); - label_2->setText(QCoreApplication::translate("dbConnector", "Password", nullptr)); - lineEdit_password->setText(QCoreApplication::translate("dbConnector", "Ab12345!", nullptr)); - lineEdit_password->setPlaceholderText(QCoreApplication::translate("dbConnector", "Password", nullptr)); - connectLabel->setText(QCoreApplication::translate("dbConnector", "Connect", nullptr)); - pushButton_login->setText(QCoreApplication::translate("dbConnector", "Login", nullptr)); - pushButton_cancel->setText(QCoreApplication::translate("dbConnector", "Cancel", nullptr)); - } // retranslateUi - -}; - -namespace Ui { - class dbConnector: public Ui_dbConnector {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_DBCONNECTOR_H diff --git a/client/ui_mainwindow.h b/client/ui_mainwindow.h deleted file mode 100644 index 69c476b..0000000 --- a/client/ui_mainwindow.h +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'mainwindow.ui' -** -** Created by: Qt User Interface Compiler version 5.15.6 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_MAINWINDOW_H -#define UI_MAINWINDOW_H - -#include <QtCore/QVariant> -// #include <QtWidgets/QAction> -#include <QtWidgets/QApplication> -#include <QtWidgets/QLabel> -#include <QtWidgets/QMainWindow> -#include <QtWidgets/QMenu> -#include <QtWidgets/QMenuBar> -#include <QtWidgets/QStatusBar> -#include <QtWidgets/QWidget> - -QT_BEGIN_NAMESPACE - -class Ui_MainWindow -{ -public: - QAction *actionRefresh; - QAction *actionLOAD; - QAction *actionQuerry; - QAction *actionConnection; - QAction *actionDisconnenct; - QWidget *centralwidget; - QLabel *label; - QMenuBar *menubar; - QMenu *menuAbouy; - QMenu *menuDatabase; - QStatusBar *statusbar; - - void setupUi(QMainWindow *MainWindow) - { - if (MainWindow->objectName().isEmpty()) - MainWindow->setObjectName(QString::fromUtf8("MainWindow")); - MainWindow->resize(800, 600); - actionRefresh = new QAction(MainWindow); - actionRefresh->setObjectName(QString::fromUtf8("actionRefresh")); - actionLOAD = new QAction(MainWindow); - actionLOAD->setObjectName(QString::fromUtf8("actionLOAD")); - actionQuerry = new QAction(MainWindow); - actionQuerry->setObjectName(QString::fromUtf8("actionQuerry")); - actionConnection = new QAction(MainWindow); - actionConnection->setObjectName(QString::fromUtf8("actionConnection")); - actionDisconnenct = new QAction(MainWindow); - actionDisconnenct->setObjectName(QString::fromUtf8("actionDisconnenct")); - centralwidget = new QWidget(MainWindow); - centralwidget->setObjectName(QString::fromUtf8("centralwidget")); - label = new QLabel(centralwidget); - label->setObjectName(QString::fromUtf8("label")); - label->setGeometry(QRect(270, 190, 181, 51)); - MainWindow->setCentralWidget(centralwidget); - menubar = new QMenuBar(MainWindow); - menubar->setObjectName(QString::fromUtf8("menubar")); - menubar->setGeometry(QRect(0, 0, 800, 24)); - menuAbouy = new QMenu(menubar); - menuAbouy->setObjectName(QString::fromUtf8("menuAbouy")); - menuDatabase = new QMenu(menubar); - menuDatabase->setObjectName(QString::fromUtf8("menuDatabase")); - MainWindow->setMenuBar(menubar); - statusbar = new QStatusBar(MainWindow); - statusbar->setObjectName(QString::fromUtf8("statusbar")); - MainWindow->setStatusBar(statusbar); - - menubar->addAction(menuAbouy->menuAction()); - menubar->addAction(menuDatabase->menuAction()); - menuAbouy->addAction(actionRefresh); - menuDatabase->addAction(actionConnection); - menuDatabase->addAction(actionDisconnenct); - - retranslateUi(MainWindow); - - QMetaObject::connectSlotsByName(MainWindow); - } // setupUi - - void retranslateUi(QMainWindow *MainWindow) - { - MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr)); - actionRefresh->setText(QCoreApplication::translate("MainWindow", "Refresh", nullptr)); -#if QT_CONFIG(shortcut) - actionRefresh->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+R", nullptr)); -#endif // QT_CONFIG(shortcut) - actionLOAD->setText(QCoreApplication::translate("MainWindow", "Load", nullptr)); - actionQuerry->setText(QCoreApplication::translate("MainWindow", "Query", nullptr)); - actionConnection->setText(QCoreApplication::translate("MainWindow", "Connect", nullptr)); -#if QT_CONFIG(shortcut) - actionConnection->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+O", nullptr)); -#endif // QT_CONFIG(shortcut) - actionDisconnenct->setText(QCoreApplication::translate("MainWindow", "Disconnenct", nullptr)); - label->setText(QCoreApplication::translate("MainWindow", "Please load data first", nullptr)); - menuAbouy->setTitle(QCoreApplication::translate("MainWindow", "Home", nullptr)); - menuDatabase->setTitle(QCoreApplication::translate("MainWindow", "Database", nullptr)); - } // retranslateUi - -}; - -namespace Ui { - class MainWindow: public Ui_MainWindow {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_MAINWINDOW_H @@ -6,8 +6,10 @@ `client/client.pro` should be tracked under version control, not `client/makefile` - the stm32 makefile uses git submodules to pull necessary files for - compilation. make sure to initialize and sync the git submodules, or re-clone - using the `--recursive` flag. + compilation. make sure to initialize and sync the git submodules, or use the + `--recursive` flag when cloning +- the stm32 firmware expects the esp8266 module to have the official espressif + firmware, not the ai-thinker firmware that the module comes pre-flashed with ## support diff --git a/stm32f091/wifi.def.h b/shared/wifi.def.h index 61e1706..aead0b6 100644 --- a/stm32f091/wifi.def.h +++ b/shared/wifi.def.h @@ -4,4 +4,5 @@ #define WS_ESP8266_WLAN_PASSWD "12345678" // #define WS_ESP8266_WLAN_MAC "f2:9b:89:47:c4:f3" // #define WS_ESP8266_WLAN_IP "192.168.2.69" +#define WS_SERVER_PORT 80 diff --git a/stm32f091/consts.h b/stm32f091/consts.h index 3d2ef5a..6d5b8d2 100644 --- a/stm32f091/consts.h +++ b/stm32f091/consts.h @@ -1,9 +1,10 @@ #pragma once -#include "wifi.h" +#include "../shared/wifi.h" +#include "util.h" -#define WS_SERVER_PORT "80" #define WS_SERVER_MAX_CHANNELS 4 +#define WS_SERVER_PORT_STR WS_MTS(WS_SERVER_PORT) #define WS_DMA_RX_BUFFER_SIZE 100 #define WS_DMA_TX_BUFFER_SIZE 1024 diff --git a/stm32f091/esp8266.c b/stm32f091/esp8266.c index 74ec347..8ff9547 100644 --- a/stm32f091/esp8266.c +++ b/stm32f091/esp8266.c @@ -77,7 +77,7 @@ void ws_esp8266_ap_client_mode() { void ws_esp8266_start_tcp_server() { ws_esp8266_send_seq("AT+CIPSERVER=0\r\n"); // stop tcp server (if running) ws_esp8266_send_seq("AT+CIPMUX=1\r\n"); // enable multiplexing (allow multiple connections) - ws_esp8266_send_seq("AT+CIPSERVER=1," WS_SERVER_PORT "\r\n"); // start tcp server + ws_esp8266_send_seq("AT+CIPSERVER=1," WS_SERVER_PORT_STR "\r\n"); // start tcp server } void ws_esp8266_set_mac() { diff --git a/stm32f091/readme.md b/stm32f091/readme.md index d2758b5..e6af60f 100644 --- a/stm32f091/readme.md +++ b/stm32f091/readme.md @@ -3,7 +3,8 @@ - uses make - make sure to initialize the git submodules - all warnings from source files in the lib/ subfolder are hidden -- copy wifi.def.h to wifi.h and edit the network credentials +- copy ../shared/wifi.def.h to ../shared/wifi.h and edit the network + credentials - the initialization code is broken in some way which means that a soft reset is required for the uart dma to work, either (a) press the reset button on the development board after plugging in, or (b) run `st-flash reset` after diff --git a/stm32f091/server.c b/stm32f091/server.c index 112d23a..d69ef1e 100644 --- a/stm32f091/server.c +++ b/stm32f091/server.c @@ -55,9 +55,6 @@ static bool ws_server_is_response(char data, uint8_t* counter, const char* cmd, return false; } -// TODO: next_few_bytes_are assumes that the complete search string is in the -// buffer, so won't work for buffer cutoffs -#define next_few_bytes_are(code) (((i + sizeof(code) - 2) < size) && (strncmp((char*)&data[i], code, sizeof(code) - 1) == 0)) void ws_server_req_incoming(uint8_t* data, size_t size) { #ifdef WS_DBG_PRINT_ESP_OVER_USART2 ws_dbg_set_usart2_tty_color(WS_DBG_TTY_COLOR_RX); diff --git a/stm32f091/util.h b/stm32f091/util.h index 11bee6f..9c15f8b 100644 --- a/stm32f091/util.h +++ b/stm32f091/util.h @@ -8,6 +8,10 @@ #include "setup.h" #include "../shared/util.h" +// macro to string macro's +#define WS_MTS_EXPAND(x) #x +#define WS_MTS(x) WS_MTS_EXPAND(x) + #define WS_DBG_TTY_COLOR_BLK 0x0 #define WS_DBG_TTY_COLOR_RED 0x1 #define WS_DBG_TTY_COLOR_GRN 0x2 diff --git a/stm32f091/todo.md b/todo.md index 1d42bf8..5924b20 100644 --- a/stm32f091/todo.md +++ b/todo.md @@ -3,7 +3,7 @@ - [ ] more documentation in header files (for both client and stm code) - [ ] design/architecture document - [x] more tests in the test document -- [ ] handle errors from `AT+CIPSEND`, these look like this: +- [x] handle errors from `AT+CIPSEND`, these look like this: ``` > AT0,CONNECT @@ -19,10 +19,10 @@ - [ ] `sensor.c:24: return (uint8_t) temp_c; //TODO: convert with range -> util.h` - [ ] `sensor.c:36: return (uint8_t) humidity; //TODO: convert with range -> util.h` - [ ] `sensor.c:51: return (uint8_t) val; // TODO: convert with range` -- [ ] `server.c:47:// TODO: next_few_bytes_are assumes that the complete search string is in the` +- [x] `server.c:47:// TODO: next_few_bytes_are assumes that the complete search string is in the` - [ ] `server.c:146: // TODO: buffer overrun protection` -- [ ] `server.c:152:// TODO: refactor this` -- [ ] `server.c:165:// TODO: refactor this` -- [ ] `server.c:174:// TODO: refactor this` +- [x] `server.c:152:// TODO: refactor this` +- [x] `server.c:165:// TODO: refactor this` +- [x] `server.c:174:// TODO: refactor this` - [ ] `setup.c:95: // TODO: remove debug size` - [ ] `setup.c:187: .Pin = GPIO_PIN_8|GPIO_PIN_9, //TODO: use #defines in setup.h` |