Pocsag improvements (#20)

* Update analog_audio_app.cpp (#353)

* Adding phase field (extracted from @jamesshao8 repo)
This commit is contained in:
Erwin Ried 2020-05-09 13:13:21 +02:00 committed by GitHub
parent 3e15baa251
commit 4aaac8545b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 11 deletions

View File

@ -69,6 +69,7 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
&field_vga,
&field_frequency,
&options_bitrate,
&options_phase,
&check_log,
&check_ignore,
&sym_ignore,
@ -99,10 +100,13 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
};
options_bitrate.on_change = [this](size_t, OptionsField::value_t v) {
on_bitrate_changed(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);
};
check_ignore.set_value(ignore);
check_ignore.on_select = [this](Checkbox&, bool v) {
ignore = v;
@ -197,8 +201,8 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
logger->log_raw_data(message->packet, target_frequency());
}
void POCSAGAppView::on_bitrate_changed(const uint32_t new_bitrate) {
baseband::set_pocsag(pocsag_bitrates[new_bitrate]);
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) {

View File

@ -93,6 +93,14 @@ private:
{ "2400bps", 2 }
}
};
OptionsField options_phase {
{ 6 * 8, 21 },
1,
{
{ "P", 0 },
{ "N", 1 },
}
};
Checkbox check_log {
{ 22 * 8, 21 },
3,
@ -124,7 +132,7 @@ private:
void on_packet(const POCSAGPacketMessage * message);
void on_bitrate_changed(const uint32_t new_bitrate);
void on_config_changed(const uint32_t new_bitrate, const bool phase);
uint32_t target_frequency() const;
void set_target_frequency(const uint32_t new_value);

View File

@ -71,6 +71,7 @@ bool POCSAGTXView::start_tx() {
return false;
}
}
MessageType phase = (MessageType)options_phase.selected_index_value();
pocsag_encode(type, BCH_code, options_function.selected_index_value(), message, address, codewords);
@ -79,6 +80,9 @@ bool POCSAGTXView::start_tx() {
progressbar.set_max(total_frames);
transmitter_model.set_sampling_rate(2280000);
transmitter_model.set_rf_amp(true);
transmitter_model.set_lna(40);
transmitter_model.set_vga(40);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable();
@ -86,7 +90,11 @@ bool POCSAGTXView::start_tx() {
bi = 0;
for (i = 0; i < codewords.size(); i++) {
if (phase == 0)
codeword = ~(codewords[i]);
else
codeword = codewords[i];
data_ptr[bi++] = (codeword >> 24) & 0xFF;
data_ptr[bi++] = (codeword >> 16) & 0xFF;
data_ptr[bi++] = (codeword >> 8) & 0xFF;
@ -126,6 +134,7 @@ POCSAGTXView::POCSAGTXView(
&field_address,
&options_type,
&options_function,
&options_phase,
&text_message,
&button_message,
&progressbar,

View File

@ -71,6 +71,7 @@ private:
{ { 3 * 8, 6 * 8 }, "Address:", Color::light_grey() },
{ { 6 * 8, 8 * 8 }, "Type:", Color::light_grey() },
{ { 2 * 8, 10 * 8 }, "Function:", Color::light_grey() },
{ { 5 * 8, 12 * 8 }, "Phase:", Color::light_grey() },
{ { 0 * 8, 14 * 8 }, "Message:", Color::light_grey() }
};
@ -111,6 +112,15 @@ private:
}
};
OptionsField options_phase {
{ 11 * 8, 12 * 8 },
1,
{
{ "P", 0 },
{ "N", 1 },
}
};
Text text_message {
{ 0 * 8, 16 * 8, 16 * 8, 16 },
""

View File

@ -224,9 +224,10 @@ void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit,
send_message(&message);
}
void set_pocsag(const pocsag::BitRate bitrate) {
void set_pocsag(const pocsag::BitRate bitrate, bool phase) {
const POCSAGConfigureMessage message {
bitrate
bitrate,
phase
};
send_message(&message);
}

View File

@ -77,7 +77,7 @@ void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit,
const uint32_t pause_symbols);
void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint32_t shift,
const uint32_t progress_notice);
void set_pocsag(const pocsag::BitRate bitrate);
void set_pocsag(const pocsag::BitRate bitrate, bool phase);
void set_adsb();
void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed);
void set_rds_data(const uint16_t message_length);

View File

@ -47,7 +47,10 @@ void POCSAGProcessor::execute(const buffer_c8_t& buffer) {
const int32_t audio_sample = __SSAT(sample_int, 16);
slicer_sr <<= 1;
if (phase == 0)
slicer_sr |= (audio_sample < 0); // Do we need hysteresis ?
else
slicer_sr |= !(audio_sample < 0);
// Detect transitions to adjust clock
if ((slicer_sr ^ (slicer_sr >> 1)) & 1) {
@ -162,6 +165,7 @@ void POCSAGProcessor::configure(const POCSAGConfigureMessage& message) {
//audio_output.configure(false);
bitrate = message.bitrate;
phase = message.phase;
sphase_delta = 0x10000u * bitrate / POCSAG_AUDIO_RATE;
sphase_delta_half = sphase_delta / 2; // Just for speed
sphase_delta_eighth = sphase_delta / 8;

View File

@ -95,6 +95,7 @@ private:
bool configured = false;
rx_states rx_state { WAITING };
pocsag::BitRate bitrate { pocsag::BitRate::FSK1200 };
bool phase;
uint32_t codeword_count { 0 };
pocsag::POCSAGPacket packet { };

View File

@ -989,13 +989,16 @@ public:
class POCSAGConfigureMessage : public Message {
public:
constexpr POCSAGConfigureMessage(
const pocsag::BitRate bitrate
const pocsag::BitRate bitrate,
const bool phase
) : Message { ID::POCSAGConfigure },
bitrate(bitrate)
bitrate(bitrate),
phase(phase)
{
}
const pocsag::BitRate bitrate;
const bool phase;
};
class ADSBConfigureMessage : public Message {