Browse Source

Meshtasticdemod: calculate carrier frequency offset

chirpmodem-v8.0.0
jvn314 1 month ago
parent
commit
e923bf2f32
  1. 10
      plugins/channelrx/demodmeshtastic/meshtasticdemodmsg.h
  2. 7
      plugins/channelrx/demodmeshtastic/meshtasticdemodsink.cpp

10
plugins/channelrx/demodmeshtastic/meshtasticdemodmsg.h

@ -40,6 +40,9 @@ namespace MeshtasticDemodMsg @@ -40,6 +40,9 @@ namespace MeshtasticDemodMsg
unsigned int getSyncWord() const { return m_syncWord; }
float getSingalDb() const { return m_signalDb; }
float getNoiseDb() const { return m_noiseDb; }
// Access the carrier frequency offset in Hz carried by this message.
double getCfoHz() const { return m_cfoHz; }
void setCfoHz(double cfoHz) { m_cfoHz = cfoHz; }
void pushBackSymbol(unsigned short symbol) {
m_symbols.push_back(symbol);
@ -93,6 +96,8 @@ namespace MeshtasticDemodMsg @@ -93,6 +96,8 @@ namespace MeshtasticDemodMsg
unsigned int m_syncWord;
float m_signalDb;
float m_noiseDb;
// Initialize the carrier frequency offset in Hz for every new message.
double m_cfoHz = 0.0;
MsgDecodeSymbols() : //!< create an empty message
Message(),
@ -259,6 +264,9 @@ namespace MeshtasticDemodMsg @@ -259,6 +264,9 @@ namespace MeshtasticDemodMsg
unsigned int getSyncWord() const { return m_syncWord; }
float getSingalDb() const { return m_signalDb; }
float getNoiseDb() const { return m_noiseDb; }
// Access the carrier frequency offset in Hz carried by this message.
double getCfoHz() const { return m_cfoHz; }
void setCfoHz(double cfoHz) { m_cfoHz = cfoHz; }
const QString& getMsgTimestamp() const { return m_msgTimestamp; }
unsigned int getPacketSize() const { return m_packetSize; }
unsigned int getNbParityBits() const { return m_nbParityBits; }
@ -338,6 +346,8 @@ namespace MeshtasticDemodMsg @@ -338,6 +346,8 @@ namespace MeshtasticDemodMsg
unsigned int m_syncWord;
float m_signalDb;
float m_noiseDb;
// Initialize the carrier frequency offset in Hz for every new message.
double m_cfoHz = 0.0;
QString m_msgTimestamp;
unsigned int m_packetSize;
unsigned int m_nbParityBits;

7
plugins/channelrx/demodmeshtastic/meshtasticdemodsink.cpp

@ -1019,6 +1019,11 @@ int MeshtasticDemodSink::processLoRaFrameSyncStep() @@ -1019,6 +1019,11 @@ int MeshtasticDemodSink::processLoRaFrameSyncStep()
m_loRaCFOInt = static_cast<int>(std::floor((m_loRaDownVal - static_cast<int>(m_nbSymbols)) / 2.0));
}
// Convert the carrier frequency offset (CFO) estimate from FFT bins to Hz.
const double cfoHz =
(static_cast<double>(m_loRaCFOInt) + static_cast<double>(m_loRaCFOFrac))
* static_cast<double>(m_bandwidth) / static_cast<double>(m_nbSymbols);
// Preserve state-machine net ID bin indices for sync word extraction.
// The corrLen-based refinement overwrites m_loRaNetIds but may produce
// incorrect results when m_loRaNetIdSamp is not fully populated.
@ -1140,6 +1145,8 @@ int MeshtasticDemodSink::processLoRaFrameSyncStep() @@ -1140,6 +1145,8 @@ int MeshtasticDemodSink::processLoRaFrameSyncStep()
m_loRaFrameId++;
m_decodeMsg = MeshtasticDemodMsg::MsgDecodeSymbols::create();
m_decodeMsg->setFrameId(m_loRaFrameId);
// Attach the measured carrier frequency offset to this frame.
m_decodeMsg->setCfoHz(cfoHz);
{
// LoRa sync word is encoded across two net-ID chirps.
// First chirp (index 0) carries the high nibble, second (index 1) the low nibble.

Loading…
Cancel
Save