diff --git a/simulations/simulation_t1.txt b/simulations/simulation_t1.txt index c6be7fb..b819e6a 100644 --- a/simulations/simulation_t1.txt +++ b/simulations/simulation_t1.txt @@ -16,24 +16,31 @@ telegram=|1E44AE4C9956341268077A36001000|2F2F0413181E0000023B00002F2F2F2F| telegram=|1844AE4C4455223368077A55000000|041389E20100023B0000| {"media":"water","meter":"iperl","name":"WaterWater","id":"33225544","total_m3":123.529,"max_flow_m3h":0,"timestamp":"1111-11-11T11:11:11Z"} -# Test at-wmbus-16-2 T1 telegram with offset 25 +# Test at-wmbus-16-2 T1 telegram with offset 23 telegram=|6E4401062020202005077A9A006085|2F2F0F0A734393CC0000435B0183001A54E06F630291342510030F00007B013E0B00003E0B00003E0B00003E0B00003E0B00003E0B00003E0B0000650000003D0000003D0000003D00000000000000A0910CB003FFFFFFFFFFFFFFFFFFFFA62B| {"media":"water","meter":"apator162","name":"Wasser","id":"20202020","total_m3":3.843,"timestamp":"1111-11-11T11:11:11Z"} -# Test at-wmbus-16-2 T1 telegram with offset 14 +# Test at-wmbus-16-2 T1 telegram with offset 12 telegram=|4E4401062020202105077A13004085|2F2F0F6D4C389300020043840210|351F040075012C0B040048D603003E630300CD2C03001EF402000ACE0200A098A39603FFFFFFFFFFFFFFFFFFFFFFFFFF1977| {"media":"water","meter":"apator162","name":"MyTapWatera","id":"21202020","total_m3":270.133,"timestamp":"1111-11-11T11:11:11Z"} -# Test at-wmbus-16-2 T1 telegram with offset 22 +# Test at-wmbus-16-2 T1 telegram with offset 20 + telegram=|4E4401062020202205077A4B004085|2F2F0FE566B99390000087C0B24B732679FF75350010FCFB00004155594265086A0043B4017301DFF600006AE70000BFD5000051BC0000A0F56C2602FFFF1B1B| {"media":"water","meter":"apator162","name":"MyTapWaterb","id":"22202020","total_m3":64.508,"timestamp":"1111-11-11T11:11:11Z"} -# Test at-wmbus-16-2 T1 telegram with offset 11 +# Test at-wmbus-16-2 T1 telegram with offset 9 + telegram=|4E4401062020202305077A9D004085|2F2F0F81902C9300000010B82F010041555942BD2882004319027301BC2601005C180100CB0A0100DFF60000A0F56C2602FFFFFFFFFFFFFFFFFFFFFFFFFF5B7C| {"media":"water","meter":"apator162","name":"MyTapWaterc","id":"23202020","total_m3":77.752,"timestamp":"1111-11-11T11:11:11Z"} +# Test at-wmbus-16-2 T1 telegram with offset 20 + +telegram=|4E4401062020202405077A6C0040852F2F|0F73B3E19410000084E15381E553810101000010FA41010041555942BF4E8A00433B027301AD380100BC2601005C180100CB0A0100A0F56C2602FFFFD0D7| +{"media":"water","meter":"apator162","name":"MyTapWaterd","id":"24202020","total_m3":82.426,"timestamp":"1111-11-11T11:11:11Z"} + # Test amiplus/apator electricity meter telegram=|4E4401061010101002027A00004005|2F2F0E035040691500000B2B300300066D00790C7423400C78371204860BABC8FC100000000E833C8074000000000BAB3C0000000AFDC9FC0136022F2F2F2F2F| diff --git a/src/meter_apator162.cc b/src/meter_apator162.cc index 58f61e7..098a1ce 100644 --- a/src/meter_apator162.cc +++ b/src/meter_apator162.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2019 Fredrik Öhrström + Copyright (C) 2017-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 @@ -87,33 +87,39 @@ void MeterApator162::processContent(Telegram *t) // Current assumption of this proprietary protocol is that byte 13 tells // us where the current total water consumption is located. int o = 0; - if ((content[11] & 0x80) == 0x80) + uchar guess = content[11]; + if ((guess & 0x83) == 0x83) { o = 23; } else - if ((content[11] & 0x40) == 0x40) + if ((guess & 0x81) == 0x81) { o = 20; } else - if ((content[11] & 0x10) == 0x10) + if ((guess & 0x40) == 0x40) + { + o = 20; + } + else + if ((guess & 0x10) == 0x10) { o = 12; } else - if ((content[11] & 0x01) == 0x01) + if ((guess & 0x01) == 0x01) { o = 9; } else { - warning("(apator162) Unknown value in proprietary(unknown) apator162 protocol. Ignoring telegram. Found 0x%02x expected bit 0x01, 0x10, 0x40 or 0x80 to be set.\n", content[13]); + warning("(apator162) Unknown value in proprietary(unknown) apator162 protocol. Ignoring telegram. Found 0x%02x expected bit 0x01, 0x10, 0x40 or 0x80 to be set.\n", guess); return; } strprintf(total, "%02x%02x%02x%02x", content[o], content[o+1], content[o+2], content[o+3]); - debug("(apator162) Guessing offset to be %d from byte 0x%02x: total %s\n", o, content[13], total.c_str()); + debug("(apator162) Guessing offset to be %d from byte 0x%02x: total %s\n", o, guess, total.c_str()); vendor_values["0413"] = { 25, DVEntry(MeasurementType::Instantaneous, 0x13, 0, 0, 0, total) }; int offset; diff --git a/tests/test_listen_to_all.sh b/tests/test_listen_to_all.sh index 8bac766..1afba6a 100755 --- a/tests/test_listen_to_all.sh +++ b/tests/test_listen_to_all.sh @@ -45,6 +45,9 @@ Received telegram from: 22202020 Received telegram from: 23202020 manufacturer: (APA) Apator, Poland device type: Water meter +Received telegram from: 24202020 + manufacturer: (APA) Apator, Poland + device type: Water meter Received telegram from: 10101010 manufacturer: (APA) Apator, Poland device type: Electricity meter diff --git a/tests/test_t1_meters.sh b/tests/test_t1_meters.sh index 875563e..9060c12 100755 --- a/tests/test_t1_meters.sh +++ b/tests/test_t1_meters.sh @@ -18,6 +18,7 @@ $PROG --format=json simulations/simulation_t1.txt \ MyTapWatera apator162 21202020 "" \ MyTapWaterb apator162 22202020 "" \ MyTapWaterc apator162 23202020 "" \ + MyTapWaterd apator162 24202020 "" \ MyElectricity1 amiplus 10101010 "" \ Duschen mkradio3 34333231 "" \ HeatMeter vario451 58234965 "" \