Skip to content

Commit

Permalink
refactor(protocols): support multiple protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
tspopp committed Nov 20, 2024
1 parent d0d951e commit bd79ebf
Show file tree
Hide file tree
Showing 32 changed files with 2,788 additions and 3,056 deletions.
1 change: 0 additions & 1 deletion AquaMQTT/include/buffer/FrameBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class FrameBuffer
uint64_t getHandledCount() const;

private:

aquamqtt::message::ProtocolVersion mLockedProtocol;

int handleFrame();
Expand Down
15 changes: 15 additions & 0 deletions AquaMQTT/include/config/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ namespace aquamqtt
{
namespace config
{

// TODO: remove prior to merge
// switches solely for debugging the crash from taloriko (protocol-next) and will be removed as soon as we determined the reason for the crash
// if this switch is enabled, no mqtt is there at all, if this already crashes, there is something wrong with the protocol parser
// if this is not crashing, reset this back to false
constexpr bool DEBUG_DISABLE_ENTIRE_MQTT = false;

// proceed with these, disable them all (set them all to true) and start with setting a single one to false, and see if it crashes
// if not reset them all back to true, and set the another one to false, until you find the one which is responsible for the crash (we will analyze further)
constexpr bool DEBUG_DISABLE_MQTT_STATS_MSG = false;
constexpr bool DEBUG_DISABLE_MQTT_HMI_MSG = false;
constexpr bool DEBUG_DISABLE_MQTT_MAIN_MSG = false;
constexpr bool DEBUG_DISABLE_MQTT_ENERGY_MSG = false;
constexpr bool DEBUG_DISABLE_MQTT_ERROR_MSG = false;

/**
* Defines the network name of your esp32 device in your network
*/
Expand Down
65 changes: 30 additions & 35 deletions AquaMQTT/include/message/IEnergyMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,28 @@

#include "MessageConstants.h"

namespace aquamqtt
namespace aquamqtt::message
{
namespace message

enum class ENERGY_ATTR_U16
{
POWER_HEATPUMP,
POWER_HEATELEMENT,
POWER_TOTAL,
WATER_TOTAL
};

enum class ENERGY_ATTR_U32
{
TOTAL_HEATPUMP_HOURS,
TOTAL_HEATING_ELEMENT_HOURS,
TOTAL_HOURS,
};

enum class ENERGY_ATTR_U64
{
TOTAL_ENERGY,
};

class IEnergyMessage
{
Expand All @@ -15,41 +33,18 @@ class IEnergyMessage

virtual uint8_t getLength() = 0;

virtual uint32_t totalHeatpumpHours() = 0;

virtual uint32_t totalHeatingElemHours() = 0;

virtual uint32_t totalHours() = 0;

virtual uint64_t totalEnergyCounter() = 0;

virtual uint16_t powerHeatpump() = 0;

virtual uint16_t powerHeatElement() = 0;

virtual uint16_t powerOverall() = 0;

virtual uint16_t totalWaterProduction() = 0;

virtual void compareWith(uint8_t* data) = 0;

virtual bool totalHeatpumpHoursChanged() const = 0;

virtual bool totalHeatingElemHoursChanged() const = 0;

virtual bool totalHoursChanged() const = 0;

virtual bool totalEnergyCounterChanged() const = 0;

virtual bool powerHeatpumpChanged() const = 0;

virtual bool powerHeatElementChanged() const = 0;
virtual uint64_t getAttr(ENERGY_ATTR_U64 attr) = 0;
virtual uint32_t getAttr(ENERGY_ATTR_U32 attr) = 0;
virtual uint16_t getAttr(ENERGY_ATTR_U16 attr) = 0;

virtual bool powerOverallChanged() const = 0;
virtual bool hasAttr(ENERGY_ATTR_U64 attr) const = 0;
virtual bool hasAttr(ENERGY_ATTR_U32 attr) const = 0;
virtual bool hasAttr(ENERGY_ATTR_U16 attr) const = 0;

virtual bool totalWaterProductionChanged() const = 0;
virtual bool hasChanged(ENERGY_ATTR_U64 attr) const = 0;
virtual bool hasChanged(ENERGY_ATTR_U32 attr) const = 0;
virtual bool hasChanged(ENERGY_ATTR_U16 attr) const = 0;
};
} // namespace message
} // namespace aquamqtt
} // namespace aquamqtt::message

#endif // AQUAMQTT_IENERGYMESSAGE_H
69 changes: 36 additions & 33 deletions AquaMQTT/include/message/IErrorMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,53 @@

#include "MessageConstants.h"

