kopia lustrzana https://github.com/weetmuts/wmbusmeters
Added minimal stub for tsd2.
rodzic
eb33a0bf13
commit
18cbf887b2
1
Makefile
1
Makefile
|
@ -157,6 +157,7 @@ METER_OBJS:=\
|
|||
$(BUILD)/meter_supercom587.o \
|
||||
$(BUILD)/meter_sontex868.o \
|
||||
$(BUILD)/meter_topaseskr.o \
|
||||
$(BUILD)/meter_tsd2.o \
|
||||
$(BUILD)/meter_ultrimis.o \
|
||||
$(BUILD)/meter_vario451.o \
|
||||
$(BUILD)/meter_waterstarm.o \
|
||||
|
|
|
@ -202,3 +202,8 @@ telegram=|2E449215303099990D077AB50820452F2F|0C12495849004C12557545000FB10445007
|
|||
telegram=|2E4492159293949511377ABE0020252F2F|04135515000004FD971D80800000441300000000426C000002FDFD02B300|
|
||||
{"media":"radio converter (meter side)","meter":"emerlin868","name":"Vodda","id":"95949392","total_m3":5.461,"target_m3":0,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
|Vodda;95949392;5.461000;0.000000;1111-11-11 11:11.11
|
||||
|
||||
# Test Techem TSD2 smoke detector
|
||||
telegram=|294468506935639176F0A0|009F2782290060822900000401D6311AF93E1BF93E008DC3009ED4000FE500|
|
||||
{"media":"smoke detector","meter":"tsd2","name":"Smokey","id":"91633569","status":"OK","timestamp":"1111-11-11T11:11:11Z"}
|
||||
|Smokey;91633569;OK;1111-11-11 11:11.11
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
Copyright (C) 2020 Fredrik Öhrström
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include"dvparser.h"
|
||||
#include"meters.h"
|
||||
#include"meters_common_implementation.h"
|
||||
#include"wmbus.h"
|
||||
#include"wmbus_utils.h"
|
||||
|
||||
#define INFO_CODE_SMOKE 0x0001
|
||||
|
||||
struct MeterTSD2 : public virtual SmokeDetector, public virtual MeterCommonImplementation
|
||||
{
|
||||
MeterTSD2(MeterInfo &mi);
|
||||
|
||||
string status();
|
||||
bool smokeDetected();
|
||||
|
||||
private:
|
||||
|
||||
void processContent(Telegram *t);
|
||||
|
||||
private:
|
||||
|
||||
uint16_t info_codes_ {};
|
||||
bool error_ {};
|
||||
};
|
||||
|
||||
MeterTSD2::MeterTSD2(MeterInfo &mi) :
|
||||
MeterCommonImplementation(mi, MeterType::TSD2)
|
||||
{
|
||||
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
|
||||
|
||||
addLinkMode(LinkMode::T1);
|
||||
|
||||
addPrint("status", Quantity::Text,
|
||||
[&](){ return status(); },
|
||||
"The current status: OK, SMOKE or ERROR.",
|
||||
true, true);
|
||||
}
|
||||
|
||||
shared_ptr<SmokeDetector> createTSD2(MeterInfo &mi)
|
||||
{
|
||||
return shared_ptr<SmokeDetector>(new MeterTSD2(mi));
|
||||
}
|
||||
|
||||
bool MeterTSD2::smokeDetected()
|
||||
{
|
||||
return info_codes_ & INFO_CODE_SMOKE;
|
||||
}
|
||||
|
||||
void MeterTSD2::processContent(Telegram *t)
|
||||
{
|
||||
vector<uchar> data;
|
||||
t->extractPayload(&data);
|
||||
|
||||
if (data.size() > 0)
|
||||
{
|
||||
info_codes_ = data[0];
|
||||
error_ = false;
|
||||
// Check CRC etc here....
|
||||
}
|
||||
else
|
||||
{
|
||||
error_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
string MeterTSD2::status()
|
||||
{
|
||||
string s;
|
||||
bool smoke = info_codes_ & INFO_CODE_SMOKE;
|
||||
if (smoke)
|
||||
{
|
||||
s.append("SMOKE ");
|
||||
}
|
||||
|
||||
if (error_)
|
||||
{
|
||||
s.append("ERROR ");
|
||||
}
|
||||
|
||||
if (s.length() > 0)
|
||||
{
|
||||
s.pop_back();
|
||||
return s;
|
||||
}
|
||||
return "OK";
|
||||
}
|
|
@ -508,7 +508,7 @@ void MeterCommonImplementation::printMeter(Telegram *t,
|
|||
|
||||
string s;
|
||||
s += "{";
|
||||
s += "\"media\":\""+mediaTypeJSON(t->dll_type)+"\",";
|
||||
s += "\"media\":\""+mediaTypeJSON(t->dll_type, t->dll_mfct)+"\",";
|
||||
s += "\"meter\":\""+meterName()+"\",";
|
||||
s += "\"name\":\""+name()+"\",";
|
||||
s += "\"id\":\""+t->id+"\",";
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
X(omnipower, C1_bit, ElectricityMeter, OMNIPOWER, Omnipower) \
|
||||
X(rfmamb, T1_bit, TempHygroMeter, RFMAMB, RfmAmb) \
|
||||
X(rfmtx1, T1_bit, WaterMeter, RFMTX1, RfmTX1) \
|
||||
X(tsd2, T1_bit, SmokeDetector, TSD2, TSD2) \
|
||||
X(q400, T1_bit, WaterMeter, Q400, Q400) \
|
||||
X(qcaloric, C1_bit, HeatCostAllocationMeter, QCALORIC, QCaloric) \
|
||||
X(sontex868, T1_bit, HeatCostAllocationMeter, SONTEX868, Sontex868) \
|
||||
|
@ -150,6 +151,7 @@
|
|||
X(OMNIPOWER, MANUFACTURER_KAM, 0x02, 0x30) \
|
||||
X(RFMAMB, MANUFACTURER_BMT, 0x1b, 0x10) \
|
||||
X(RFMTX1, MANUFACTURER_BMT, 0x07, 0x05) \
|
||||
X(TSD2, MANUFACTURER_TCH, 0xf0, 0x76) \
|
||||
X(Q400, MANUFACTURER_AXI, 0x07, 0x10) \
|
||||
X(QCALORIC, MANUFACTURER_QDS, 0x08, 0x35) \
|
||||
X(SUPERCOM587,MANUFACTURER_SON, 0x06, 0x3c) \
|
||||
|
|
60
src/wmbus.cc
60
src/wmbus.cc
|
@ -234,7 +234,7 @@ void Telegram::print()
|
|||
manufacturerFlag(dll_mfct).c_str(),
|
||||
manufacturer(dll_mfct).c_str(),
|
||||
dll_mfct);
|
||||
notice(" type: %s (0x%02x)\n", mediaType(dll_type).c_str(), dll_type);
|
||||
notice(" type: %s (0x%02x)\n", mediaType(dll_type, dll_mfct).c_str(), dll_type);
|
||||
|
||||
notice(" ver: 0x%02x\n", dll_version);
|
||||
|
||||
|
@ -260,7 +260,7 @@ void Telegram::printDLL()
|
|||
dll_id[0], dll_id[1], dll_id[2], dll_id[3],
|
||||
dll_version,
|
||||
dll_type,
|
||||
mediaType(dll_type).c_str(),
|
||||
mediaType(dll_type, dll_mfct).c_str(),
|
||||
possible_drivers.c_str(),
|
||||
about.device.c_str(),
|
||||
about.rssi_dbm);
|
||||
|
@ -324,7 +324,7 @@ void Telegram::printTPL()
|
|||
|
||||
if (tpl_ci == 0x72)
|
||||
{
|
||||
string info = mediaType(tpl_type);
|
||||
string info = mediaType(tpl_type, tpl_mfct);
|
||||
verbose(" ID=%02x%02x%02x%02x MFT=%02x%02x VER=%02x TYPE=%02x (%s)",
|
||||
tpl_id_b[0], tpl_id_b[1], tpl_id_b[2], tpl_id_b[3],
|
||||
tpl_mfct_b[0], tpl_mfct_b[1],
|
||||
|
@ -378,7 +378,7 @@ string manufacturerFlag(int m_field) {
|
|||
return flag;
|
||||
}
|
||||
|
||||
string mediaType(int a_field_device_type) {
|
||||
string mediaType(int a_field_device_type, int m_field) {
|
||||
switch (a_field_device_type) {
|
||||
case 0: return "Other";
|
||||
case 1: return "Oil meter";
|
||||
|
@ -438,22 +438,25 @@ string mediaType(int a_field_device_type) {
|
|||
case 0x3D: return "Reserved for system devices";
|
||||
case 0x3E: return "Reserved for system devices";
|
||||
case 0x3F: return "Reserved for system devices";
|
||||
}
|
||||
|
||||
// Techem MK Radio 3/4 manufacturer specific.
|
||||
case 0x62: return "Warm water"; // MKRadio3/MKRadio4
|
||||
case 0x72: return "Cold water"; // MKRadio3/MKRadio4
|
||||
|
||||
// Techem FHKV.
|
||||
case 0x80: return "Heat Cost Allocator"; // FHKV data ii/iii
|
||||
|
||||
// Techem Vario 4 Typ 4.5.1 manufacturer specific.
|
||||
case 0xC3: return "Heat meter";
|
||||
|
||||
if (m_field == MANUFACTURER_TCH)
|
||||
{
|
||||
switch (a_field_device_type) {
|
||||
// Techem MK Radio 3/4 manufacturer specific.
|
||||
case 0x62: return "Warm water"; // MKRadio3/MKRadio4
|
||||
case 0x72: return "Cold water"; // MKRadio3/MKRadio4
|
||||
// Techem FHKV.
|
||||
case 0x80: return "Heat Cost Allocator"; // FHKV data ii/iii
|
||||
// Techem Vario 4 Typ 4.5.1 manufacturer specific.
|
||||
case 0xC3: return "Heat meter";
|
||||
case 0xf0: return "Smoke detector";
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
string mediaTypeJSON(int a_field_device_type)
|
||||
string mediaTypeJSON(int a_field_device_type, int m_field)
|
||||
{
|
||||
switch (a_field_device_type) {
|
||||
case 0: return "other";
|
||||
|
@ -514,17 +517,20 @@ string mediaTypeJSON(int a_field_device_type)
|
|||
case 0x3D: return "reserved";
|
||||
case 0x3E: return "reserved";
|
||||
case 0x3F: return "reserved";
|
||||
}
|
||||
|
||||
// Techem MK Radio 3/4 manufacturer specific.
|
||||
case 0x62: return "warm water"; // MKRadio3/MKRadio4
|
||||
case 0x72: return "cold water"; // MKRadio3/MKRadio4
|
||||
|
||||
// Techem FHKV.
|
||||
case 0x80: return "heat cost allocator"; // FHKV data ii/iii
|
||||
|
||||
// Techem Vario 4 Typ 4.5.1 manufacturer specific codes:
|
||||
case 0xC3: return "heat";
|
||||
|
||||
if (m_field == MANUFACTURER_TCH)
|
||||
{
|
||||
switch (a_field_device_type) {
|
||||
// Techem MK Radio 3/4 manufacturer specific.
|
||||
case 0x62: return "warm water"; // MKRadio3/MKRadio4
|
||||
case 0x72: return "cold water"; // MKRadio3/MKRadio4
|
||||
// Techem FHKV.
|
||||
case 0x80: return "heat cost allocator"; // FHKV data ii/iii
|
||||
// Techem Vario 4 Typ 4.5.1 manufacturer specific.
|
||||
case 0xC3: return "heat";
|
||||
case 0xf0: return "smoke detector";
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
@ -769,7 +775,7 @@ bool Telegram::parseDLL(vector<uchar>::iterator &pos)
|
|||
dll_type = *(pos+1);
|
||||
addExplanationAndIncrementPos(pos, 1, "%02x dll-version", dll_version);
|
||||
addExplanationAndIncrementPos(pos, 1, "%02x dll-type (%s)", dll_type,
|
||||
mediaType(dll_type).c_str());
|
||||
mediaType(dll_type, dll_mfct).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1215,7 +1221,7 @@ bool Telegram::parseLongTPL(std::vector<uchar>::iterator &pos)
|
|||
|
||||
CHECK(1);
|
||||
tpl_type = *(pos+0);
|
||||
string info = mediaType(tpl_type);
|
||||
string info = mediaType(tpl_type, tpl_mfct);
|
||||
addExplanationAndIncrementPos(pos, 1, "%02x tpl-type (%s)", tpl_type, info.c_str());
|
||||
|
||||
bool ok = parseShortTPL(pos);
|
||||
|
|
|
@ -584,8 +584,8 @@ shared_ptr<WMBus> openSimulator(string file, shared_ptr<SerialCommunicationManag
|
|||
|
||||
string manufacturer(int m_field);
|
||||
string manufacturerFlag(int m_field);
|
||||
string mediaType(int a_field_device_type);
|
||||
string mediaTypeJSON(int a_field_device_type);
|
||||
string mediaType(int a_field_device_type, int m_field);
|
||||
string mediaTypeJSON(int a_field_device_type, int m_field);
|
||||
bool isCiFieldOfType(int ci_field, CI_TYPE type);
|
||||
int ciFieldLength(int ci_field);
|
||||
string ciType(int ci_field);
|
||||
|
|
|
@ -205,6 +205,11 @@ Received telegram from: 95949392
|
|||
type: Radio converter (meter side) (0x37)
|
||||
ver: 0x11
|
||||
driver: emerlin868
|
||||
Received telegram from: 91633569
|
||||
manufacturer: (TCH) Techem Service (0x5068)
|
||||
type: Smoke detector (0xf0)
|
||||
ver: 0x76
|
||||
driver: tsd2
|
||||
EOF
|
||||
|
||||
RES=$($PROG --logfile=$LOGFILE --t1 simulations/simulation_t1.txt 2>&1)
|
||||
|
|
|
@ -41,7 +41,8 @@ METERS="MyWarmWater supercom587 12345678 NOKEY
|
|||
Witer topaseskr 78563412 NOKEY
|
||||
Heater sensostar 12345679 NOKEY
|
||||
Voda ev200 99993030 NOKEY
|
||||
Vodda emerlin868 95949392 NOKEY"
|
||||
Vodda emerlin868 95949392 NOKEY
|
||||
Smokey tsd2 91633569 NOKEY"
|
||||
|
||||
|
||||
cat simulations/simulation_t1.txt | grep '^{' > $TEST/test_expected.txt
|
||||
|
|
Ładowanie…
Reference in New Issue