From 70d6a8699b6f1db423e54a5242cb54ed957fe46b Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Wed, 6 Nov 2024 18:22:56 +0100 Subject: [PATCH] Added default settings to KMP communicator --- lib/MeterCommunicators/include/KmpCommunicator.h | 2 -- lib/MeterCommunicators/include/PassiveMeterCommunicator.h | 2 +- lib/MeterCommunicators/src/KmpCommunicator.cpp | 7 +++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/MeterCommunicators/include/KmpCommunicator.h b/lib/MeterCommunicators/include/KmpCommunicator.h index 1981e87f..03e32fd4 100644 --- a/lib/MeterCommunicators/include/KmpCommunicator.h +++ b/lib/MeterCommunicators/include/KmpCommunicator.h @@ -31,8 +31,6 @@ class KmpCommunicator : public PassiveMeterCommunicator { bool loop(); AmsData* getData(AmsData& meterState); int getLastError(); - bool isConfigChanged() { return false; } - void ackConfigChanged() {} void getCurrentConfig(MeterConfig& meterConfig) { meterConfig = this->meterConfig; } diff --git a/lib/MeterCommunicators/include/PassiveMeterCommunicator.h b/lib/MeterCommunicators/include/PassiveMeterCommunicator.h index 7540acce..84acb717 100644 --- a/lib/MeterCommunicators/include/PassiveMeterCommunicator.h +++ b/lib/MeterCommunicators/include/PassiveMeterCommunicator.h @@ -20,7 +20,7 @@ #include "SoftwareSerial.h" #endif -const uint32_t AUTO_BAUD_RATES[] = { 2400, 115200 }; +const uint32_t AUTO_BAUD_RATES[] = { 2400, 9600, 115200 }; class PassiveMeterCommunicator : public MeterCommunicator { public: diff --git a/lib/MeterCommunicators/src/KmpCommunicator.cpp b/lib/MeterCommunicators/src/KmpCommunicator.cpp index d1b75aed..381922dc 100644 --- a/lib/MeterCommunicators/src/KmpCommunicator.cpp +++ b/lib/MeterCommunicators/src/KmpCommunicator.cpp @@ -12,12 +12,19 @@ void KmpCommunicator::configure(MeterConfig& meterConfig) { this->meterConfig = meterConfig; this->configChanged = false; + if(meterConfig.baud == 0) { + this->configChanged = true; + meterConfig.baud = 9600; + meterConfig.parity = 7; + meterConfig.invert = false; + } setupHanPort(meterConfig.baud, meterConfig.parity, meterConfig.invert, false); talker = new KmpTalker(hanSerial, hanBuffer, hanBufferSize); } bool KmpCommunicator::loop() { uint64_t now = millis64(); + bool ret = talker->loop(); int lastError = getLastError(); if(ret) {