mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-19 22:24:02 +00:00
cf44076a34
Baseband (proc_flex.cpp): - Fix numeric vector field width (3-bit n+1 for types 3,4,7) - Fix capcode range classification for long address components - Add long address decode (Set 1-2, 1-3/1-4, 2-3) - Add vector checksum validation (4-bit nibble sum) - Add tone-only boundary detection via vector pre-scan - Add idle phase detection (skip all-zeros/all-ones before BCH) - Skip spurious TON for capcode 1 (BCH-corrected idle artifact) - Add BIW parsing: SSID1/SSID2, DATE, TIME, TZ, SYSMSG, CHAN - Add alpha fragment flags: frag, more_frag, seq, new, maildrop, sig - Add secure message enc= field (alpha/binary/separate) - Add numbered numeric flags: seq, new, fmt - Add HEX/Binary header decode: block_bits, new, maildrop, rtl - Add short instruction decode: temp group slot/target, sys events - Add short message (SMSG) decode: tone/numeric/source/numbered - Add group/temp-group/priority flags per address - Add S2 C-pattern detection with ±1 symbol boundary correction - Extract FIW roaming, repeat, traffic fields - Replace snprintf with lightweight str_* helpers (no heap/_sbrk) - Mark uncorrectable BCH words as ? instead of aborting phase - ETX/NUL handling: trim trailing padding, show mid-message as ? App (ui_flex_rx.cpp): - Add status bar: cycle/frame, bitrate, polarity, time, timezone - Add network info bar: LID, CZ, CC, roaming flag - Pipe-delimited serial output for all message types - BIW events to serial and status bar (not console) - Human-readable console: +GRP for temp group, G/TG/P flags - USB serial via UsbSerialAsyncmsg Packet (flex_defs.hpp): - uint64_t capcode (long address support) - 256-byte message buffer - Fragment flags, BIW raw values, address type, group/priority Known limitation: phase label unreliable on multi-phase modes (3200/2FSK, 6400/4FSK). Data always decodes correctly.
112 lines
3.0 KiB
C++
112 lines
3.0 KiB
C++
#ifndef __UI_FLEX_RX_H__
|
|
#define __UI_FLEX_RX_H__
|
|
|
|
#include "ui_widget.hpp"
|
|
#include "ui_navigation.hpp"
|
|
#include "ui_receiver.hpp"
|
|
#include "ui_freq_field.hpp"
|
|
#include "ui_rssi.hpp"
|
|
#include "app_settings.hpp"
|
|
#include "radio_state.hpp"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace ui::external_app::flex_rx {
|
|
|
|
class FlexAppView : public View {
|
|
public:
|
|
FlexAppView(NavigationView& nav);
|
|
~FlexAppView();
|
|
|
|
void focus() override;
|
|
std::string title() const override { return "FLEX RX"; };
|
|
|
|
private:
|
|
NavigationView& nav_;
|
|
|
|
// Saved settings
|
|
rf::Frequency frequency_value{931740000};
|
|
|
|
RxRadioState radio_state_{};
|
|
|
|
// Status bar state (updated from BIW packets)
|
|
char status_time_[12]{}; // "HH:MM:SS"
|
|
char status_tz_[12]{}; // "UTC+N"
|
|
uint16_t status_lid_{0};
|
|
uint16_t status_cz_{0};
|
|
uint16_t status_cc_{0};
|
|
|
|
// Message storage for console redraw
|
|
static constexpr size_t MAX_MESSAGES = 20;
|
|
std::vector<std::string> messages{};
|
|
|
|
// Helper methods
|
|
void log_message(const std::string& message);
|
|
void redraw_console();
|
|
void update_freq(rf::Frequency f);
|
|
|
|
// UI Elements - Row 0, dynamically positioned
|
|
RxFrequencyField field_frequency{
|
|
{UI_POS_X(0), UI_POS_Y(0)},
|
|
nav_};
|
|
|
|
RFAmpField field_rf_amp{
|
|
{UI_POS_X(13), UI_POS_Y(0)}};
|
|
LNAGainField field_lna{
|
|
{UI_POS_X(15), UI_POS_Y(0)}};
|
|
VGAGainField field_vga{
|
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
|
|
|
RSSI rssi{
|
|
{UI_POS_X(21), 0, UI_POS_WIDTH(9), 4}};
|
|
|
|
// Status rows (rows 1-2)
|
|
Text text_status1{
|
|
{0, 1 * 16, screen_width, 16},
|
|
""};
|
|
Text text_status2{
|
|
{0, 2 * 16, screen_width, 16},
|
|
""};
|
|
|
|
// Message display area (below status rows)
|
|
Console console{
|
|
{0, 3 * 16, screen_width, screen_height - 4 * 16}};
|
|
|
|
// Persistent settings manager
|
|
app_settings::SettingsManager settings_{
|
|
"rx_flex",
|
|
app_settings::Mode::RX,
|
|
{{"frequency", &frequency_value}}};
|
|
|
|
// Message handlers
|
|
void on_packet(const FlexPacketMessage* message);
|
|
void on_stats(const FlexStatsMessage* message);
|
|
void on_debug(const FlexDebugMessage* message);
|
|
|
|
// Message handler registrations
|
|
MessageHandlerRegistration message_handler_packet{
|
|
Message::ID::FlexPacket,
|
|
[this](const Message* const p) {
|
|
const auto message = *static_cast<const FlexPacketMessage*>(p);
|
|
this->on_packet(&message);
|
|
}};
|
|
|
|
MessageHandlerRegistration message_handler_stats{
|
|
Message::ID::FlexStats,
|
|
[this](const Message* const p) {
|
|
const auto message = *static_cast<const FlexStatsMessage*>(p);
|
|
this->on_stats(&message);
|
|
}};
|
|
|
|
MessageHandlerRegistration message_handler_debug{
|
|
Message::ID::FlexDebug,
|
|
[this](const Message* const p) {
|
|
const auto message = *static_cast<const FlexDebugMessage*>(p);
|
|
this->on_debug(&message);
|
|
}};
|
|
};
|
|
|
|
} // namespace ui::external_app::flex_rx
|
|
|
|
#endif /*__UI_FLEX_RX_H__*/ |