forked from mutability/dump978
-
Notifications
You must be signed in to change notification settings - Fork 17
/
fec.h
53 lines (44 loc) · 2.16 KB
/
fec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// -*- c++ -*-
// Copyright (c) 2019, FlightAware LLC.
// All rights reserved.
// Licensed under the 2-clause BSD license; see the LICENSE file
#ifndef UAT_FEC_H
#define UAT_FEC_H
#include <tuple>
#include "common.h"
namespace flightaware::uat {
// Deinterleaving and error-correction of UAT messages.
// This delegates to the "fec" library (in fec/) for the actual Reed-Solomon
// error-correction work.
class FEC {
public:
FEC();
~FEC();
// Given DOWNLINK_LONG_BYTES of demodulated data, returns a tuple of:
// bool - true if the message is good, false if it was uncorrectable.
// Bytes - a buffer containing the corrected data with FEC bits removed;
// this will be either DOWNLINK_SHORT_DATA_BYTES or
// DOWNLINK_LONG_DATA_BYTES in size depending on the detected
// message type. Empty if the message was uncorrectable.
// unsigned - the number of errors corrected. 0 if the message was
// uncorrectable
// `erasures` is an optional vector of indexes into `raw` that should be
// handled as erasures
std::tuple<bool, Bytes, unsigned> CorrectDownlink(const Bytes &raw, const std::vector<std::size_t> &erasures = {});
// Given UPLINK_BYTES of demodulated data, returns a tuple of:
// bool - true if the message is good, false if it was uncorrectable.
// Bytes - a buffer containing the deinterleaved, corrected data with
// FEC bits removed; this will be exactly UPLINK_DATA_BYTES
// in size. Empty if the message was uncorrectable.
// unsigned - the number of errors corrected. 0 if the message was
// uncorrectable
// `erasures` is an optional vector of indexes into `raw` that should be
// handled as erasures
std::tuple<bool, Bytes, unsigned> CorrectUplink(const Bytes &raw, const std::vector<std::size_t> &erasures = {});
private:
void *rs_uplink_;
void *rs_downlink_short_;
void *rs_downlink_long_;
};
}; // namespace flightaware::uat
#endif