namespace aquamqtt
namespace aquamqtt::message
{
namespace message

enum class ERROR_ATTR_U8
{
ERROR_REQUEST_ID,
ERROR_ERROR_CODE,
ERROR_TIME_MINUTES,
ERROR_TIME_HOURS,
ERROR_DATE_DAY,
ERROR_DATE_MONTH,
ERROR_DATE_YEAR
};

enum class ERROR_ATTR_FLOAT
{
ERROR_WATER_TEMPERATURE,
ERROR_AIR_TEMPERATURE,
ERROR_EVAPORATOR_UPPER_TEMPERATURE,
ERROR_EVAPORATOR_LOWER_TEMPERATURE,
ERROR_COMPRESSOR_OUTLET_TEMPERATURE,
ERROR_FAN_SPEED_PWM,
};

enum class ERROR_ATTR_U16
{
ERROR_TOTAL_HEATPUMP_HOURS,
ERROR_TOTAL_HEATING_ELEMENT_HOURS,
};

class IErrorMessage
{
public:
virtual ~IErrorMessage() = default;
virtual ~IErrorMessage() = default;

virtual uint8_t getLength() = 0;

virtual uint8_t errorRequestId() = 0;

virtual uint8_t errorCode() = 0;

virtual float hotWaterTemp() = 0;

virtual float airTemp() = 0;

virtual float evaporatorLowerAirTemp() = 0;

virtual float evaporatorUpperAirTemp() = 0;

virtual float fanSpeedPwm() = 0;

virtual uint16_t totalHeatpumpHours() = 0;

virtual uint16_t totalHeatingElemHours() = 0;

virtual uint8_t timeHours() = 0;

virtual uint8_t timeMinutes() = 0;

virtual uint16_t dateYear() = 0;

virtual uint8_t dateMonth() = 0;

virtual uint8_t dateDay() = 0;
virtual bool isEmpty() = 0;

virtual bool isEmpty() = 0;
virtual uint8_t getAttr(ERROR_ATTR_U8 attr) = 0;
virtual uint16_t getAttr(ERROR_ATTR_U16 attr) = 0;
virtual float getAttr(ERROR_ATTR_FLOAT attr) = 0;

virtual bool hasAttr(ERROR_ATTR_U8 attr) const = 0;
virtual bool hasAttr(ERROR_ATTR_U16 attr) const = 0;
virtual bool hasAttr(ERROR_ATTR_FLOAT attr) const = 0;
};
} // namespace message
} // namespace aquamqtt
} // namespace aquamqtt::message

#endif // AQUAMQTT_IERRORMESSAGE_H
178 changes: 69 additions & 109 deletions AquaMQTT/include/message/IHMIMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,127 +3,87 @@

#include "MessageConstants.h"

