add flex decoder menu entry and fix pocsag decoding

This commit is contained in:
AlexandreRouma
2024-02-01 00:55:17 +01:00
parent 3fc893568a
commit ef42ea01d8
4 changed files with 141 additions and 142 deletions

View File

@ -1,28 +1,107 @@
#pragma once
#include "../decoder.h"
#include <signal_path/vfo_manager.h>
#include <utils/optionlist.h>
#include <gui/widgets/symbol_diagram.h>
#include <gui/style.h>
#include <dsp/sink/handler_sink.h>
#include "dsp.h"
#include "pocsag.h"
const char* msgTypes[] = {
"Numeric",
"Unknown (0b01)",
"Unknown (0b10)",
"Alphanumeric",
};
class POCSAGDecoder : public Decoder {
public:
POCSAGDecoder() : diag(0.6, 2400) {
POCSAGDecoder(const std::string& name, VFOManager::VFO* vfo) : diag(0.6, 2400) {
this->name = name;
this->vfo = vfo;
// Define baudrate options
baudrates.define(512, "512 Baud", 512);
baudrates.define(1200, "1200 Baud", 1200);
baudrates.define(2400, "2400 Baud", 2400);
// Init DSP
vfo->setBandwidthLimits(12500, 12500, true);
vfo->setSampleRate(24000, 12500);
dsp.init(vfo->output, 24000, 2400);
reshape.init(&dsp.soft, 2400.0, (2400 / 30.0) - 2400.0);
dataHandler.init(&dsp.out, _dataHandler, this);
diagHandler.init(&reshape.out, _diagHandler, this);
// Init decoder
decoder.onMessage.bind(&POCSAGDecoder::messageHandler, this);
}
~POCSAGDecoder() {
stop();
}
void showMenu() {
ImGui::LeftLabel("Baudrate");
ImGui::FillWidth();
if (ImGui::Combo(("##pager_decoder_proto_" + name).c_str(), &brId, baudrates.txt)) {
if (ImGui::Combo(("##pager_decoder_pocsag_br_" + name).c_str(), &brId, baudrates.txt)) {
// TODO
}
ImGui::FillWidth();
diag.draw();
}
void setVFO(VFOManager::VFO* vfo) {
this->vfo = vfo;
vfo->setBandwidthLimits(12500, 12500, true);
vfo->setSampleRate(24000, 12500);
dsp.setInput(vfo->output);
}
void start() {
flog::debug("POCSAG start");
dsp.start();
reshape.start();
dataHandler.start();
diagHandler.start();
}
void stop() {
flog::debug("POCSAG stop");
dsp.stop();
reshape.stop();
dataHandler.stop();
diagHandler.stop();
}
private:
static void _dataHandler(uint8_t* data, int count, void* ctx) {
POCSAGDecoder* _this = (POCSAGDecoder*)ctx;
_this->decoder.process(data, count);
}
static void _diagHandler(float* data, int count, void* ctx) {
POCSAGDecoder* _this = (POCSAGDecoder*)ctx;
float* buf = _this->diag.acquireBuffer();
memcpy(buf, data, count * sizeof(float));
_this->diag.releaseBuffer();
}
void messageHandler(pocsag::Address addr, pocsag::MessageType type, const std::string& msg) {
flog::debug("[{}]: '{}'", (uint32_t)addr, msg);
}
std::string name;
VFOManager::VFO* vfo;
POCSAGDSP dsp;
dsp::buffer::Reshaper<float> reshape;
dsp::sink::Handler<uint8_t> dataHandler;
dsp::sink::Handler<float> diagHandler;
pocsag::Decoder decoder;
ImGui::SymbolDiagram diag;

View File

@ -11,7 +11,7 @@
#include <dsp/digital/binary_slicer.h>
#include <dsp/routing/doubler.h>
class POCSAGDSP : dsp::Processor<dsp::complex_t, uint8_t> {
class POCSAGDSP : public dsp::Processor<dsp::complex_t, uint8_t> {
using base_type = dsp::Processor<dsp::complex_t, uint8_t>;
public:
POCSAGDSP() {}