mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-08 18:58:34 -05:00
Remove proc pocsag & add keep/drop filtering (#1453)
* Remove proc_pocsag from build, use new proc in app * Add support for keep/drop filtering
This commit is contained in:
parent
fca373d936
commit
070eb4003e
@ -54,35 +54,32 @@ POCSAGSettingsView::POCSAGSettingsView(
|
|||||||
POCSAGSettings& settings)
|
POCSAGSettings& settings)
|
||||||
: settings_{settings} {
|
: settings_{settings} {
|
||||||
add_children(
|
add_children(
|
||||||
{&check_beta,
|
{&labels,
|
||||||
&check_log,
|
&check_log,
|
||||||
&check_log_raw,
|
&check_log_raw,
|
||||||
&check_small_font,
|
&check_small_font,
|
||||||
&check_hide_bad,
|
&check_hide_bad,
|
||||||
&check_hide_addr_only,
|
&check_hide_addr_only,
|
||||||
&check_ignore,
|
&opt_filter_mode,
|
||||||
&field_ignore,
|
&field_filter_address,
|
||||||
&button_save});
|
&button_save});
|
||||||
|
|
||||||
check_beta.set_value(settings_.use_new_proc);
|
|
||||||
check_log.set_value(settings_.enable_logging);
|
check_log.set_value(settings_.enable_logging);
|
||||||
check_log_raw.set_value(settings_.enable_raw_log);
|
check_log_raw.set_value(settings_.enable_raw_log);
|
||||||
check_small_font.set_value(settings_.enable_small_font);
|
check_small_font.set_value(settings_.enable_small_font);
|
||||||
check_hide_bad.set_value(settings_.hide_bad_data);
|
check_hide_bad.set_value(settings_.hide_bad_data);
|
||||||
check_hide_addr_only.set_value(settings_.hide_addr_only);
|
check_hide_addr_only.set_value(settings_.hide_addr_only);
|
||||||
check_ignore.set_value(settings_.enable_ignore);
|
opt_filter_mode.set_by_value(settings_.filter_mode);
|
||||||
|
field_filter_address.set_value(settings_.filter_address);
|
||||||
field_ignore.set_value(settings_.address_to_ignore);
|
|
||||||
|
|
||||||
button_save.on_select = [this, &nav](Button&) {
|
button_save.on_select = [this, &nav](Button&) {
|
||||||
settings_.use_new_proc = check_beta.value();
|
|
||||||
settings_.enable_logging = check_log.value();
|
settings_.enable_logging = check_log.value();
|
||||||
settings_.enable_raw_log = check_log_raw.value();
|
settings_.enable_raw_log = check_log_raw.value();
|
||||||
settings_.enable_small_font = check_small_font.value();
|
settings_.enable_small_font = check_small_font.value();
|
||||||
settings_.hide_bad_data = check_hide_bad.value();
|
settings_.hide_bad_data = check_hide_bad.value();
|
||||||
settings_.hide_addr_only = check_hide_addr_only.value();
|
settings_.hide_addr_only = check_hide_addr_only.value();
|
||||||
settings_.enable_ignore = check_ignore.value();
|
settings_.filter_mode = opt_filter_mode.selected_index_value();
|
||||||
settings_.address_to_ignore = field_ignore.to_integer();
|
settings_.filter_address = field_filter_address.to_integer();
|
||||||
|
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
@ -90,10 +87,7 @@ POCSAGSettingsView::POCSAGSettingsView(
|
|||||||
|
|
||||||
POCSAGAppView::POCSAGAppView(NavigationView& nav)
|
POCSAGAppView::POCSAGAppView(NavigationView& nav)
|
||||||
: nav_{nav} {
|
: nav_{nav} {
|
||||||
if (settings_.use_new_proc)
|
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_pocsag2);
|
baseband::run_image(portapack::spi_flash::image_tag_pocsag2);
|
||||||
else
|
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_pocsag);
|
|
||||||
|
|
||||||
add_children(
|
add_children(
|
||||||
{&rssi,
|
{&rssi,
|
||||||
@ -109,14 +103,16 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
|
|||||||
&widget_baud,
|
&widget_baud,
|
||||||
&widget_bits,
|
&widget_bits,
|
||||||
&widget_frames,
|
&widget_frames,
|
||||||
&button_ignore_last,
|
&button_filter_last,
|
||||||
&button_config,
|
&button_config,
|
||||||
&console});
|
&console});
|
||||||
|
|
||||||
// No app settings, use fallbacks from pmem.
|
// No app settings, use fallbacks from pmem.
|
||||||
if (!app_settings_.loaded()) {
|
if (!app_settings_.loaded()) {
|
||||||
settings_.address_to_ignore = pmem::pocsag_ignore_address();
|
settings_.filter_address = pmem::pocsag_ignore_address();
|
||||||
settings_.enable_ignore = settings_.address_to_ignore > 0;
|
settings_.filter_mode = (settings_.filter_address == 0)
|
||||||
|
? FILTER_NONE
|
||||||
|
: FILTER_DROP;
|
||||||
}
|
}
|
||||||
if (!app_settings_.radio_loaded()) {
|
if (!app_settings_.radio_loaded()) {
|
||||||
field_frequency.set_value(initial_target_frequency);
|
field_frequency.set_value(initial_target_frequency);
|
||||||
@ -129,9 +125,11 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
|
|||||||
receiver_model.set_squelch_level(v);
|
receiver_model.set_squelch_level(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
button_ignore_last.on_select = [this](Button&) {
|
button_filter_last.on_select = [this](Button&) {
|
||||||
settings_.enable_ignore = true;
|
if (settings_.filter_mode == FILTER_NONE)
|
||||||
settings_.address_to_ignore = last_address;
|
settings_.filter_mode = FILTER_DROP;
|
||||||
|
settings_.filter_address = last_address;
|
||||||
|
refresh_ui();
|
||||||
};
|
};
|
||||||
|
|
||||||
button_config.on_select = [this](Button&) {
|
button_config.on_select = [this](Button&) {
|
||||||
@ -155,15 +153,48 @@ POCSAGAppView::~POCSAGAppView() {
|
|||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
|
|
||||||
// Save pmem settings.
|
// Save pmem settings.
|
||||||
pmem::set_pocsag_ignore_address(settings_.address_to_ignore);
|
pmem::set_pocsag_ignore_address(settings_.filter_address);
|
||||||
pmem::set_pocsag_last_address(last_address); // For POCSAG TX.
|
pmem::set_pocsag_last_address(last_address); // For POCSAG TX.
|
||||||
}
|
}
|
||||||
|
|
||||||
void POCSAGAppView::refresh_ui() {
|
void POCSAGAppView::refresh_ui() {
|
||||||
|
// Set console font style.
|
||||||
console.set_style(
|
console.set_style(
|
||||||
settings_.enable_small_font
|
settings_.enable_small_font
|
||||||
? &Styles::white_small
|
? &Styles::white_small
|
||||||
: &Styles::white);
|
: &Styles::white);
|
||||||
|
|
||||||
|
// Update filter button text.
|
||||||
|
std::string btn_text = "Filter Last";
|
||||||
|
switch (settings_.filter_mode) {
|
||||||
|
case FILTER_DROP:
|
||||||
|
btn_text = "Ignore Last";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FILTER_KEEP:
|
||||||
|
btn_text = "Keep Last";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FILTER_NONE:
|
||||||
|
default:
|
||||||
|
btn_text = "Filter Last";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
button_filter_last.set_text(btn_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool POCSAGAppView::ignore_address(uint32_t address) const {
|
||||||
|
switch (settings_.filter_mode) {
|
||||||
|
case FILTER_DROP:
|
||||||
|
return address == settings_.filter_address;
|
||||||
|
|
||||||
|
case FILTER_KEEP:
|
||||||
|
return address != settings_.filter_address;
|
||||||
|
|
||||||
|
case FILTER_NONE:
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void POCSAGAppView::handle_decoded(Timestamp timestamp, const std::string& prefix) {
|
void POCSAGAppView::handle_decoded(Timestamp timestamp, const std::string& prefix) {
|
||||||
@ -176,8 +207,8 @@ void POCSAGAppView::handle_decoded(Timestamp timestamp, const std::string& prefi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignored address.
|
// Ignore address? TODO: could filter earlier.
|
||||||
if (ignore() && pocsag_state.address == settings_.address_to_ignore) {
|
if (ignore_address(pocsag_state.address)) {
|
||||||
console.write("\n" STR_COLOR_CYAN + prefix + " Ignored: " + to_string_dec_uint(pocsag_state.address));
|
console.write("\n" STR_COLOR_CYAN + prefix + " Ignored: " + to_string_dec_uint(pocsag_state.address));
|
||||||
last_address = pocsag_state.address;
|
last_address = pocsag_state.address;
|
||||||
return;
|
return;
|
||||||
|
@ -114,15 +114,20 @@ class FrameIndicator : public Widget {
|
|||||||
bool has_sync_ = false;
|
bool has_sync_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum POCSAGFilter : uint8_t {
|
||||||
|
FILTER_NONE,
|
||||||
|
FILTER_DROP,
|
||||||
|
FILTER_KEEP
|
||||||
|
};
|
||||||
|
|
||||||
struct POCSAGSettings {
|
struct POCSAGSettings {
|
||||||
bool enable_small_font = false;
|
bool enable_small_font = false;
|
||||||
bool enable_logging = false;
|
bool enable_logging = false;
|
||||||
bool enable_raw_log = false;
|
bool enable_raw_log = false;
|
||||||
bool enable_ignore = false;
|
|
||||||
bool hide_bad_data = false;
|
bool hide_bad_data = false;
|
||||||
bool hide_addr_only = false;
|
bool hide_addr_only = false;
|
||||||
uint32_t address_to_ignore = 0;
|
uint8_t filter_mode = false;
|
||||||
bool use_new_proc = false;
|
uint32_t filter_address = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class POCSAGSettingsView : public View {
|
class POCSAGSettingsView : public View {
|
||||||
@ -135,11 +140,10 @@ class POCSAGSettingsView : public View {
|
|||||||
private:
|
private:
|
||||||
POCSAGSettings& settings_;
|
POCSAGSettings& settings_;
|
||||||
|
|
||||||
Checkbox check_beta{
|
Labels labels{
|
||||||
{0 * 8 + 2, 18 * 16 - 4},
|
{{2 * 8, 12 * 16}, "Filter Mode:", Color::light_grey()},
|
||||||
6,
|
{{2 * 8, 13 * 16}, "Filter Addr:", Color::light_grey()},
|
||||||
"Beta",
|
};
|
||||||
true /*small*/};
|
|
||||||
|
|
||||||
Checkbox check_log{
|
Checkbox check_log{
|
||||||
{2 * 8, 2 * 16},
|
{2 * 8, 2 * 16},
|
||||||
@ -166,13 +170,15 @@ class POCSAGSettingsView : public View {
|
|||||||
22,
|
22,
|
||||||
"Hide Addr Only"};
|
"Hide Addr Only"};
|
||||||
|
|
||||||
Checkbox check_ignore{
|
OptionsField opt_filter_mode{
|
||||||
{2 * 8, 12 * 16},
|
{15 * 8, 12 * 16},
|
||||||
22,
|
4,
|
||||||
"Enable Ignored Address"};
|
{{"None", FILTER_NONE},
|
||||||
|
{"Drop", FILTER_DROP},
|
||||||
|
{"Keep", FILTER_KEEP}}};
|
||||||
|
|
||||||
SymField field_ignore{
|
SymField field_filter_address{
|
||||||
{7 * 8, 13 * 16 + 8},
|
{15 * 8, 13 * 16},
|
||||||
7,
|
7,
|
||||||
SymField::Type::Dec,
|
SymField::Type::Dec,
|
||||||
true /*explicit_edit*/};
|
true /*explicit_edit*/};
|
||||||
@ -194,7 +200,6 @@ class POCSAGAppView : public View {
|
|||||||
static constexpr uint32_t initial_target_frequency = 466'175'000;
|
static constexpr uint32_t initial_target_frequency = 466'175'000;
|
||||||
bool logging() const { return settings_.enable_logging; };
|
bool logging() const { return settings_.enable_logging; };
|
||||||
bool logging_raw() const { return settings_.enable_raw_log; };
|
bool logging_raw() const { return settings_.enable_raw_log; };
|
||||||
bool ignore() const { return settings_.enable_ignore; };
|
|
||||||
bool hide_bad_data() const { return settings_.hide_bad_data; };
|
bool hide_bad_data() const { return settings_.hide_bad_data; };
|
||||||
bool hide_addr_only() const { return settings_.hide_addr_only; };
|
bool hide_addr_only() const { return settings_.hide_addr_only; };
|
||||||
|
|
||||||
@ -210,14 +215,14 @@ class POCSAGAppView : public View {
|
|||||||
{"small_font"sv, &settings_.enable_small_font},
|
{"small_font"sv, &settings_.enable_small_font},
|
||||||
{"enable_logging"sv, &settings_.enable_logging},
|
{"enable_logging"sv, &settings_.enable_logging},
|
||||||
{"enable_raw_log"sv, &settings_.enable_raw_log},
|
{"enable_raw_log"sv, &settings_.enable_raw_log},
|
||||||
{"enable_ignore"sv, &settings_.enable_ignore},
|
{"filter_mode"sv, &settings_.filter_mode},
|
||||||
{"address_to_ignore"sv, &settings_.address_to_ignore},
|
{"filter_address"sv, &settings_.filter_address},
|
||||||
{"hide_bad_data"sv, &settings_.hide_bad_data},
|
{"hide_bad_data"sv, &settings_.hide_bad_data},
|
||||||
{"hide_addr_only"sv, &settings_.hide_addr_only},
|
{"hide_addr_only"sv, &settings_.hide_addr_only},
|
||||||
{"use_new_proc"sv, &settings_.use_new_proc},
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
void refresh_ui();
|
void refresh_ui();
|
||||||
|
bool ignore_address(uint32_t address) const;
|
||||||
void handle_decoded(Timestamp timestamp, const std::string& prefix);
|
void handle_decoded(Timestamp timestamp, const std::string& prefix);
|
||||||
void on_packet(const POCSAGPacketMessage* message);
|
void on_packet(const POCSAGPacketMessage* message);
|
||||||
void on_stats(const POCSAGStatsMessage* stats);
|
void on_stats(const POCSAGStatsMessage* stats);
|
||||||
@ -273,9 +278,9 @@ class POCSAGAppView : public View {
|
|||||||
BaudIndicator widget_baud{
|
BaudIndicator widget_baud{
|
||||||
{8 * 9 + 1, 1 * 16 + 2}};
|
{8 * 9 + 1, 1 * 16 + 2}};
|
||||||
|
|
||||||
Button button_ignore_last{
|
Button button_filter_last{
|
||||||
{10 * 8, 1 * 16, 12 * 8, 20},
|
{10 * 8, 1 * 16, 12 * 8, 20},
|
||||||
"Ignore Last"};
|
"Filter Last"};
|
||||||
|
|
||||||
Button button_config{
|
Button button_config{
|
||||||
{22 * 8, 1 * 16, 8 * 8, 20},
|
{22 * 8, 1 * 16, 8 * 8, 20},
|
||||||
|
@ -437,12 +437,12 @@ set(MODE_CPPSRC
|
|||||||
)
|
)
|
||||||
DeclareTargets(POOK ook)
|
DeclareTargets(POOK ook)
|
||||||
|
|
||||||
### POCSAG RX
|
#### POCSAG RX
|
||||||
|
#
|
||||||
set(MODE_CPPSRC
|
#set(MODE_CPPSRC
|
||||||
proc_pocsag.cpp
|
# proc_pocsag.cpp
|
||||||
)
|
#)
|
||||||
DeclareTargets(PPOC pocsag)
|
#DeclareTargets(PPOC pocsag)
|
||||||
|
|
||||||
### POCSAG2 RX
|
### POCSAG2 RX
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user