namespace aquamqtt
{
namespace message
namespace aquamqtt::message
{

class IHMIMessage
enum class HMI_ATTR_U16
{
public:
virtual ~IHMIMessage() = default;

virtual uint8_t getLength() = 0;

virtual float waterTempTarget() = 0;

virtual void setWaterTempTarget(float targetTemperature) = 0;

virtual HMIOperationMode operationMode() const = 0;

virtual void setOperationMode(HMIOperationMode operationMode) const = 0;

virtual HMIOperationType getOperationType() const = 0;

virtual void setOperationType(HMIOperationType operationType) const = 0;

virtual bool isEmergencyModeEnabled() const = 0;

virtual void setEmergencyMode(bool enabled) const = 0;

virtual bool isHeatingElementEnabled() const = 0;

virtual void enableHeatingElement(bool enabled) const = 0;

virtual bool isPVInputActivated() const = 0;

virtual HMISetup setupMode() const = 0;

virtual uint8_t antiLegionellaModePerMonth() const = 0;

virtual void setAntiLegionellaModePerMonth(uint8_t value) = 0;

virtual HMIAirDuctConfig airDuctConfig() const = 0;

virtual void setAirDuctConfig(HMIAirDuctConfig config) const = 0;

virtual HMIInstallation installationMode() = 0;

virtual HMIFanExhaust fanExhaust() const = 0;

virtual void setFanExhaustMode(HMIFanExhaust mode) const = 0;

virtual bool exhaustFanChanged() const = 0;

virtual HMITestMode testMode() = 0;

virtual void timerWindowStr(bool firstWindow, char* buffer) = 0;

virtual void setTimeWindowByStr(bool firstWindow, char* buffer, uint8_t length) = 0;

virtual uint16_t timerWindowAStart() const = 0;

virtual uint16_t timerWindowALength() const = 0;

virtual uint16_t timerWindowBStart() const = 0;

virtual uint16_t timerWindowBLength() const = 0;

virtual uint8_t timeHours() const = 0;
TIMER_A_START,
TIMER_A_LENGTH,
TIMER_B_START,
TIMER_B_LENGTH,
DATE_YEAR,
};

virtual void setTimeHours(uint8_t hour) const = 0;
enum class HMI_ATTR_U8
{
ANTI_LEGIONELLA_CYCLES,
TIME_SECONDS,
TIME_MINUTES,
TIME_HOURS,
DATE_DAY,
DATE_MONTH,
STATE_SETUP,
STATE_TEST,
STATE_INSTALLATION_MODE,
CONFIG_AIRDUCT,
CONFIG_FAN_EXHAUST,
HMI_ERROR_ID_REQUESTED,
HMI_ERROR_NO_REQUESTED,
OPERATION_MODE,
OPERATION_TYPE,
};

virtual uint8_t timeMinutes() const = 0;
enum class HMI_ATTR_FLOAT
{
WATER_TARGET_TEMPERATURE,
};

virtual void setTimeMinutes(uint8_t minute) const = 0;
enum class HMI_ATTR_BOOL
{
EMERGENCY_MODE_ENABLED,
HEATING_ELEMENT_ALLOWED,
PV_INPUT_ALLOWED,
};

virtual uint8_t timeSeconds() const = 0;
enum class HMI_ATTR_STR
{
TIMER_WINDOW_A,
TIMER_WINDOW_B
};

virtual void setTimeSeconds(uint8_t second) const = 0;
class IHMIMessage
{
public:
virtual ~IHMIMessage() = default;

virtual uint16_t dateYear() const = 0;
virtual uint8_t getLength() = 0;

virtual void setDateMonthAndYear(uint8_t month, uint16_t year) const = 0;

virtual uint8_t dateMonth() const = 0;

virtual uint8_t dateDay() const = 0;

virtual void setDateDay(uint8_t day) const = 0;

virtual void setInstallationMode(HMIInstallation mode) const = 0;

virtual bool waterTempTargetChanged() const = 0;

virtual bool operationTypeOrModeChanged() const = 0;

virtual bool timeChanged() const = 0;

virtual bool dateChanged() const = 0;

virtual bool emergencyModeChanged() const = 0;

virtual bool heatingElemOrSetupStateOrPVActiveChanged() const = 0;

virtual bool legionellaOrAirductChanged() const = 0;

virtual bool testModeChanged() const = 0;

virtual bool installationConfigChanged() const = 0;

virtual bool timerModeOneChanged() const = 0;

virtual bool timerModeTwoChanged() const = 0;

virtual void compareWith(uint8_t* data) = 0;

virtual uint8_t errorRequestId() const = 0;

virtual uint8_t errorNumberRequested() const = 0;

virtual bool errorRequestChanged() const = 0;
virtual uint8_t getAttr(HMI_ATTR_U8 attr) = 0;
virtual uint16_t getAttr(HMI_ATTR_U16 attr) = 0;
virtual bool getAttr(HMI_ATTR_BOOL attr) = 0;
virtual float getAttr(HMI_ATTR_FLOAT attr) = 0;
virtual void getAttr(HMI_ATTR_STR attr, char* buffer) = 0;

virtual void setAttr(HMI_ATTR_U8 attr, uint8_t value) = 0;
virtual void setAttr(HMI_ATTR_U16 attr, uint16_t value) = 0;
virtual void setAttr(HMI_ATTR_BOOL attr, bool value) = 0;
virtual void setAttr(HMI_ATTR_FLOAT attr, float value) = 0;

virtual bool hasAttr(HMI_ATTR_U8 attr) const = 0;
virtual bool hasAttr(HMI_ATTR_U16 attr) const = 0;
virtual bool hasAttr(HMI_ATTR_BOOL attr) const = 0;
virtual bool hasAttr(HMI_ATTR_FLOAT attr) const = 0;
virtual bool hasAttr(HMI_ATTR_STR attr) const = 0;

virtual bool hasChanged(HMI_ATTR_U8 attr) const = 0;
virtual bool hasChanged(HMI_ATTR_U16 attr) const = 0;
virtual bool hasChanged(HMI_ATTR_BOOL attr) const = 0;
virtual bool hasChanged(HMI_ATTR_FLOAT attr) const = 0;
virtual bool hasChanged(HMI_ATTR_STR attr) const = 0;
};
} // namespace message
} // namespace aquamqtt
} // namespace aquamqtt::message

#endif // AQUAMQTT_IHMIMESSAGE_H
Loading

0 comments on commit bd79ebf

Please sign in to comment.