2015-07-08 11:39:24 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-12-09 12:21:47 -05:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2015-07-08 11:39:24 -04:00
|
|
|
*
|
|
|
|
* 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 __MESSAGE_H__
|
|
|
|
#define __MESSAGE_H__
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
2016-05-10 17:12:37 -04:00
|
|
|
#include <cstring>
|
2015-07-08 11:39:24 -04:00
|
|
|
#include <array>
|
|
|
|
#include <functional>
|
2016-05-09 15:05:11 -04:00
|
|
|
#include <algorithm>
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2017-01-16 03:40:17 -05:00
|
|
|
#include "pocsag_packet.hpp"
|
2016-01-31 03:34:24 -05:00
|
|
|
#include "baseband_packet.hpp"
|
|
|
|
#include "ert_packet.hpp"
|
2016-04-06 20:04:40 -04:00
|
|
|
#include "tpms_packet.hpp"
|
2016-08-23 02:45:33 -04:00
|
|
|
#include "pocsag_packet.hpp"
|
2017-02-13 00:35:13 -05:00
|
|
|
#include "jammer.hpp"
|
2016-01-31 03:34:24 -05:00
|
|
|
#include "dsp_fir_taps.hpp"
|
2016-01-29 18:57:20 -05:00
|
|
|
#include "dsp_iir.hpp"
|
2016-01-31 03:34:24 -05:00
|
|
|
#include "fifo.hpp"
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
#include "utility.hpp"
|
|
|
|
|
2015-11-09 14:57:25 -05:00
|
|
|
#include "ch.h"
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
class Message {
|
|
|
|
public:
|
2016-01-30 20:30:54 -05:00
|
|
|
static constexpr size_t MAX_SIZE = 512;
|
2016-01-31 03:34:24 -05:00
|
|
|
|
|
|
|
enum class ID : uint32_t {
|
2015-07-08 11:39:24 -04:00
|
|
|
/* Assign consecutive IDs. IDs are used to index array. */
|
|
|
|
RSSIStatistics = 0,
|
|
|
|
BasebandStatistics = 1,
|
|
|
|
ChannelStatistics = 2,
|
2016-01-29 18:28:05 -05:00
|
|
|
DisplayFrameSync = 3,
|
2016-01-31 03:34:24 -05:00
|
|
|
AudioStatistics = 4,
|
|
|
|
TPMSPacket = 6,
|
2015-08-20 21:03:49 -04:00
|
|
|
Shutdown = 8,
|
2016-01-31 03:34:24 -05:00
|
|
|
AISPacket = 7,
|
|
|
|
ERTPacket = 9,
|
|
|
|
UpdateSpectrum = 10,
|
|
|
|
NBFMConfigure = 11,
|
|
|
|
WFMConfigure = 12,
|
|
|
|
AMConfigure = 13,
|
|
|
|
ChannelSpectrumConfig = 14,
|
|
|
|
SpectrumStreamingConfig = 15,
|
|
|
|
DisplaySleep = 16,
|
2016-05-09 15:05:11 -04:00
|
|
|
CaptureConfig = 17,
|
2016-06-21 15:05:55 -04:00
|
|
|
CaptureThreadDone = 18,
|
2017-01-10 14:45:40 -05:00
|
|
|
ReplayConfig = 19,
|
|
|
|
ReplayThreadDone = 20,
|
|
|
|
|
|
|
|
TXDone = 30,
|
|
|
|
Retune = 31,
|
2017-01-17 03:42:35 -05:00
|
|
|
|
2017-01-10 14:45:40 -05:00
|
|
|
TonesConfigure = 32,
|
|
|
|
AFSKConfigure = 33,
|
|
|
|
PWMRSSIConfigure = 34,
|
|
|
|
OOKConfigure = 35,
|
|
|
|
RDSConfigure = 36,
|
|
|
|
AudioTXConfig = 37,
|
|
|
|
POCSAGConfigure = 38,
|
|
|
|
DTMFTXConfig = 39,
|
|
|
|
ADSBConfigure = 40,
|
2017-01-17 03:42:35 -05:00
|
|
|
JammerConfigure = 41,
|
2017-02-01 03:53:26 -05:00
|
|
|
WidebandSpectrumConfig = 42,
|
2017-02-07 12:48:17 -05:00
|
|
|
FSKConfigure = 43,
|
2016-08-03 02:53:50 -04:00
|
|
|
|
2017-01-17 03:42:35 -05:00
|
|
|
POCSAGPacket = 50,
|
2016-08-23 02:45:33 -04:00
|
|
|
|
2017-01-10 14:45:40 -05:00
|
|
|
FIFOSignal = 52,
|
|
|
|
FIFOData = 53,
|
2015-07-08 11:39:24 -04:00
|
|
|
MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr Message(
|
|
|
|
ID id
|
2015-08-20 16:13:12 -04:00
|
|
|
) : id { id }
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const ID id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RSSIStatistics {
|
|
|
|
uint32_t accumulator { 0 };
|
|
|
|
uint32_t min { 0 };
|
|
|
|
uint32_t max { 0 };
|
|
|
|
uint32_t count { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
class RSSIStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr RSSIStatisticsMessage(
|
2015-11-11 12:35:28 -05:00
|
|
|
const RSSIStatistics& statistics
|
2015-07-08 11:39:24 -04:00
|
|
|
) : Message { ID::RSSIStatistics },
|
2015-11-11 12:35:28 -05:00
|
|
|
statistics { statistics }
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RSSIStatistics statistics;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BasebandStatistics {
|
|
|
|
uint32_t idle_ticks { 0 };
|
2015-10-14 13:44:20 -04:00
|
|
|
uint32_t main_ticks { 0 };
|
|
|
|
uint32_t rssi_ticks { 0 };
|
2015-07-08 11:39:24 -04:00
|
|
|
uint32_t baseband_ticks { 0 };
|
|
|
|
bool saturation { false };
|
|
|
|
};
|
|
|
|
|
|
|
|
class BasebandStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr BasebandStatisticsMessage(
|
2015-11-11 12:35:28 -05:00
|
|
|
const BasebandStatistics& statistics
|
2015-07-08 11:39:24 -04:00
|
|
|
) : Message { ID::BasebandStatistics },
|
2015-11-11 12:35:28 -05:00
|
|
|
statistics { statistics }
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BasebandStatistics statistics;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ChannelStatistics {
|
|
|
|
int32_t max_db;
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
constexpr ChannelStatistics(
|
2015-11-11 12:16:20 -05:00
|
|
|
int32_t max_db = -120,
|
|
|
|
size_t count = 0
|
2015-07-08 11:39:24 -04:00
|
|
|
) : max_db { max_db },
|
|
|
|
count { count }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ChannelStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ChannelStatisticsMessage(
|
2016-01-31 03:34:24 -05:00
|
|
|
const ChannelStatistics& statistics
|
|
|
|
) : Message { ID::ChannelStatistics },
|
|
|
|
statistics { statistics }
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ChannelStatistics statistics;
|
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class DisplayFrameSyncMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr DisplayFrameSyncMessage(
|
|
|
|
) : Message { ID::DisplayFrameSync }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
struct AudioStatistics {
|
|
|
|
int32_t rms_db;
|
|
|
|
int32_t max_db;
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
constexpr AudioStatistics(
|
|
|
|
) : rms_db { -120 },
|
|
|
|
max_db { -120 },
|
|
|
|
count { 0 }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr AudioStatistics(
|
|
|
|
int32_t rms_db,
|
|
|
|
int32_t max_db,
|
|
|
|
size_t count
|
|
|
|
) : rms_db { rms_db },
|
|
|
|
max_db { max_db },
|
|
|
|
count { count }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class DisplaySleepMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr DisplaySleepMessage(
|
|
|
|
) : Message { ID::DisplaySleep }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
class AudioStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr AudioStatisticsMessage(
|
2016-01-31 03:34:24 -05:00
|
|
|
const AudioStatistics& statistics
|
2015-07-08 11:39:24 -04:00
|
|
|
) : Message { ID::AudioStatistics },
|
2016-01-31 03:34:24 -05:00
|
|
|
statistics { statistics }
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioStatistics statistics;
|
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class SpectrumStreamingConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
enum class Mode : uint32_t {
|
|
|
|
Stopped = 0,
|
|
|
|
Running = 1,
|
|
|
|
};
|
2016-05-12 19:18:04 -04:00
|
|
|
|
|
|
|
constexpr SpectrumStreamingConfigMessage(
|
2016-01-10 13:42:20 -05:00
|
|
|
Mode mode
|
2016-05-12 19:18:04 -04:00
|
|
|
) : Message { ID::SpectrumStreamingConfig },
|
2016-01-10 13:42:20 -05:00
|
|
|
mode { mode }
|
2016-01-31 03:34:24 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Mode mode { Mode::Stopped };
|
|
|
|
};
|
|
|
|
|
2017-02-01 03:53:26 -05:00
|
|
|
class WidebandSpectrumConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr WidebandSpectrumConfigMessage (
|
|
|
|
size_t sampling_rate,
|
|
|
|
size_t trigger
|
|
|
|
) : Message { ID::WidebandSpectrumConfig },
|
|
|
|
sampling_rate { sampling_rate },
|
|
|
|
trigger { trigger }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t sampling_rate { 0 };
|
|
|
|
size_t trigger { 0 };
|
|
|
|
};
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
struct ChannelSpectrum {
|
2015-08-20 16:13:12 -04:00
|
|
|
std::array<uint8_t, 256> db { { 0 } };
|
2015-07-18 01:55:18 -04:00
|
|
|
uint32_t sampling_rate { 0 };
|
2015-07-18 02:16:09 -04:00
|
|
|
uint32_t channel_filter_pass_frequency { 0 };
|
|
|
|
uint32_t channel_filter_stop_frequency { 0 };
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2016-02-10 13:41:06 -05:00
|
|
|
using ChannelSpectrumFIFO = FIFO<ChannelSpectrum>;
|
2016-01-31 03:34:24 -05:00
|
|
|
|
|
|
|
class ChannelSpectrumConfigMessage : public Message {
|
2015-07-08 11:39:24 -04:00
|
|
|
public:
|
2016-02-10 13:41:06 -05:00
|
|
|
static constexpr size_t fifo_k = 2;
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
constexpr ChannelSpectrumConfigMessage(
|
|
|
|
ChannelSpectrumFIFO* fifo
|
|
|
|
) : Message { ID::ChannelSpectrumConfig },
|
|
|
|
fifo { fifo }
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
ChannelSpectrumFIFO* fifo { nullptr };
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class AISPacketMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr AISPacketMessage(
|
|
|
|
const baseband::Packet& packet
|
|
|
|
) : Message { ID::AISPacket },
|
|
|
|
packet { packet }
|
|
|
|
{
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
baseband::Packet packet;
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class TPMSPacketMessage : public Message {
|
2015-07-08 11:39:24 -04:00
|
|
|
public:
|
2016-01-31 03:34:24 -05:00
|
|
|
constexpr TPMSPacketMessage(
|
2016-04-06 20:04:40 -04:00
|
|
|
const tpms::SignalType signal_type,
|
2016-01-31 03:34:24 -05:00
|
|
|
const baseband::Packet& packet
|
|
|
|
) : Message { ID::TPMSPacket },
|
2016-04-06 20:04:40 -04:00
|
|
|
signal_type { signal_type },
|
2016-01-31 03:34:24 -05:00
|
|
|
packet { packet }
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-04-06 20:04:40 -04:00
|
|
|
tpms::SignalType signal_type;
|
2016-01-31 03:34:24 -05:00
|
|
|
baseband::Packet packet;
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2016-08-23 02:45:33 -04:00
|
|
|
class POCSAGPacketMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr POCSAGPacketMessage(
|
|
|
|
const pocsag::POCSAGPacket& packet
|
|
|
|
) : Message { ID::POCSAGPacket },
|
|
|
|
packet { packet }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
pocsag::POCSAGPacket packet;
|
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class ShutdownMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ShutdownMessage(
|
|
|
|
) : Message { ID::Shutdown }
|
|
|
|
{
|
|
|
|
}
|
2015-11-10 18:19:56 -05:00
|
|
|
};
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class ERTPacketMessage : public Message {
|
2015-11-10 18:19:56 -05:00
|
|
|
public:
|
2016-01-31 03:34:24 -05:00
|
|
|
constexpr ERTPacketMessage(
|
|
|
|
const ert::Packet::Type type,
|
|
|
|
const baseband::Packet& packet
|
|
|
|
) : Message { ID::ERTPacket },
|
|
|
|
type { type },
|
|
|
|
packet { packet }
|
2015-11-10 18:19:56 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
ert::Packet::Type type;
|
|
|
|
|
|
|
|
baseband::Packet packet;
|
2015-11-10 18:19:56 -05:00
|
|
|
};
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class UpdateSpectrumMessage : public Message {
|
2016-01-03 01:24:30 -05:00
|
|
|
public:
|
2016-01-31 03:34:24 -05:00
|
|
|
constexpr UpdateSpectrumMessage(
|
|
|
|
) : Message { ID::UpdateSpectrum }
|
2016-01-03 01:24:30 -05:00
|
|
|
{
|
|
|
|
}
|
2016-01-31 03:34:24 -05:00
|
|
|
};
|
2016-01-03 01:24:30 -05:00
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class NBFMConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr NBFMConfigureMessage(
|
|
|
|
const fir_taps_real<24> decim_0_filter,
|
|
|
|
const fir_taps_real<32> decim_1_filter,
|
|
|
|
const fir_taps_real<32> channel_filter,
|
2016-01-29 22:23:30 -05:00
|
|
|
const size_t channel_decimation,
|
2016-01-29 18:57:20 -05:00
|
|
|
const size_t deviation,
|
|
|
|
const iir_biquad_config_t audio_hpf_config,
|
|
|
|
const iir_biquad_config_t audio_deemph_config
|
2016-01-31 03:34:24 -05:00
|
|
|
) : Message { ID::NBFMConfigure },
|
|
|
|
decim_0_filter(decim_0_filter),
|
|
|
|
decim_1_filter(decim_1_filter),
|
|
|
|
channel_filter(channel_filter),
|
2016-01-29 22:23:30 -05:00
|
|
|
channel_decimation { channel_decimation },
|
2016-01-29 18:57:20 -05:00
|
|
|
deviation { deviation },
|
2016-02-03 20:59:46 -05:00
|
|
|
audio_hpf_config(audio_hpf_config),
|
|
|
|
audio_deemph_config(audio_deemph_config)
|
2016-01-31 03:34:24 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const fir_taps_real<24> decim_0_filter;
|
|
|
|
const fir_taps_real<32> decim_1_filter;
|
|
|
|
const fir_taps_real<32> channel_filter;
|
2016-01-29 22:23:30 -05:00
|
|
|
const size_t channel_decimation;
|
2016-01-31 03:34:24 -05:00
|
|
|
const size_t deviation;
|
2016-01-29 18:57:20 -05:00
|
|
|
const iir_biquad_config_t audio_hpf_config;
|
|
|
|
const iir_biquad_config_t audio_deemph_config;
|
2016-01-03 01:24:30 -05:00
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class WFMConfigureMessage : public Message {
|
2015-08-20 21:03:49 -04:00
|
|
|
public:
|
2016-01-31 03:34:24 -05:00
|
|
|
constexpr WFMConfigureMessage(
|
|
|
|
const fir_taps_real<24> decim_0_filter,
|
|
|
|
const fir_taps_real<16> decim_1_filter,
|
|
|
|
const fir_taps_real<64> audio_filter,
|
2016-01-29 18:57:20 -05:00
|
|
|
const size_t deviation,
|
|
|
|
const iir_biquad_config_t audio_hpf_config,
|
|
|
|
const iir_biquad_config_t audio_deemph_config
|
2016-01-31 03:34:24 -05:00
|
|
|
) : Message { ID::WFMConfigure },
|
|
|
|
decim_0_filter(decim_0_filter),
|
|
|
|
decim_1_filter(decim_1_filter),
|
|
|
|
audio_filter(audio_filter),
|
2016-01-29 18:57:20 -05:00
|
|
|
deviation { deviation },
|
2016-02-03 20:59:46 -05:00
|
|
|
audio_hpf_config(audio_hpf_config),
|
|
|
|
audio_deemph_config(audio_deemph_config)
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
2016-01-31 03:34:24 -05:00
|
|
|
|
|
|
|
const fir_taps_real<24> decim_0_filter;
|
|
|
|
const fir_taps_real<16> decim_1_filter;
|
|
|
|
const fir_taps_real<64> audio_filter;
|
|
|
|
const size_t deviation;
|
2016-01-29 18:57:20 -05:00
|
|
|
const iir_biquad_config_t audio_hpf_config;
|
|
|
|
const iir_biquad_config_t audio_deemph_config;
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
class AMConfigureMessage : public Message {
|
2015-07-08 11:39:24 -04:00
|
|
|
public:
|
2016-01-30 21:02:28 -05:00
|
|
|
enum class Modulation : int32_t {
|
2016-01-30 21:17:29 -05:00
|
|
|
DSB = 0,
|
2016-01-30 21:02:28 -05:00
|
|
|
SSB = 1,
|
|
|
|
};
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
constexpr AMConfigureMessage(
|
|
|
|
const fir_taps_real<24> decim_0_filter,
|
|
|
|
const fir_taps_real<32> decim_1_filter,
|
2016-01-30 20:28:11 -05:00
|
|
|
const fir_taps_real<32> decim_2_filter,
|
2016-01-30 20:30:54 -05:00
|
|
|
const fir_taps_complex<64> channel_filter,
|
2016-01-30 21:02:28 -05:00
|
|
|
const Modulation modulation,
|
2016-01-29 18:57:20 -05:00
|
|
|
const iir_biquad_config_t audio_hpf_config
|
2016-01-31 03:34:24 -05:00
|
|
|
) : Message { ID::AMConfigure },
|
|
|
|
decim_0_filter(decim_0_filter),
|
|
|
|
decim_1_filter(decim_1_filter),
|
2016-01-30 20:28:11 -05:00
|
|
|
decim_2_filter(decim_2_filter),
|
2016-01-29 18:57:20 -05:00
|
|
|
channel_filter(channel_filter),
|
2016-01-30 21:02:28 -05:00
|
|
|
modulation { modulation },
|
2016-02-03 20:59:46 -05:00
|
|
|
audio_hpf_config(audio_hpf_config)
|
2015-07-08 11:39:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:34:24 -05:00
|
|
|
const fir_taps_real<24> decim_0_filter;
|
|
|
|
const fir_taps_real<32> decim_1_filter;
|
2016-01-30 20:28:11 -05:00
|
|
|
const fir_taps_real<32> decim_2_filter;
|
2016-01-30 20:30:54 -05:00
|
|
|
const fir_taps_complex<64> channel_filter;
|
2016-01-30 21:02:28 -05:00
|
|
|
const Modulation modulation;
|
2016-01-29 18:57:20 -05:00
|
|
|
const iir_biquad_config_t audio_hpf_config;
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2016-05-10 17:12:37 -04:00
|
|
|
// TODO: Put this somewhere else, or at least the implementation part.
|
|
|
|
class StreamBuffer {
|
|
|
|
uint8_t* data_;
|
|
|
|
size_t used_;
|
|
|
|
size_t capacity_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
constexpr StreamBuffer(
|
|
|
|
void* const data = nullptr,
|
|
|
|
const size_t capacity = 0
|
|
|
|
) : data_ { static_cast<uint8_t*>(data) },
|
|
|
|
used_ { 0 },
|
|
|
|
capacity_ { capacity }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t write(const void* p, const size_t count) {
|
|
|
|
const auto copy_size = std::min(capacity_ - used_, count);
|
|
|
|
memcpy(&data_[used_], p, copy_size);
|
|
|
|
used_ += copy_size;
|
|
|
|
return copy_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_full() const {
|
|
|
|
return used_ >= capacity_;
|
|
|
|
}
|
|
|
|
|
2016-10-04 12:15:19 -04:00
|
|
|
void* data() const {
|
2016-05-10 17:12:37 -04:00
|
|
|
return data_;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t size() const {
|
|
|
|
return used_;
|
|
|
|
}
|
|
|
|
|
2016-10-04 12:15:19 -04:00
|
|
|
void set_size(const size_t value) {
|
|
|
|
used_ = value;
|
|
|
|
}
|
|
|
|
|
2016-05-10 17:12:37 -04:00
|
|
|
void empty() {
|
|
|
|
used_ = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-09 15:05:11 -04:00
|
|
|
struct CaptureConfig {
|
2016-05-10 17:12:37 -04:00
|
|
|
const size_t write_size;
|
|
|
|
const size_t buffer_count;
|
2016-05-09 15:05:11 -04:00
|
|
|
uint64_t baseband_bytes_received;
|
|
|
|
uint64_t baseband_bytes_dropped;
|
2016-05-10 17:12:37 -04:00
|
|
|
FIFO<StreamBuffer*>* fifo_buffers_empty;
|
|
|
|
FIFO<StreamBuffer*>* fifo_buffers_full;
|
2016-05-09 15:05:11 -04:00
|
|
|
|
|
|
|
constexpr CaptureConfig(
|
2016-05-10 17:12:37 -04:00
|
|
|
const size_t write_size,
|
|
|
|
const size_t buffer_count
|
|
|
|
) : write_size { write_size },
|
|
|
|
buffer_count { buffer_count },
|
2016-05-09 15:05:11 -04:00
|
|
|
baseband_bytes_received { 0 },
|
|
|
|
baseband_bytes_dropped { 0 },
|
2016-05-10 17:12:37 -04:00
|
|
|
fifo_buffers_empty { nullptr },
|
|
|
|
fifo_buffers_full { nullptr }
|
2016-05-09 15:05:11 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t dropped_percent() const {
|
|
|
|
if( baseband_bytes_dropped == 0 ) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
const size_t percent = baseband_bytes_dropped * 100U / baseband_bytes_received;
|
|
|
|
return std::max(1U, percent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CaptureConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr CaptureConfigMessage(
|
|
|
|
CaptureConfig* const config
|
|
|
|
) : Message { ID::CaptureConfig },
|
|
|
|
config { config }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CaptureConfig* const config;
|
|
|
|
};
|
|
|
|
|
2017-01-10 14:45:40 -05:00
|
|
|
struct ReplayConfig {
|
|
|
|
const size_t read_size;
|
|
|
|
const size_t buffer_count;
|
|
|
|
uint64_t baseband_bytes_sent;
|
|
|
|
FIFO<StreamBuffer*>* fifo_buffers_empty;
|
|
|
|
FIFO<StreamBuffer*>* fifo_buffers_full;
|
|
|
|
|
|
|
|
constexpr ReplayConfig(
|
|
|
|
const size_t read_size,
|
|
|
|
const size_t buffer_count
|
|
|
|
) : read_size { read_size },
|
|
|
|
buffer_count { buffer_count },
|
|
|
|
baseband_bytes_sent { 0 },
|
|
|
|
fifo_buffers_empty { nullptr },
|
|
|
|
fifo_buffers_full { nullptr }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ReplayConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ReplayConfigMessage(
|
|
|
|
ReplayConfig* const config
|
|
|
|
) : Message { ID::ReplayConfig },
|
|
|
|
config { config }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplayConfig* const config;
|
|
|
|
};
|
|
|
|
|
2015-09-04 14:37:27 -04:00
|
|
|
class TXDoneMessage : public Message {
|
|
|
|
public:
|
2016-08-06 02:49:45 -04:00
|
|
|
constexpr TXDoneMessage(
|
2015-09-04 14:37:27 -04:00
|
|
|
) : Message { ID::TXDone }
|
|
|
|
{
|
|
|
|
}
|
2015-09-10 14:36:39 -04:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
uint32_t progress = 0;
|
|
|
|
bool done = false;
|
2015-09-04 14:37:27 -04:00
|
|
|
};
|
|
|
|
|
2016-07-27 23:25:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
class PWMRSSIConfigureMessage : public Message {
|
2016-01-05 14:17:55 -05:00
|
|
|
public:
|
2016-08-06 02:49:45 -04:00
|
|
|
constexpr PWMRSSIConfigureMessage(
|
2016-07-27 23:25:33 -04:00
|
|
|
const bool enabled,
|
2017-01-16 03:40:17 -05:00
|
|
|
const uint32_t synth_div,
|
2016-07-27 23:25:33 -04:00
|
|
|
const int32_t avg
|
|
|
|
) : Message { ID::PWMRSSIConfigure },
|
|
|
|
enabled(enabled),
|
2017-01-16 03:40:17 -05:00
|
|
|
synth_div(synth_div),
|
2016-07-27 23:25:33 -04:00
|
|
|
avg(avg)
|
2016-01-05 14:17:55 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-27 23:25:33 -04:00
|
|
|
const bool enabled;
|
2017-01-16 03:40:17 -05:00
|
|
|
const uint32_t synth_div;
|
2016-07-27 23:25:33 -04:00
|
|
|
const int32_t avg;
|
2016-01-05 14:17:55 -05:00
|
|
|
};
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
class TonesConfigureMessage : public Message {
|
2015-11-20 01:59:09 -05:00
|
|
|
public:
|
2016-12-09 12:21:47 -05:00
|
|
|
constexpr TonesConfigureMessage(
|
|
|
|
const uint32_t fm_delta,
|
|
|
|
const uint32_t pre_silence,
|
|
|
|
const uint16_t tone_count,
|
|
|
|
const bool dual_tone,
|
|
|
|
const bool audio_out
|
|
|
|
) : Message { ID::TonesConfigure },
|
|
|
|
fm_delta(fm_delta),
|
|
|
|
pre_silence(pre_silence),
|
|
|
|
tone_count(tone_count),
|
|
|
|
dual_tone(dual_tone),
|
|
|
|
audio_out(audio_out)
|
2015-11-20 01:59:09 -05:00
|
|
|
{
|
|
|
|
}
|
2016-07-26 21:03:40 -04:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
const uint32_t fm_delta;
|
|
|
|
const uint32_t pre_silence;
|
2016-08-06 02:49:45 -04:00
|
|
|
const uint16_t tone_count;
|
2016-12-09 12:21:47 -05:00
|
|
|
const bool dual_tone;
|
|
|
|
const bool audio_out;
|
2015-11-20 01:59:09 -05:00
|
|
|
};
|
|
|
|
|
2016-08-16 20:55:34 -04:00
|
|
|
class RDSConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr RDSConfigureMessage(
|
2016-12-05 06:56:41 -05:00
|
|
|
const uint16_t length
|
2016-08-16 20:55:34 -04:00
|
|
|
) : Message { ID::RDSConfigure },
|
|
|
|
length(length)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
const uint16_t length = 0;
|
2016-08-16 20:55:34 -04:00
|
|
|
};
|
|
|
|
|
2016-08-06 02:49:45 -04:00
|
|
|
class RetuneMessage : public Message {
|
2016-08-03 02:53:50 -04:00
|
|
|
public:
|
2016-08-06 02:49:45 -04:00
|
|
|
constexpr RetuneMessage(
|
2016-11-30 01:41:55 -05:00
|
|
|
) : Message { ID::Retune }
|
2016-08-03 02:53:50 -04:00
|
|
|
{
|
|
|
|
}
|
2016-08-06 02:49:45 -04:00
|
|
|
|
2016-11-30 01:41:55 -05:00
|
|
|
int64_t freq = 0;
|
2017-01-17 03:42:35 -05:00
|
|
|
uint32_t range = 0;
|
2016-08-03 02:53:50 -04:00
|
|
|
};
|
|
|
|
|
2016-08-16 20:55:34 -04:00
|
|
|
class AudioTXConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr AudioTXConfigMessage(
|
2016-08-26 03:54:17 -04:00
|
|
|
const uint32_t divider,
|
2017-02-02 04:29:14 -05:00
|
|
|
const uint32_t fm_delta,
|
2016-09-23 17:08:54 -04:00
|
|
|
const uint32_t ctcss_phase_inc,
|
|
|
|
const bool ctcss_enabled
|
2016-08-16 20:55:34 -04:00
|
|
|
) : Message { ID::AudioTXConfig },
|
2016-08-26 03:54:17 -04:00
|
|
|
divider(divider),
|
2017-02-02 04:29:14 -05:00
|
|
|
fm_delta(fm_delta),
|
2016-09-23 17:08:54 -04:00
|
|
|
ctcss_phase_inc(ctcss_phase_inc),
|
|
|
|
ctcss_enabled(ctcss_enabled)
|
2016-08-16 20:55:34 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-26 03:54:17 -04:00
|
|
|
const uint32_t divider;
|
2017-02-02 04:29:14 -05:00
|
|
|
const uint32_t fm_delta;
|
2016-09-23 17:08:54 -04:00
|
|
|
const uint32_t ctcss_phase_inc;
|
|
|
|
const bool ctcss_enabled;
|
2016-08-16 20:55:34 -04:00
|
|
|
};
|
|
|
|
|
2016-08-06 02:49:45 -04:00
|
|
|
class AFSKConfigureMessage : public Message {
|
2015-11-13 21:44:49 -05:00
|
|
|
public:
|
2016-08-06 02:49:45 -04:00
|
|
|
constexpr AFSKConfigureMessage(
|
|
|
|
const uint32_t samples_per_bit,
|
|
|
|
const uint32_t phase_inc_mark,
|
|
|
|
const uint32_t phase_inc_space,
|
|
|
|
const uint8_t repeat,
|
|
|
|
const uint32_t bw,
|
|
|
|
const uint8_t format
|
|
|
|
) : Message { ID::AFSKConfigure },
|
|
|
|
samples_per_bit(samples_per_bit),
|
|
|
|
phase_inc_mark(phase_inc_mark),
|
|
|
|
phase_inc_space(phase_inc_space),
|
|
|
|
repeat(repeat),
|
|
|
|
bw(bw),
|
|
|
|
format(format)
|
2015-11-13 21:44:49 -05:00
|
|
|
{
|
|
|
|
}
|
2016-08-06 02:49:45 -04:00
|
|
|
|
|
|
|
const uint32_t samples_per_bit;
|
|
|
|
const uint32_t phase_inc_mark;
|
|
|
|
const uint32_t phase_inc_space;
|
|
|
|
const uint8_t repeat;
|
|
|
|
const uint32_t bw;
|
|
|
|
const uint8_t format;
|
2015-11-13 21:44:49 -05:00
|
|
|
};
|
|
|
|
|
2016-08-06 02:49:45 -04:00
|
|
|
class OOKConfigureMessage : public Message {
|
2016-01-29 18:28:05 -05:00
|
|
|
public:
|
2016-08-06 02:49:45 -04:00
|
|
|
constexpr OOKConfigureMessage(
|
|
|
|
const uint32_t stream_length,
|
|
|
|
const uint32_t samples_per_bit,
|
|
|
|
const uint8_t repeat,
|
|
|
|
const uint32_t pause_symbols
|
|
|
|
) : Message { ID::OOKConfigure },
|
|
|
|
stream_length(stream_length),
|
|
|
|
samples_per_bit(samples_per_bit),
|
|
|
|
repeat(repeat),
|
|
|
|
pause_symbols(pause_symbols)
|
2016-01-29 18:28:05 -05:00
|
|
|
{
|
|
|
|
}
|
2016-02-04 04:27:53 -05:00
|
|
|
|
2016-08-06 02:49:45 -04:00
|
|
|
const uint32_t stream_length;
|
|
|
|
const uint32_t samples_per_bit;
|
|
|
|
const uint8_t repeat;
|
|
|
|
const uint32_t pause_symbols;
|
2016-01-29 18:28:05 -05:00
|
|
|
};
|
|
|
|
|
2017-02-07 12:48:17 -05:00
|
|
|
class FSKConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr FSKConfigureMessage(
|
|
|
|
const uint32_t stream_length,
|
|
|
|
const uint32_t samples_per_bit,
|
|
|
|
const uint32_t shift,
|
|
|
|
const uint32_t progress_notice
|
|
|
|
) : Message { ID::FSKConfigure },
|
|
|
|
stream_length(stream_length),
|
|
|
|
samples_per_bit(samples_per_bit),
|
|
|
|
shift(shift),
|
|
|
|
progress_notice(progress_notice)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t stream_length;
|
|
|
|
const uint32_t samples_per_bit;
|
|
|
|
const uint32_t shift;
|
|
|
|
const uint32_t progress_notice;
|
|
|
|
};
|
|
|
|
|
2016-08-23 02:45:33 -04:00
|
|
|
class POCSAGConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr POCSAGConfigureMessage(
|
2017-01-16 03:40:17 -05:00
|
|
|
const pocsag::BitRate bitrate
|
2016-08-23 02:45:33 -04:00
|
|
|
) : Message { ID::POCSAGConfigure },
|
2017-01-16 03:40:17 -05:00
|
|
|
bitrate(bitrate)
|
2016-08-23 02:45:33 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-16 03:40:17 -05:00
|
|
|
const pocsag::BitRate bitrate;
|
2016-08-23 02:45:33 -04:00
|
|
|
};
|
|
|
|
|
2016-12-01 00:58:47 -05:00
|
|
|
class ADSBConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ADSBConfigureMessage(
|
|
|
|
const uint32_t test
|
|
|
|
) : Message { ID::ADSBConfigure },
|
|
|
|
test(test)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t test;
|
|
|
|
};
|
|
|
|
|
2017-01-17 03:42:35 -05:00
|
|
|
class JammerConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr JammerConfigureMessage(
|
2017-01-29 20:09:00 -05:00
|
|
|
const bool run,
|
2017-02-13 00:35:13 -05:00
|
|
|
const jammer::JammerType type,
|
2017-01-29 20:09:00 -05:00
|
|
|
const uint32_t speed
|
2017-01-17 03:42:35 -05:00
|
|
|
) : Message { ID::JammerConfigure },
|
2017-01-29 20:09:00 -05:00
|
|
|
run(run),
|
|
|
|
type(type),
|
|
|
|
speed(speed)
|
2017-01-17 03:42:35 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-17 09:27:37 -05:00
|
|
|
const bool run;
|
2017-02-13 00:35:13 -05:00
|
|
|
const jammer::JammerType type;
|
2017-01-29 20:09:00 -05:00
|
|
|
const uint32_t speed;
|
2017-01-17 03:42:35 -05:00
|
|
|
};
|
|
|
|
|
2016-09-23 11:34:50 -04:00
|
|
|
class DTMFTXConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr DTMFTXConfigMessage(
|
|
|
|
const uint32_t bw,
|
|
|
|
const uint32_t tone_length,
|
|
|
|
const uint32_t pause_length
|
|
|
|
) : Message { ID::DTMFTXConfig },
|
|
|
|
bw(bw),
|
|
|
|
tone_length(tone_length),
|
|
|
|
pause_length(pause_length)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t bw;
|
|
|
|
const uint32_t tone_length;
|
|
|
|
const uint32_t pause_length;
|
|
|
|
};
|
|
|
|
|
2016-08-16 20:55:34 -04:00
|
|
|
// TODO: use streaming buffer instead
|
2016-01-29 18:28:05 -05:00
|
|
|
class FIFOSignalMessage : public Message {
|
|
|
|
public:
|
2016-08-06 02:49:45 -04:00
|
|
|
constexpr FIFOSignalMessage(
|
2016-01-29 18:28:05 -05:00
|
|
|
) : Message { ID::FIFOSignal }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-16 20:55:34 -04:00
|
|
|
char signaltype = 0;
|
2016-01-29 18:28:05 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class FIFODataMessage : public Message {
|
|
|
|
public:
|
2016-08-06 02:49:45 -04:00
|
|
|
constexpr FIFODataMessage(
|
2016-08-16 22:17:24 -04:00
|
|
|
const int8_t * data
|
2016-08-06 02:49:45 -04:00
|
|
|
) : Message { ID::FIFOData },
|
2016-08-16 22:17:24 -04:00
|
|
|
data ( data )
|
2016-01-29 18:28:05 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-16 22:17:24 -04:00
|
|
|
const int8_t * data;
|
2016-01-29 18:28:05 -05:00
|
|
|
};
|
|
|
|
|
2016-06-21 15:05:55 -04:00
|
|
|
class CaptureThreadDoneMessage : public Message {
|
2015-07-08 11:39:24 -04:00
|
|
|
public:
|
2016-06-21 15:05:55 -04:00
|
|
|
constexpr CaptureThreadDoneMessage(
|
2016-06-21 14:53:07 -04:00
|
|
|
uint32_t error = 0
|
2016-06-21 15:05:55 -04:00
|
|
|
) : Message { ID::CaptureThreadDone },
|
2016-06-21 14:04:10 -04:00
|
|
|
error { error }
|
|
|
|
{
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
2016-06-21 14:04:10 -04:00
|
|
|
uint32_t error;
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2017-01-10 14:45:40 -05:00
|
|
|
class ReplayThreadDoneMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ReplayThreadDoneMessage(
|
|
|
|
uint32_t error = 0
|
|
|
|
) : Message { ID::ReplayThreadDone },
|
|
|
|
error { error }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t error;
|
|
|
|
};
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
#endif/*__MESSAGE_H__*/
|