ems+ xF7 and xF9 commands

This commit is contained in:
proddy
2019-05-03 18:08:30 +02:00
parent 1850eb3797
commit 17307300fb
2 changed files with 26 additions and 7 deletions

View File

@@ -716,16 +716,31 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
// determing if its normal ems or ems plus
if (telegram[2] >= 0xF0) {
// its EMS plus
// its EMS plus / EMS 2.0
EMS_RxTelegram.emsplus = true;
EMS_RxTelegram.type = (telegram[4] << 8) + telegram[5]; // is a long in bytes 5 & 6
EMS_RxTelegram.data = telegram + 6;
if (length <= 7) {
EMS_RxTelegram.data_length = 0; // special broadcast on ems+ have no data values
if (telegram[2] == 0xFF) {
EMS_RxTelegram.type = (telegram[4] << 8) + telegram[5]; // is a long in bytes 5 & 6
EMS_RxTelegram.data = telegram + 6;
if (length <= 7) {
EMS_RxTelegram.data_length = 0; // special broadcast on ems+ have no data values
} else {
EMS_RxTelegram.data_length = length - 7; // remove 6 byte header plus CRC
}
} else {
EMS_RxTelegram.data_length = length - 7; // remove 6 byte header plus CRC
// its F9 or F7
uint8_t shift = (telegram[4] != 0xFF); // true (1) if byte 4 is not 0xFF, then telegram is 1 byte longer
EMS_RxTelegram.type = (telegram[5 + shift] << 8) + telegram[6 + shift];
EMS_RxTelegram.data = telegram + 6 + shift; // there is a special byte after the typeID which we ignore for now
if (length <= (9 + shift)) {
EMS_RxTelegram.data_length = 0; // special broadcast on ems+ have no data values
} else {
EMS_RxTelegram.data_length = length - (9 + shift);
}
}
} else {
// Normal EMS 1.0
EMS_RxTelegram.emsplus = false;
EMS_RxTelegram.type = telegram[2]; // 3rd byte
EMS_RxTelegram.data = telegram + 4;

View File

@@ -36,7 +36,11 @@ static const char * TEST_DATA[] = {
"10 48 02 00 9E", // test 31 - version test
"30 00 FF 00 02 8E 00 00 0C F3 00 00 06 02 00 00 76 33", // test 32 - SM100 energy
"30 00 FF 00 02 8E 00 00 07 9E 00 00 06 C5 00 00 76 35", // test 33 - SM100 energy
"30 00 FF 00 02 8E 00 00 00 00 00 00 06 C5 00 00 76 35" // test 34 - SM100 energy
"30 00 FF 00 02 8E 00 00 00 00 00 00 06 C5 00 00 76 35", // test 34 - SM100 energy
"10 48 F9 00 FF 01 6C 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03 00 02", // test 35 - F9
"48 90 F9 00 11 FF 01 6D 08", // test 36 - F9
"10 48 F9 00 FF 01 6D 08", // test 37 - F9
"10 00 F7 00 FF 01 B9 35 19" // test 38 - F7
};