From b782993eb4225e72704e7b98e86395df3804b628 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 15 Nov 2020 17:28:27 +0100 Subject: [PATCH] fix display or direction in pretty telegram --- src/emsesp.cpp | 2 +- src/telegram.cpp | 9 +++++---- src/telegram.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 896139bf4..88015b0f3 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -471,7 +471,7 @@ std::string EMSESP::pretty_telegram(std::shared_ptr telegram) { type_name = read_flash_string(F("?")); } - if (telegram->dest & 0x80) { + if (telegram->operation == Telegram::Operation::RX_READ) { direction = read_flash_string(F("<-")); } else { direction = read_flash_string(F("->")); diff --git a/src/telegram.cpp b/src/telegram.cpp index 4fb9e78af..350621e08 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -159,9 +159,10 @@ void RxService::add(uint8_t * data, uint8_t length) { } // src, dest and offset are always in fixed positions - uint8_t src = data[0] & 0x7F; // strip MSB (HT3 adds it) - uint8_t dest = data[1] & 0x7F; // strip MSB, don't care if its read or write for processing - uint8_t offset = data[3]; // offset is always 4th byte + uint8_t src = data[0] & 0x7F; // strip MSB (HT3 adds it) + uint8_t dest = data[1] & 0x7F; // strip MSB, don't care if its read or write for processing + uint8_t offset = data[3]; // offset is always 4th byte + uint8_t operation = (data[1] & 0x80) ? Telegram::Operation::RX_READ : Telegram::Operation::RX; uint16_t type_id; uint8_t * message_data; // where the message block starts @@ -212,7 +213,7 @@ void RxService::add(uint8_t * data, uint8_t length) { src = EMSESP::check_master_device(src, type_id, true); // create the telegram - auto telegram = std::make_shared(Telegram::Operation::RX, src, dest, type_id, offset, message_data, message_length); + auto telegram = std::make_shared(operation, src, dest, type_id, offset, message_data, message_length); // check if queue is full, if so remove top item to make space if (rx_telegrams_.size() >= MAX_RX_TELEGRAMS) { diff --git a/src/telegram.h b/src/telegram.h index 52a71bd9d..e438d784a 100644 --- a/src/telegram.h +++ b/src/telegram.h @@ -74,6 +74,7 @@ class Telegram { enum Operation : uint8_t { NONE = 0, RX, + RX_READ, TX_RAW, TX_READ, TX_WRITE,