diff --git a/src/AmsToMqttBridge.cpp b/src/AmsToMqttBridge.cpp index b29a569e..aed27a4c 100644 --- a/src/AmsToMqttBridge.cpp +++ b/src/AmsToMqttBridge.cpp @@ -78,7 +78,7 @@ ADC_MODE(ADC_VCC); #include "MeterCommunicator.h" #include "PassiveMeterCommunicator.h" -//#include "KamstrupPullCommunicator.h" +#include "KmpCommunicator.h" #include "PulseMeterCommunicator.h" #include "Uptime.h" @@ -171,7 +171,7 @@ RealtimePlot rtp; MeterCommunicator* mc = NULL; PassiveMeterCommunicator* passiveMc = NULL; -//KamstrupPullCommunicator* kamstrupMc = NULL; +KmpCommunicator* kmpMc = NULL; PulseMeterCommunicator* pulseMc = NULL; bool networkConnected = false; @@ -260,11 +260,9 @@ void rxerr(int err) { if(passiveMc != NULL) { passiveMc->rxerr(err); } - /* - if(kamstrupMc != NULL) { - kamstrupMc->rxerr(err); + if(kmpMc != NULL) { + kmpMc->rxerr(err); } - */ } #endif @@ -723,12 +721,10 @@ void loop() { delete pulseMc; pulseMc = NULL; } - /* - if(kamstrupMc != NULL) { - delete(kamstrupMc); - kamstrupMc = NULL; + if(kmpMc != NULL) { + delete(kmpMc); + kmpMc = NULL; } - */ if(passiveMc == NULL) { passiveMc = new PassiveMeterCommunicator(&Debug); } @@ -736,7 +732,6 @@ void loop() { hwSerial = passiveMc->getHwSerial(); mc = passiveMc; break; - /* case METER_PARSER_KAMSTRUP: if(pulseMc != NULL) { delete pulseMc; @@ -746,20 +741,18 @@ void loop() { delete(passiveMc); passiveMc = NULL; } - if(kamstrupMc == NULL) { - kamstrupMc = new KamstrupPullCommunicator(&Debug); + if(kmpMc == NULL) { + kmpMc = new KmpCommunicator(&Debug); } - kamstrupMc->configure(meterConfig, tz); - hwSerial = kamstrupMc->getHwSerial(); - mc = kamstrupMc; - break;*/ + kmpMc->configure(meterConfig, tz); + hwSerial = kmpMc->getHwSerial(); + mc = kmpMc; + break; case METER_PARSER_PULSE: - /* - if(kamstrupMc != NULL) { - delete(kamstrupMc); - kamstrupMc = NULL; + if(kmpMc != NULL) { + delete(kmpMc); + kmpMc = NULL; } - */ if(passiveMc != NULL) { delete(passiveMc); passiveMc = NULL; diff --git a/src/KmpCommunicator.cpp b/src/KmpCommunicator.cpp new file mode 100644 index 00000000..a361cb88 --- /dev/null +++ b/src/KmpCommunicator.cpp @@ -0,0 +1,12 @@ +#include "KmpCommunicator.h" + +KmpCommunicator::KmpCommunicator(RemoteDebug* debugger) {} +void KmpCommunicator::configure(MeterConfig& config, Timezone* tz) {} +bool KmpCommunicator::loop() { return false; } +AmsData* KmpCommunicator::getData(AmsData& meterState) { return NULL; } +int KmpCommunicator::getLastError() { return 0; } +bool KmpCommunicator::isConfigChanged() { return false; } +void KmpCommunicator::getCurrentConfig(MeterConfig& meterConfig) {} + +HardwareSerial* KmpCommunicator::getHwSerial() { return NULL; } +void KmpCommunicator::rxerr(int err) {} diff --git a/src/KmpCommunicator.h b/src/KmpCommunicator.h new file mode 100644 index 00000000..85684de9 --- /dev/null +++ b/src/KmpCommunicator.h @@ -0,0 +1,27 @@ +/** + * @copyright Utilitech AS 2024 + * License: Fair Source + * + */ + +#pragma once + +#include "MeterCommunicator.h" +#include "RemoteDebug.h" +#include "AmsConfiguration.h" +#include "Timezone.h" +#include "ImpulseAmsData.h" + +class KmpCommunicator : public MeterCommunicator { +public: + KmpCommunicator(RemoteDebug* debugger); + void configure(MeterConfig& config, Timezone* tz); + bool loop(); + AmsData* getData(AmsData& meterState); + int getLastError(); + bool isConfigChanged(); + void getCurrentConfig(MeterConfig& meterConfig); + + HardwareSerial* getHwSerial(); + void rxerr(int err); +};