aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edi/ETIDecoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/edi/ETIDecoder.cpp')
-rw-r--r--lib/edi/ETIDecoder.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/edi/ETIDecoder.cpp b/lib/edi/ETIDecoder.cpp
index 1fa9c3c..88a7333 100644
--- a/lib/edi/ETIDecoder.cpp
+++ b/lib/edi/ETIDecoder.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2019
+ Copyright (C) 2020
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -30,9 +30,9 @@ namespace EdiDecoder {
using namespace std;
-ETIDecoder::ETIDecoder(ETIDataCollector& data_collector, bool verbose) :
+ETIDecoder::ETIDecoder(ETIDataCollector& data_collector) :
m_data_collector(data_collector),
- m_dispatcher(std::bind(&ETIDecoder::packet_completed, this), verbose)
+ m_dispatcher(std::bind(&ETIDecoder::packet_completed, this))
{
using std::placeholders::_1;
using std::placeholders::_2;
@@ -44,6 +44,12 @@ ETIDecoder::ETIDecoder(ETIDataCollector& data_collector, bool verbose) :
std::bind(&ETIDecoder::decode_estn, this, _1, _2));
m_dispatcher.register_tag("*dmy",
std::bind(&ETIDecoder::decode_stardmy, this, _1, _2));
+ m_dispatcher.register_tagpacket_handler(std::bind(&ETIDecoder::decode_tagpacket, this, _1));
+}
+
+void ETIDecoder::set_verbose(bool verbose)
+{
+ m_dispatcher.set_verbose(verbose);
}
void ETIDecoder::push_bytes(const vector<uint8_t> &buf)
@@ -63,7 +69,7 @@ void ETIDecoder::setMaxDelay(int num_af_packets)
#define AFPACKET_HEADER_LEN 10 // includes SYNC
-bool ETIDecoder::decode_starptr(const vector<uint8_t> &value, uint16_t)
+bool ETIDecoder::decode_starptr(const std::vector<uint8_t>& value, const tag_name_t& n)
{
if (value.size() != 0x40 / 8) {
etiLog.log(warn, "Incorrect length %02lx for *PTR", value.size());
@@ -83,7 +89,7 @@ bool ETIDecoder::decode_starptr(const vector<uint8_t> &value, uint16_t)
return true;
}
-bool ETIDecoder::decode_deti(const vector<uint8_t> &value, uint16_t)
+bool ETIDecoder::decode_deti(const std::vector<uint8_t>& value, const tag_name_t& n)
{
/*
uint16_t detiHeader = fct | (fcth << 8) | (rfudf << 13) | (ficf << 14) | (atstf << 15);
@@ -145,6 +151,8 @@ bool ETIDecoder::decode_deti(const vector<uint8_t> &value, uint16_t)
i += 4;
m_data_collector.update_edi_time(utco, seconds);
+ m_received_tagpacket.timestamp.utco = utco;
+ m_received_tagpacket.timestamp.seconds = seconds;
fc.tsta = read_24b(value.begin() + i);
i += 3;
@@ -152,8 +160,12 @@ bool ETIDecoder::decode_deti(const vector<uint8_t> &value, uint16_t)
else {
// Null timestamp, ETSI ETS 300 799, C.2.2
fc.tsta = 0xFFFFFF;
+ m_received_tagpacket.timestamp.utco = 0;
+ m_received_tagpacket.timestamp.seconds = 0;
}
+ m_received_tagpacket.timestamp.tsta = fc.tsta;
+
if (fc.ficf) {
vector<uint8_t> fic(fic_length);
@@ -183,12 +195,13 @@ bool ETIDecoder::decode_deti(const vector<uint8_t> &value, uint16_t)
return true;
}
-bool ETIDecoder::decode_estn(const vector<uint8_t> &value, uint16_t n)
+bool ETIDecoder::decode_estn(const std::vector<uint8_t>& value, const tag_name_t& name)
{
uint32_t sstc = read_24b(value.begin());
eti_stc_data stc;
+ const uint8_t n = name[3];
stc.stream_index = n - 1; // n is 1-indexed
stc.scid = (sstc >> 18) & 0x3F;
stc.sad = (sstc >> 8) & 0x3FF;
@@ -207,14 +220,22 @@ bool ETIDecoder::decode_estn(const vector<uint8_t> &value, uint16_t n)
return true;
}
-bool ETIDecoder::decode_stardmy(const vector<uint8_t>& /*value*/, uint16_t)
+bool ETIDecoder::decode_stardmy(const std::vector<uint8_t>&, const tag_name_t&)
+{
+ return true;
+}
+
+bool ETIDecoder::decode_tagpacket(const std::vector<uint8_t>& value)
{
+ m_received_tagpacket.tagpacket = value;
return true;
}
void ETIDecoder::packet_completed()
{
- m_data_collector.assemble();
+ ReceivedTagPacket tp;
+ swap(tp, m_received_tagpacket);
+ m_data_collector.assemble(move(tp));
}
}