Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 51 additions & 50 deletions src/ofdm/tii-detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,55 +88,39 @@ static constexpr std::array<const std::byte, 70> cMainIdPatternTable = {
std::byte{0xf0} // 1 1 1 1 0 0 0 0 69
};

static constexpr std::array<const int8_t, 768> cPhaseCorrTable = {
2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0,
1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1,
0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2,
-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1,
2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0,
1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1,
0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2,
-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1,
2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0,
1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1,
0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2,
-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1,
2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0,
1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1,
0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2,
-1, 1, 1,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 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 1, 3, 3, 3, 1, 3, 3, 3,
1, 3, 3, 3, 1, 3, 3, 3, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0,
3, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2,
0, 2, 2, 2, 0, 2, 2, 2, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3,
2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 3, 1, 1, 1, 3, 1, 1, 1,
3, 1, 1, 1, 3, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2,
1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 2, 0, 0, 0, 2, 0, 0, 0,
2, 0, 0, 0, 2, 0, 0, 0, 3, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1,
0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 1, 3, 3, 3, 1, 3, 3, 3,
1, 3, 3, 3, 1, 3, 3, 3, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0,
3, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2,
0, 2, 2, 2, 0, 2, 2, 2, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3
};

inline std::byte rev_bit_val(const uint32_t iBitPos)
Expand Down Expand Up @@ -343,6 +327,23 @@ void TiiDetector::_remove_single_carrier_values(TBufferArr768 & ioBuffer) const
}
}

// turns the phase 0, 90, 180 or -90 degrees
cmplx TiiDetector::_turn_phase(cmplx value, uint8_t phase) const
{
switch (phase)
{
case 3:
return cmplx(-imag(value), real(value));
case 2:
return -value;
case 1:
return cmplx(imag(value), -real(value));
case 0:
default:
return value;
}
}

// we map the "K" carriers (complex values) onto
// a collapsed vector of "K / 8" length,
// considered to consist of 8 segments of 24 values
Expand All @@ -369,7 +370,7 @@ void TiiDetector::_collapse_tii_groups(TCmplxTable192 & ioEtsiVec, TCmplxTable19
const cmplx x = buffer[i + blockIdx * cBlockSize192];
ioEtsiVec[i] += x;
// correct assumed wrongly sent carrier pair phase difference
ioNonEtsiVec[i] += std::polar(abs(x), arg(x) - (float)cPhaseCorrTable[i + blockIdx * cBlockSize192] * F_M_PI_2);
ioNonEtsiVec[i] += _turn_phase(x, cPhaseCorrTable[i + blockIdx * cBlockSize192]);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ofdm/tii-detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ class TiiDetector
void _remove_single_carrier_values(TBufferArr768 & ioBuffer) const;
void _decode_and_accumulate_carrier_pairs(TBufferArr768 & ioVec, const std::vector<cmplx> & iVec) const;
void _collapse_tii_groups(TCmplxTable192 & ioEtsiVec, TCmplxTable192 & ioNonEtsiVec, const TBufferArr768 & iVec) const;
cmplx _turn_phase(cmplx const value, const uint8_t phase) const;
};