2016-08-23 06:45:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __POCSAG_APP_H__
|
|
|
|
#define __POCSAG_APP_H__
|
|
|
|
|
|
|
|
#include "ui_widget.hpp"
|
2023-06-18 19:11:04 +00:00
|
|
|
#include "ui_freq_field.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
#include "ui_rssi.hpp"
|
2023-08-25 21:45:02 +00:00
|
|
|
#include "ui_styles.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
|
2022-04-15 12:43:44 +00:00
|
|
|
#include "app_settings.hpp"
|
2023-08-25 21:45:02 +00:00
|
|
|
#include "log_file.hpp"
|
2017-02-05 20:57:20 +00:00
|
|
|
#include "pocsag.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
#include "pocsag_packet.hpp"
|
2023-08-25 21:45:02 +00:00
|
|
|
#include "radio_state.hpp"
|
|
|
|
|
|
|
|
#include <functional>
|
2016-08-23 06:45:33 +00:00
|
|
|
|
|
|
|
class POCSAGLogger {
|
2023-05-18 20:16:05 +00:00
|
|
|
public:
|
|
|
|
Optional<File::Error> append(const std::string& filename) {
|
|
|
|
return log_file.append(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void log_raw_data(const pocsag::POCSAGPacket& packet, const uint32_t frequency);
|
|
|
|
void log_decoded(const pocsag::POCSAGPacket& packet, const std::string text);
|
|
|
|
|
|
|
|
private:
|
|
|
|
LogFile log_file{};
|
2016-08-23 06:45:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
struct POCSAGSettings {
|
|
|
|
bool enable_small_font = false;
|
|
|
|
bool enable_logging = false;
|
|
|
|
bool enable_raw_log = false;
|
|
|
|
bool enable_ignore = false;
|
|
|
|
uint32_t address_to_ignore = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class POCSAGSettingsView : public View {
|
|
|
|
public:
|
|
|
|
POCSAGSettingsView(NavigationView& nav, POCSAGSettings& settings);
|
|
|
|
|
|
|
|
std::string title() const override { return "POCSAG Config"; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
POCSAGSettings& settings_;
|
|
|
|
|
|
|
|
Checkbox check_log{
|
|
|
|
{2 * 8, 2 * 16},
|
|
|
|
10,
|
|
|
|
"Enable Log",
|
|
|
|
false};
|
|
|
|
|
|
|
|
Checkbox check_log_raw{
|
|
|
|
{2 * 8, 4 * 16},
|
|
|
|
12,
|
|
|
|
"Log Raw Data",
|
|
|
|
false};
|
|
|
|
|
|
|
|
Checkbox check_small_font{
|
|
|
|
{2 * 8, 6 * 16},
|
|
|
|
4,
|
|
|
|
"Use Small Font",
|
|
|
|
false};
|
|
|
|
|
|
|
|
Checkbox check_ignore{
|
|
|
|
{2 * 8, 8 * 16},
|
|
|
|
22,
|
|
|
|
"Enable Ignored Address",
|
|
|
|
false};
|
|
|
|
|
|
|
|
NumberField field_ignore{
|
|
|
|
{7 * 8, 9 * 16 + 8},
|
|
|
|
7,
|
|
|
|
{0, 9999999},
|
|
|
|
1,
|
|
|
|
'0'};
|
|
|
|
|
|
|
|
Button button_save{
|
|
|
|
{12 * 8, 16 * 16, 10 * 8, 2 * 16},
|
|
|
|
"Save"};
|
|
|
|
};
|
|
|
|
|
2016-08-23 06:45:33 +00:00
|
|
|
class POCSAGAppView : public View {
|
2023-05-18 20:16:05 +00:00
|
|
|
public:
|
|
|
|
POCSAGAppView(NavigationView& nav);
|
|
|
|
~POCSAGAppView();
|
|
|
|
|
|
|
|
std::string title() const override { return "POCSAG RX"; };
|
2023-06-11 18:47:13 +00:00
|
|
|
void focus() override;
|
2023-05-18 20:16:05 +00:00
|
|
|
|
|
|
|
private:
|
2023-08-25 21:45:02 +00:00
|
|
|
static constexpr uint32_t initial_target_frequency = 466'175'000;
|
|
|
|
bool logging() const { return settings_.enable_logging; };
|
|
|
|
bool logging_raw() const { return settings_.enable_raw_log; };
|
|
|
|
bool ignore() const { return settings_.enable_ignore; };
|
2023-06-04 19:56:46 +00:00
|
|
|
|
2023-06-18 19:11:04 +00:00
|
|
|
NavigationView& nav_;
|
2023-08-25 21:45:02 +00:00
|
|
|
RxRadioState radio_state_{
|
|
|
|
12'500, // POCSAG is FSK +/- 4.5MHz, 12k5 is a good filter.
|
|
|
|
3'072'000, // Match baseband_fs in proc_pocsag.
|
|
|
|
};
|
|
|
|
|
2023-08-18 19:35:41 +00:00
|
|
|
// Settings
|
2023-08-25 21:45:02 +00:00
|
|
|
POCSAGSettings settings_{};
|
|
|
|
app_settings::SettingsManager app_settings_{
|
2023-08-19 16:02:26 +00:00
|
|
|
"rx_pocsag"sv,
|
|
|
|
app_settings::Mode::RX,
|
2023-08-25 21:45:02 +00:00
|
|
|
{
|
|
|
|
{"small_font"sv, &settings_.enable_small_font},
|
|
|
|
{"enable_logging"sv, &settings_.enable_logging},
|
|
|
|
{"enable_ignore"sv, &settings_.enable_ignore},
|
|
|
|
}};
|
|
|
|
|
|
|
|
void refresh_ui();
|
|
|
|
void on_packet(const POCSAGPacketMessage* message);
|
|
|
|
void on_stats(const POCSAGStatsMessage* stats);
|
2023-05-18 20:16:05 +00:00
|
|
|
|
|
|
|
uint32_t last_address = 0xFFFFFFFF;
|
|
|
|
pocsag::POCSAGState pocsag_state{};
|
2023-08-25 21:45:02 +00:00
|
|
|
POCSAGLogger logger{};
|
|
|
|
bool packet_toggle = false;
|
2023-05-18 20:16:05 +00:00
|
|
|
|
|
|
|
RFAmpField field_rf_amp{
|
|
|
|
{13 * 8, 0 * 16}};
|
|
|
|
LNAGainField field_lna{
|
|
|
|
{15 * 8, 0 * 16}};
|
|
|
|
VGAGainField field_vga{
|
|
|
|
{18 * 8, 0 * 16}};
|
|
|
|
RSSI rssi{
|
2023-08-25 21:45:02 +00:00
|
|
|
{21 * 8, 3, 6 * 8, 4}};
|
2023-05-18 20:16:05 +00:00
|
|
|
Audio audio{
|
2023-08-25 21:45:02 +00:00
|
|
|
{21 * 8, 8, 6 * 8, 4}};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-06-18 19:11:04 +00:00
|
|
|
RxFrequencyField field_frequency{
|
2023-05-18 20:16:05 +00:00
|
|
|
{0 * 8, 0 * 8},
|
2023-06-18 19:11:04 +00:00
|
|
|
nav_};
|
2023-06-04 19:56:46 +00:00
|
|
|
AudioVolumeField field_volume{
|
|
|
|
{28 * 8, 0 * 16}};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
Image image_status{
|
|
|
|
{7 * 8, 1 * 16 + 2, 16, 16},
|
|
|
|
&bitmap_icon_pocsag,
|
|
|
|
Color::white(),
|
|
|
|
Color::black()};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
Button button_ignore_last{
|
|
|
|
{10 * 8, 1 * 16, 12 * 8, 20},
|
|
|
|
"Ignore Last"};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
Button button_config{
|
|
|
|
{22 * 8, 1 * 16, 8 * 8, 20},
|
|
|
|
"Config"};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
Console console{
|
|
|
|
{0, 2 * 16 + 6, screen_width, screen_height - 56}};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_packet{
|
|
|
|
Message::ID::POCSAGPacket,
|
|
|
|
[this](Message* const p) {
|
|
|
|
const auto message = static_cast<const POCSAGPacketMessage*>(p);
|
|
|
|
this->on_packet(message);
|
|
|
|
}};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_stats{
|
|
|
|
Message::ID::POCSAGStats,
|
|
|
|
[this](Message* const p) {
|
|
|
|
const auto stats = static_cast<const POCSAGStatsMessage*>(p);
|
|
|
|
this->on_stats(stats);
|
|
|
|
}};
|
2016-08-23 06:45:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
|
|
|
|
2023-05-18 20:16:05 +00:00
|
|
|
#endif /*__POCSAG_APP_H__*/
|