Skip to content

Commit

Permalink
init(repo): protocol and basic mqtt bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
tspopp committed Sep 8, 2023
0 parents commit 18c094d
Show file tree
Hide file tree
Showing 25 changed files with 1,318 additions and 0 deletions.
137 changes: 137 additions & 0 deletions AquaMqttLogger/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Configured for clang-format-9
# If You want to test some setting, try https://zed0.co.uk/clang-format-configurator/
# Integration helpers, see here: https://clang.llvm.org/docs/ClangFormat.html

Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -4
AllowAllConstructorInitializersOnNextLine: false
AllowAllArgumentsOnNextLine : false
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AlignConsecutiveMacros: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
AfterCaseLabel: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
BreakInheritanceList: BeforeComma
ColumnLimit: 119
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
- std::for_each
IncludeBlocks: Regroup
IncludeCategories:

- Regex: '^<(gmock|gtest|Poco|rapidjson|eb)\/([A-Z0-9.\/-_])+'
Priority: 4

- Regex: '^<([A-Z0-9\/-_])+>'
Priority: 3

- Regex: '^<.*/.*\.hpp>'
Priority: 5

- Regex: '^<.*.h>'
Priority: 1

- Regex: '^<.*/.*\.h>'
Priority: 2

- Regex: '^".*/.*\.hpp"'
Priority: 6

- Regex: '^"([A-Z0-9.-_])+"'
Priority: 7

IncludeIsMainRegex: '(_test)?$'
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PointerAlignment: Left
RawStringFormats:
- Language: TextProto
BasedOnStyle: google
Delimiters: - pb
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never

PenaltyBreakAssignment: 200
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
3 changes: 3 additions & 0 deletions AquaMqttLogger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pio
CMakeListsPrivate.txt
cmake-build-*/
8 changes: 8 additions & 0 deletions AquaMqttLogger/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions AquaMqttLogger/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions AquaMqttLogger/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions AquaMqttLogger/.idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions AquaMqttLogger/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions AquaMqttLogger/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions AquaMqttLogger/.idea/untitled1.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions AquaMqttLogger/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions AquaMqttLogger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE
# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
#
# If you need to override existing CMake configuration or add extra,
# please create `CMakeListsUser.txt` in the root of project.
# The `CMakeListsUser.txt` will not be overwritten by PlatformIO.

cmake_minimum_required(VERSION 3.13)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)

project("untitled1" C CXX)

include(CMakeListsPrivate.txt)

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsUser.txt)
include(CMakeListsUser.txt)
endif()

add_custom_target(
Production ALL
COMMAND platformio -c clion run "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_custom_target(
Debug ALL
COMMAND platformio -c clion debug "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_executable(Z_DUMMY_TARGET ${SRC_LIST})
31 changes: 31 additions & 0 deletions AquaMqttLogger/include/FrameBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef AQUAMQTT_FRAMEBUFFER_H
#define AQUAMQTT_FRAMEBUFFER_H

#include "../.pio/libdeps/nanoatmega328new/FastCRC/FastCRC.h"
#include "../.pio/libdeps/nanoatmega328new/RingBuffer/src/RingBuf.h"
#include "FrameHandler.h"

#define HEATPUMP_MAX_FRAME_LENGTH 50

class FrameBuffer
{
public:
explicit FrameBuffer(FrameHandler* handler);

~FrameBuffer() = default;

void pushByte(int val);

private:
void handleFrame();

bool isSync();

RingBuf<int, HEATPUMP_MAX_FRAME_LENGTH> mBuffer;

FastCRC16 mCRC;

FrameHandler* mFrameHandler;
};

#endif // AQUAMQTT_FRAMEBUFFER_H
35 changes: 35 additions & 0 deletions AquaMqttLogger/include/FrameHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef AQUAMQTT_FRAMEHANDLER_H
#define AQUAMQTT_FRAMEHANDLER_H

#include <Arduino.h>

#include "../.pio/libdeps/nanoatmega328new/ELClient/ELClient.h"
#include "../.pio/libdeps/nanoatmega328new/ELClient/ELClientCmd.h"
#include "../.pio/libdeps/nanoatmega328new/ELClient/ELClientMqtt.h"

class FrameHandler
{
public:
FrameHandler();

~FrameHandler() = default;

bool setup();

void loop();

void handleFrame(uint8_t frameId, uint8_t payloadLength, uint8_t* payload);

private:
void parse193(uint8_t payloadLength, const uint8_t* payload);
void parse194(uint8_t payloadLength, const uint8_t* payload);
void parse67(uint8_t payloadLength, const uint8_t* payload);

void logDebug(uint8_t frameId, uint8_t payloadLength, uint8_t* payload);

ELClient mElClient;
ELClientCmd mELClientCmd;
ELClientMqtt mELClientMqtt;
};

#endif // AQUAMQTT_FRAMEHANDLER_H
26 changes: 26 additions & 0 deletions AquaMqttLogger/include/MQTTDefinitions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef AQUAMQTT_MQTTDEFINITIONS_H
#define AQUAMQTT_MQTTDEFINITIONS_H

const char DEBUG_TOPIC[] PROGMEM = { "tortuga/aquawin/dbg/" };
const char BASE_TOPIC[] PROGMEM = { "tortuga/aquawin/" };

const char HOT_WATER_TEMP[] PROGMEM = { "waterTemp" };
const char SUPPLY_AIR_TEMP[] PROGMEM = { "supplyAirTemp" };
const char EVAPORATOR_AIR_TEMP_UPPER[] PROGMEM = { "evaporatorAirTemp" };
const char EVAPORATOR_AIR_TEMP_LOWER[] PROGMEM = { "evaporatorAirTempLower" };
const char HOT_WATER_TEMP_TARGET[] PROGMEM = { "waterTempTarget" };
const char TOTAL_HEATING_ELEM_HOURS[] PROGMEM = { "totalHeatingElemHours" };
const char TOTAL_HEATPUMP_HOURS[] PROGMEM = { "totalHeatpumpHours" };
const char TOTAL_HOURS[] PROGMEM = { "totalHours" };
const char TOTAL_ENERGY_WH[] PROGMEM = { "totalEnergyWh" };
const char OPERATION_MODE[] PROGMEM = { "operationMode" };
const char TIME[] PROGMEM = { "time" };
const char DATE[] PROGMEM = { "date" };
const char POWER_TOTAL[] PROGMEM = { "powerTotal" };
const char POWER_HEAT_ELEMENT[] PROGMEM = { "powerHeatingElem" };
const char POWER_HEATPUMP[] PROGMEM = { "powerHeatpump" };
const char FAN_SPEED[] PROGMEM = { "fanSpeed" };
const char UNKNOWN_67A[] PROGMEM = { "67a" };
const char BITMASK_193[] PROGMEM = { "193bitmask" };

#endif // AQUAMQTT_MQTTDEFINITIONS_H
39 changes: 39 additions & 0 deletions AquaMqttLogger/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
Loading

0 comments on commit 18c094d

Please sign in to comment.