Merge pull request #426 from heurist1/update_pocsag_decoder

Update pocsag decoder
This commit is contained in:
Erwin Ried
2021-11-24 12:32:33 +01:00
committed by GitHub
10 changed files with 852 additions and 200 deletions

View File

@@ -30,10 +30,11 @@ using namespace pocsag;
#include "string_format.hpp"
#include "utility.hpp"
#include "audio.hpp"
void POCSAGLogger::log_raw_data(const pocsag::POCSAGPacket& packet, const uint32_t frequency) {
std::string entry = "Raw: F:" + to_string_dec_uint(frequency) + "Hz " +
pocsag::bitrate_str(packet.bitrate()) + " Codewords:";
to_string_dec_uint(packet.bitrate()) + " Codewords:";
// Raw hex dump of all the codewords
for (size_t c = 0; c < 16; c++)
@@ -64,13 +65,13 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
add_children({
&rssi,
&channel,
&audio,
&field_rf_amp,
&field_lna,
&field_vga,
&field_frequency,
&options_bitrate,
&options_phase,
&check_log,
&field_volume,
&check_ignore,
&sym_ignore,
&console
@@ -99,14 +100,11 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
logging = v;
};
options_bitrate.on_change = [this](size_t, OptionsField::value_t v) {
on_config_changed(v, options_phase.selected_index_value());
};
options_bitrate.set_selected_index(1); // 1200bps
options_phase.on_change = [this](size_t, OptionsField::value_t v) {
on_config_changed(options_bitrate.selected_index_value(),v);
field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99);
field_volume.on_change = [this](int32_t v) {
this->on_headphone_volume_changed(v);
};
check_ignore.set_value(ignore);
check_ignore.on_select = [this](Checkbox&, bool v) {
ignore = v;
@@ -121,9 +119,16 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
logger = std::make_unique<POCSAGLogger>();
if (logger)
logger->append("pocsag.txt");
audio::output::start();
audio::output::unmute();
baseband::set_pocsag();
}
POCSAGAppView::~POCSAGAppView() {
audio::output::stop();
// Save ignored address
persistent_memory::set_pocsag_ignore_address(sym_ignore.value_dec_u32());
@@ -135,6 +140,12 @@ void POCSAGAppView::focus() {
field_frequency.focus();
}
void POCSAGAppView::on_headphone_volume_changed(int32_t v) {
const auto new_volume = volume_t::decibel(v - 99) + audio::headphone::volume_range().max;
receiver_model.set_headphone_volume(new_volume);
}
// Useless ?
void POCSAGAppView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect);
@@ -154,11 +165,17 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
// " Ignored address " + to_string_dec_uint(pocsag_state.address));
return;
}
// Too many errors for reliable decode
if ((ignore) && (pocsag_state.errors >= 3)) {
return;
}
std::string console_info;
const uint32_t roundVal = 50;
const uint32_t bitrate = roundVal * ((message->packet.bitrate() + (roundVal/2))/roundVal);
console_info = "\n" + to_string_datetime(message->packet.timestamp(), HM);
console_info += " " + pocsag::bitrate_str(message->packet.bitrate());
console_info += " " + to_string_dec_uint(bitrate);
console_info += " ADDR:" + to_string_dec_uint(pocsag_state.address);
console_info += " F" + to_string_dec_uint(pocsag_state.function);
@@ -201,10 +218,6 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
logger->log_raw_data(message->packet, target_frequency());
}
void POCSAGAppView::on_config_changed(const uint32_t new_bitrate, bool new_phase) {
baseband::set_pocsag(pocsag_bitrates[new_bitrate], new_phase);
}
void POCSAGAppView::set_target_frequency(const uint32_t new_value) {
target_frequency_ = new_value;
receiver_model.set_tuning_frequency(new_value);

View File

@@ -61,7 +61,7 @@ private:
static constexpr uint32_t initial_target_frequency = 466175000;
bool logging { true };
bool ignore { false };
bool ignore { true };
uint32_t last_address = 0xFFFFFFFF;
pocsag::POCSAGState pocsag_state { };
@@ -80,49 +80,41 @@ private:
Channel channel {
{ 21 * 8, 5, 6 * 8, 4 },
};
Audio audio{
{ 21 * 8, 10, 6 * 8, 4 },
};
FrequencyField field_frequency {
{ 0 * 8, 0 * 8 },
};
OptionsField options_bitrate {
{ 12 * 8, 21 },
7,
{
{ "512bps ", 0 },
{ "1200bps", 1 },
{ "2400bps", 2 },
{ "3200bps", 3 }
}
};
OptionsField options_phase {
{ 6 * 8, 21 },
1,
{
{ "P", 0 },
{ "N", 1 },
}
};
Checkbox check_log {
{ 22 * 8, 21 },
{ 24 * 8, 21 },
3,
"LOG",
true
};
NumberField field_volume{
{ 28 * 8, 0 * 16 },
2,
{ 0, 99 },
1,
' ',
};
Checkbox check_ignore {
{ 1 * 8, 40 },
15,
"Ignore address:",
{ 1 * 8, 21 },
12,
"Ignore addr:",
true
};
SymField sym_ignore {
{ 19 * 8, 40 },
{ 16 * 8, 21 },
7,
SymField::SYMFIELD_DEC
};
Console console {
{ 0, 4 * 16, 240, 240 }
{ 0, 3 * 16, 240, 256 }
};
std::unique_ptr<POCSAGLogger> logger { };
@@ -133,7 +125,7 @@ private:
void on_packet(const POCSAGPacketMessage * message);
void on_config_changed(const uint32_t new_bitrate, const bool phase);
void on_headphone_volume_changed(int32_t v);
uint32_t target_frequency() const;
void set_target_frequency(const uint32_t new_value);