Now media is returned properly in json.

pull/5/head
weetmuts 2018-11-01 20:45:44 +01:00
rodzic 847b6c9947
commit 2a04c74981
8 zmienionych plików z 38 dodań i 8 usunięć

Wyświetl plik

@ -26,7 +26,7 @@ Add --verbose for detailed debug information.
Specifying auto as the device will automatically look for usb
wmbus dongles on /dev/im871a and /dev/amb8465.
The meter types: multical21 and flowiq3100 (water meters) are supported.
The meter types: multical21,flowiq3100,supercom587 (water meters) are supported.
The meter types: multical302 (heat) and omnipower (electricity)
are work in progress.
```

Wyświetl plik

@ -48,8 +48,8 @@ int main(int argc, char **argv)
" or 10m for ten minutes or 5s for five seconds.\n\n");
printf("Specifying auto as the device will automatically look for usb\n");
printf("wmbus dongles on /dev/im871a and /dev/amb8465\n\n");
printf("The meter types: multical21 and flowiq3100 (water meters) are supported.\n"
"The meter types: multical302 (heat) and omnipower (electricity) and supercom587 (water)\n"
printf("The meter types: multical21,flowiq3100,supercom587 (water meters) are supported.\n"
"The meter types: multical302 (heat) and omnipower (electricity)\n"
"are work in progress.\n\n");
exit(0);
}

Wyświetl plik

@ -96,6 +96,8 @@ void MeterSupercom587::handleTelegram(Telegram *t)
mediaType(t->m_field, t->a_field_device_type).c_str());
}
updateMedia(t->a_field_device_type);
if (t->m_field != manufacturer() ||
t->a_field_version != 0x3c) {
warning("(%s) expected telegram from SON meter with version 0x%02x, "

Wyświetl plik

@ -165,3 +165,8 @@ void MeterCommonImplementation::triggerUpdate(Telegram *t)
for (auto &cb : on_update_) if (cb) cb(this);
t->handled = true;
}
void MeterCommonImplementation::updateMedia(int media)
{
media_ = media;
}

Wyświetl plik

@ -52,6 +52,7 @@ struct MeterCommonImplementation : public virtual Meter {
protected:
void triggerUpdate(Telegram *t);
void updateMedia(int media);
private:

Wyświetl plik

@ -17,8 +17,6 @@ telegram=|25442D2C785634121b048D2093E13CBA20|0000790000000000000000000000000000|
# full telegram
# Test Multical302 T1 telegrams
# Test Omnipower C1 telegrams
telegram=|1E442D2C0771941501027A|B300108504833B08340500|

Wyświetl plik

@ -0,0 +1,7 @@
# Test Supercom587 T1 telegrams
telegram=|A244EE4D785634123C067A73000000|0C1334190000426CE1F14C130000000082046C21298C0413330000008D04931E3A3CFE3300000033000000330000003300000033000000330000003300000033000000330000003300000033000000330000004300000034180000046D0113412B03FD6CDE120082206C5C290BFD0F0200018C4079678885238310FD3100000082106C01018110FD610002FD66020002|
{"media":"warm water","meter":"supercom587","name":"MyWarmWater","id":"12345678","total_m3":6.452000,"timestamp":"1111-11-11T11:11:11Z"}
telegram=|A244EE4D111111113C077A72000000|0C1374140000426CE1F14C130000000082046C21298C0413010000008D04931E3A3CFE0100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000001600000031130000046D0113412B03FD6CDF120082206C5C290BFD0F0200018C4079629885238310FD3100000082106C01018110FD610002FD66020002|
{"media":"water","meter":"supercom587","name":"MyColdWater","id":"11111111","total_m3":5.236000,"timestamp":"1111-11-11T11:11:11Z"}

23
test.sh
Wyświetl plik

@ -2,10 +2,10 @@
PROG="$1"
cat simulation.txt | grep '^{' > test_expected.txt
$PROG --robot=json simulation.txt \
MyTapWater multical21 76348799 "" \
cat simulation_c1.txt | grep '^{' > test_expected.txt
$PROG --robot=json simulation_c1.txt \
MyHeater multical302 12345678 "" \
MyTapWater multical21 76348799 "" \
MyElectricity omnipower 15947107 "" \
> test_output.txt
if [ "$?" == "0" ]
@ -19,3 +19,20 @@ then
else
Failure.
fi
cat simulation_t1.txt | grep '^{' > test_expected.txt
$PROG --robot=json simulation_t1.txt \
MyWarmWater supercom587 12345678 "" \
MyColdWater supercom587 11111111 "" \
> test_output.txt
if [ "$?" == "0" ]
then
cat test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > test_responses.txt
diff test_expected.txt test_responses.txt
if [ "$?" == "0" ]
then
echo OK
fi
else
Failure.
fi