ggwave : getTxProtocols is now static method

This commit is contained in:
Georgi Gerganov
2021-01-09 13:24:19 +02:00
parent 78af9e96b6
commit a9b339c02e
2 changed files with 20 additions and 17 deletions

View File

@@ -26,14 +26,18 @@ public:
using TxProtocols = std::vector<TxProtocol>;
const TxProtocols kTxProtocols {
{ "Normal", 40, 9, 3, },
{ "Fast", 40, 6, 3, },
{ "Fastest", 40, 3, 3, },
{ "[U] Normal", 320, 9, 3, },
{ "[U] Fast", 320, 6, 3, },
{ "[U] Fastest", 320, 3, 3, },
};
static const TxProtocols & getTxProtocols() {
static TxProtocols kTxProtocols {
{ "Normal", 40, 9, 3, },
{ "Fast", 40, 6, 3, },
{ "Fastest", 40, 3, 3, },
{ "[U] Normal", 320, 9, 3, },
{ "[U] Fast", 320, 6, 3, },
{ "[U] Fastest", 320, 3, 3, },
};
return kTxProtocols;
}
using AmplitudeData = std::vector<float>;
using AmplitudeData16 = std::vector<int16_t>;
@@ -71,8 +75,7 @@ public:
const float & getSampleRateIn() const { return m_sampleRateIn; }
const float & getSampleRateOut() const { return m_sampleRateOut; }
const TxProtocol & getDefultTxProtocol() const { return kTxProtocols[1]; }
const TxProtocols & getTxProtocols() const { return kTxProtocols; }
const TxProtocol & getDefultTxProtocol() const { return getTxProtocols()[1]; }
const TxRxData & getRxData() const { return m_rxData; }
const TxProtocol & getRxProtocol() const { return m_rxProtocol; }

View File

@@ -444,8 +444,8 @@ void GGWave::receive(const CBDequeueAudio & CBDequeueAudio) {
const int step = m_samplesPerFrame/stepsPerFrame;
bool isValid = false;
for (int rxProtocolId = 0; rxProtocolId < (int) kTxProtocols.size(); ++rxProtocolId) {
const auto & rxProtocol = kTxProtocols[rxProtocolId];
for (int rxProtocolId = 0; rxProtocolId < (int) getTxProtocols().size(); ++rxProtocolId) {
const auto & rxProtocol = getTxProtocols()[rxProtocolId];
// skip Rx protocol if start frequency is different from detected one
if (rxProtocol.freqStart != m_markerFreqStart) {
@@ -576,7 +576,7 @@ void GGWave::receive(const CBDequeueAudio & CBDequeueAudio) {
if (m_receivingData == false) {
bool isReceiving = false;
for (const auto & rxProtocol : kTxProtocols) {
for (const auto & rxProtocol : getTxProtocols()) {
int nDetectedMarkerBits = m_nBitsInMarker;
for (int i = 0; i < m_nBitsInMarker; ++i) {
@@ -615,7 +615,7 @@ void GGWave::receive(const CBDequeueAudio & CBDequeueAudio) {
} else {
bool isEnded = false;
for (const auto & rxProtocol : kTxProtocols) {
for (const auto & rxProtocol : getTxProtocols()) {
int nDetectedMarkerBits = m_nBitsInMarker;
for (int i = 0; i < m_nBitsInMarker; ++i) {
@@ -681,15 +681,15 @@ bool GGWave::takeSpectrum(SpectrumData & dst) {
int GGWave::maxFramesPerTx() const {
int res = 0;
for (const auto & protocol : kTxProtocols) {
for (const auto & protocol : getTxProtocols()) {
res = std::max(res, protocol.framesPerTx);
}
return res;
}
int GGWave::minBytesPerTx() const {
int res = kTxProtocols.front().framesPerTx;
for (const auto & protocol : kTxProtocols) {
int res = getTxProtocols().front().framesPerTx;
for (const auto & protocol : getTxProtocols()) {
res = std::min(res, protocol.bytesPerTx);
}
return res;