From c439af109bf11ced83bf4a9297965ec27b11e79e Mon Sep 17 00:00:00 2001 From: weetmuts Date: Tue, 19 Mar 2019 18:51:57 +0100 Subject: [PATCH] Adaptor now perhaps extracts a volume. --- src/meter_apator162.cc | 19 ++++++++++++++++--- src/meter_iperl.cc | 2 +- src/meter_multical302.cc | 2 +- src/meter_omnipower.cc | 2 +- src/meter_qcaloric.cc | 2 +- src/meter_supercom587.cc | 2 +- src/wmbus.h | 4 ++++ src/wmbus_simulator.cc | 1 + 8 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/meter_apator162.cc b/src/meter_apator162.cc index 0047a49..09edb85 100644 --- a/src/meter_apator162.cc +++ b/src/meter_apator162.cc @@ -107,7 +107,7 @@ void MeterApator162::handleTelegram(Telegram *t) t->a_field_version); } - if (t->isEncrypted() && !useAes()) { + if (t->isEncrypted() && !useAes() && !t->isSimulated()) { warning("(apator162) warning: telegram is encrypted but no key supplied!\n"); } if (useAes()) { @@ -135,10 +135,23 @@ void MeterApator162::processContent(Telegram *t) map> values; parseDV(t, t->content, t->content.begin(), t->content.size(), &values); + // Unfortunately, the at-wmbus-16-2 is mostly a proprieatary protocol + // simple wrapped inside a wmbus telegram. Thus the parsing above ends + // immediately with a 0x0f dif which means: from now on, its vendor specific + // data structures. + + // By examining some telegrams though, it looks like the total consumption + // counter is on offset 25. So we can fake a parse here, to make it easier + // to extract using the existing tools. + map> vendor_values; + + string total; + strprintf(total, "%02x%02x%02x%02x", t->content[25], t->content[26], t->content[27], t->content[28]); + vendor_values["0413"] = { 25, DVEntry(0x13, 0, 0, 0, total) }; int offset; string key; - if(findKey(ValueInformation::Volume, 0, &key, &values)) { - extractDVdouble(&values, key, &offset, &total_water_consumption_); + if(findKey(ValueInformation::Volume, 0, &key, &vendor_values)) { + extractDVdouble(&vendor_values, key, &offset, &total_water_consumption_); t->addMoreExplanation(offset, " total consumption (%f m3)", total_water_consumption_); } } diff --git a/src/meter_iperl.cc b/src/meter_iperl.cc index 7f296cb..7bef003 100644 --- a/src/meter_iperl.cc +++ b/src/meter_iperl.cc @@ -109,7 +109,7 @@ void MeterIperl::handleTelegram(Telegram *t) t->a_field_version); } - if (t->isEncrypted() && !useAes()) { + if (t->isEncrypted() && !useAes() && !t->isSimulated()) { warning("(iperl) warning: telegram is encrypted but no key supplied!\n"); } if (useAes()) { diff --git a/src/meter_multical302.cc b/src/meter_multical302.cc index d3a309b..0bfe681 100644 --- a/src/meter_multical302.cc +++ b/src/meter_multical302.cc @@ -84,7 +84,7 @@ void MeterMultical302::handleTelegram(Telegram *t) { t->a_field_address[0], t->a_field_address[1], t->a_field_address[2], t->a_field_address[3]); - if (t->isEncrypted() && !useAes()) { + if (t->isEncrypted() && !useAes() && !t->isSimulated()) { warning("(multical302) warning: telegram is encrypted but no key supplied!\n"); } if (useAes()) { diff --git a/src/meter_omnipower.cc b/src/meter_omnipower.cc index a07ae54..0ae6bbc 100644 --- a/src/meter_omnipower.cc +++ b/src/meter_omnipower.cc @@ -83,7 +83,7 @@ void MeterOmnipower::handleTelegram(Telegram *t) { manufacturerFlag(t->m_field).c_str(), t->a_field_version); } - if (t->isEncrypted() && !useAes()) { + if (t->isEncrypted() && !useAes() && !t->isSimulated()) { warning("(omnipower) warning: telegram is encrypted but no key supplied!\n"); } if (useAes()) { diff --git a/src/meter_qcaloric.cc b/src/meter_qcaloric.cc index fdbc9bd..e7be853 100644 --- a/src/meter_qcaloric.cc +++ b/src/meter_qcaloric.cc @@ -98,7 +98,7 @@ void MeterQCaloric::handleTelegram(Telegram *t) { manufacturerFlag(t->m_field).c_str(), t->a_field_version); } - if (t->isEncrypted() && !useAes()) { + if (t->isEncrypted() && !useAes() && !t->isSimulated()) { warning("(qcaloric) warning: telegram is encrypted but no key supplied!\n"); } if (useAes()) { diff --git a/src/meter_supercom587.cc b/src/meter_supercom587.cc index a3c350e..1818253 100644 --- a/src/meter_supercom587.cc +++ b/src/meter_supercom587.cc @@ -107,7 +107,7 @@ void MeterSupercom587::handleTelegram(Telegram *t) t->a_field_version); } - if (t->isEncrypted() && !useAes()) { + if (t->isEncrypted() && !useAes() && !t->isSimulated()) { warning("(supercom587) warning: telegram is encrypted but no key supplied!\n"); } if (useAes()) { diff --git a/src/wmbus.h b/src/wmbus.h index 5ff40f4..42bed51 100644 --- a/src/wmbus.h +++ b/src/wmbus.h @@ -107,10 +107,14 @@ struct Telegram { void explainParse(string intro, int from); bool isEncrypted() { return is_encrypted_; } + bool isSimulated() { return is_simulated_; } + + void markAsSimulated() { is_simulated_ = true; } private: bool is_encrypted_ {}; + bool is_simulated_ {}; }; struct WMBus { diff --git a/src/wmbus_simulator.cc b/src/wmbus_simulator.cc index b5e17ff..8638ca5 100644 --- a/src/wmbus_simulator.cc +++ b/src/wmbus_simulator.cc @@ -180,6 +180,7 @@ void WMBusSimulator::simulate() } Telegram t; t.parse(payload); + t.markAsSimulated(); for (auto f : telegram_listeners_) { if (f) f(&t); }