Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Precise committed Feb 4, 2024
2 parents 239a198 + bddfe53 commit 8860f36
Show file tree
Hide file tree
Showing 15 changed files with 957 additions and 160 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ option(OPT_BUILD_WEATHER_SAT_DECODER "Build the HRPT decoder module (no dependen
# Misc
option(OPT_BUILD_DISCORD_PRESENCE "Build the Discord Rich Presence module" ON)
option(OPT_BUILD_FREQUENCY_MANAGER "Build the Frequency Manager module" ON)
option(OPT_BUILD_IQ_EXPORTER "Build the IQ Exporter module" ON)
option(OPT_BUILD_RECORDER "Audio and baseband recorder" ON)
option(OPT_BUILD_RIGCTL_CLIENT "Rigctl client to make SDR++ act as a panadapter" ON)
option(OPT_BUILD_RIGCTL_SERVER "Rigctl backend for controlling SDR++ with software like gpredict" ON)
Expand Down Expand Up @@ -247,7 +248,6 @@ if (OPT_BUILD_WEATHER_SAT_DECODER)
add_subdirectory("decoder_modules/weather_sat_decoder")
endif (OPT_BUILD_WEATHER_SAT_DECODER)

add_subdirectory("decoder_modules/pager_decoder")

# Misc
if (OPT_BUILD_DISCORD_PRESENCE)
Expand All @@ -258,6 +258,10 @@ if (OPT_BUILD_FREQUENCY_MANAGER)
add_subdirectory("misc_modules/frequency_manager")
endif (OPT_BUILD_FREQUENCY_MANAGER)

if (OPT_BUILD_IQ_EXPORTER)
add_subdirectory("misc_modules/iq_exporter")
endif (OPT_BUILD_IQ_EXPORTER)

if (OPT_BUILD_RECORDER)
add_subdirectory("misc_modules/recorder")
endif (OPT_BUILD_RECORDER)
Expand Down
11 changes: 10 additions & 1 deletion core/src/utils/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,16 @@ namespace net {
}

int Socket::send(const uint8_t* data, size_t len, const Address* dest) {
return sendto(sock, (const char*)data, len, 0, (sockaddr*)(dest ? &dest->addr : (raddr ? &raddr->addr : NULL)), sizeof(sockaddr_in));
// Send data
int err = sendto(sock, (const char*)data, len, 0, (sockaddr*)(dest ? &dest->addr : (raddr ? &raddr->addr : NULL)), sizeof(sockaddr_in));

// On error, close socket
if (err <= 0 && !WOULD_BLOCK) {
close();
return err;
}

return err;
}

int Socket::sendstr(const std::string& str, const Address* dest) {
Expand Down
9 changes: 6 additions & 3 deletions decoder_modules/pager_decoder/src/decoder.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#pragma once
#include <signal_path/vfo_manager.h>

class Decoder {
public:

virtual void showMenu();

virtual ~Decoder() {}
virtual void showMenu() {};
virtual void setVFO(VFOManager::VFO* vfo) = 0;
virtual void start() = 0;
virtual void stop() = 0;
};
96 changes: 96 additions & 0 deletions decoder_modules/pager_decoder/src/flex/decoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#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 "flex.h"

class FLEXDecoder : public Decoder {
dsp::stream<float> dummy1;
dsp::stream<uint8_t> dummy2;
public:
FLEXDecoder(const std::string& name, VFOManager::VFO* vfo) : diag(0.6, 1600) {
this->name = name;
this->vfo = vfo;

// Define baudrate options
baudrates.define(1600, "1600 Baud", 1600);
baudrates.define(3200, "3200 Baud", 3200);
baudrates.define(6400, "6400 Baud", 6400);

// Init DSP
vfo->setBandwidthLimits(12500, 12500, true);
vfo->setSampleRate(16000, 12500);
reshape.init(&dummy1, 1600.0, (1600 / 30.0) - 1600.0);
dataHandler.init(&dummy2, _dataHandler, this);
diagHandler.init(&reshape.out, _diagHandler, this);
}

~FLEXDecoder() {
stop();
}

void showMenu() {
ImGui::LeftLabel("Baudrate");
ImGui::FillWidth();
if (ImGui::Combo(("##pager_decoder_flex_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("FLEX start");
// dsp.start();
reshape.start();
dataHandler.start();
diagHandler.start();
}

void stop() {
flog::debug("FLEX stop");
// dsp.stop();
reshape.stop();
dataHandler.stop();
diagHandler.stop();
}

private:
static void _dataHandler(uint8_t* data, int count, void* ctx) {
FLEXDecoder* _this = (FLEXDecoder*)ctx;
// _this->decoder.process(data, count);
}

static void _diagHandler(float* data, int count, void* ctx) {
FLEXDecoder* _this = (FLEXDecoder*)ctx;
float* buf = _this->diag.acquireBuffer();
memcpy(buf, data, count * sizeof(float));
_this->diag.releaseBuffer();
}

std::string name;

VFOManager::VFO* vfo;
dsp::buffer::Reshaper<float> reshape;
dsp::sink::Handler<uint8_t> dataHandler;
dsp::sink::Handler<float> diagHandler;

flex::Decoder decoder;

ImGui::SymbolDiagram diag;

int brId = 0;

OptionList<int, int> baudrates;
};
5 changes: 5 additions & 0 deletions decoder_modules/pager_decoder/src/flex/flex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "flex.h"

namespace flex {
// TODO
}
11 changes: 11 additions & 0 deletions decoder_modules/pager_decoder/src/flex/flex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

namespace flex {
class Decoder {
public:
// TODO

private:
// TODO
};
}
Loading

0 comments on commit 8860f36

Please sign in to comment.