Skip to content

Commit

Permalink
Added default settings to KMP communicator
Browse files Browse the repository at this point in the history
  • Loading branch information
gskjold committed Nov 6, 2024
1 parent 118c633 commit 70d6a86
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/MeterCommunicators/include/KmpCommunicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/MeterCommunicators/include/PassiveMeterCommunicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions lib/MeterCommunicators/src/KmpCommunicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 70d6a86

Please sign in to comment.