Digital modes no longer use ReceiverModel.

AIS/TPMS/ERT were changing receiver mode settings -- not my intent.
This commit is contained in:
Jared Boone 2016-02-10 16:31:52 -08:00
parent 3587300701
commit 5cdbae495a
6 changed files with 116 additions and 43 deletions

View File

@ -25,7 +25,7 @@
#include "string_format.hpp"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
using namespace portapack;
#include <algorithm>
@ -340,22 +340,27 @@ AISAppView::AISAppView(NavigationView&) {
}
}
);
set_target_frequency(initial_target_frequency);
radio::set_rf_amp(false);
radio::set_lna_gain(32);
radio::set_vga_gain(32);
radio::set_baseband_rate(sampling_rate);
radio::set_baseband_decimation_by(1);
radio::set_baseband_filter_bandwidth(baseband_bandwidth);
radio::set_direction(rf::Direction::Receive);
BasebandConfigurationMessage message { {
.mode = 3,
.sampling_rate = sampling_rate,
.decimation_factor = 1,
} };
shared_memory.baseband_queue.push(message);
options_channel.on_change = [this](size_t, OptionsField::value_t v) {
this->on_frequency_changed(v);
};
options_channel.set_by_value(162025000);
receiver_model.set_baseband_configuration({
.mode = 3,
.sampling_rate = 2457600,
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(1750000);
receiver_model.set_rf_amp(false);
receiver_model.set_lna(32);
receiver_model.set_vga(32);
receiver_model.enable();
options_channel.set_by_value(target_frequency());
recent_entries_view.on_select = [this](const AISRecentEntry& entry) {
this->on_show_detail(entry);
@ -366,7 +371,13 @@ AISAppView::AISAppView(NavigationView&) {
}
AISAppView::~AISAppView() {
receiver_model.disable();
shared_memory.baseband_queue.push_and_wait(
BasebandConfigurationMessage {
.configuration = { },
}
);
radio::disable();
EventDispatcher::message_map().unregister_handler(Message::ID::AISPacket);
}
@ -405,8 +416,21 @@ void AISAppView::on_show_detail(const AISRecentEntry& entry) {
recent_entry_detail_view.focus();
}
void AISAppView::on_frequency_changed(const uint32_t new_frequency) {
receiver_model.set_tuning_frequency(new_frequency);
void AISAppView::on_frequency_changed(const uint32_t new_target_frequency) {
set_target_frequency(new_target_frequency);
}
void AISAppView::set_target_frequency(const uint32_t new_value) {
target_frequency_ = new_value;
radio::set_tuning_frequency(tuning_frequency());
}
uint32_t AISAppView::target_frequency() const {
return target_frequency_;
}
uint32_t AISAppView::tuning_frequency() const {
return target_frequency() - (sampling_rate / 4);
}
} /* namespace ui */

View File

@ -145,6 +145,10 @@ public:
std::string title() const override { return "AIS"; };
private:
static constexpr uint32_t initial_target_frequency = 162025000;
static constexpr uint32_t sampling_rate = 2457600;
static constexpr uint32_t baseband_bandwidth = 1750000;
AISRecentEntries recent;
AISLogger logger;
@ -167,11 +171,18 @@ private:
}
};
uint32_t target_frequency_ = initial_target_frequency;
void on_packet(const ais::Packet& packet);
void on_show_list();
void on_show_detail(const AISRecentEntry& entry);
void on_frequency_changed(const uint32_t new_frequency);
void on_frequency_changed(const uint32_t new_target_frequency);
uint32_t target_frequency() const;
void set_target_frequency(const uint32_t new_value);
uint32_t tuning_frequency() const;
};
} /* namespace ui */

View File

@ -23,7 +23,7 @@
#include "event_m0.hpp"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
using namespace portapack;
#include "manchester.hpp"
@ -131,21 +131,31 @@ ERTAppView::ERTAppView(NavigationView&) {
}
);
receiver_model.set_baseband_configuration({
radio::set_tuning_frequency(initial_target_frequency);
radio::set_rf_amp(false);
radio::set_lna_gain(32);
radio::set_vga_gain(32);
radio::set_baseband_rate(sampling_rate);
radio::set_baseband_decimation_by(1);
radio::set_baseband_filter_bandwidth(baseband_bandwidth);
radio::set_direction(rf::Direction::Receive);
BasebandConfigurationMessage message { {
.mode = 6,
.sampling_rate = 4194304,
.sampling_rate = sampling_rate,
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(2500000);
receiver_model.set_rf_amp(false);
receiver_model.set_lna(32);
receiver_model.set_vga(32);
receiver_model.set_tuning_frequency(911600000);
receiver_model.enable();
} };
shared_memory.baseband_queue.push(message);
}
ERTAppView::~ERTAppView() {
receiver_model.disable();
shared_memory.baseband_queue.push_and_wait(
BasebandConfigurationMessage {
.configuration = { },
}
);
radio::disable();
EventDispatcher::message_map().unregister_handler(Message::ID::ERTPacket);
}

View File

@ -74,6 +74,10 @@ using ERTRecentEntriesView = RecentEntriesView<ERTRecentEntries>;
class ERTAppView : public View {
public:
static constexpr uint32_t initial_target_frequency = 911600000;
static constexpr uint32_t sampling_rate = 4194304;
static constexpr uint32_t baseband_bandwidth = 2500000;
ERTAppView(NavigationView& nav);
~ERTAppView();

View File

@ -23,7 +23,7 @@
#include "event_m0.hpp"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
using namespace portapack;
#include "string_format.hpp"
@ -137,13 +137,12 @@ size_t Packet::crc_valid_length() const {
} /* namespace tpms */
void TPMSLogger::on_packet(const tpms::Packet& packet) {
void TPMSLogger::on_packet(const tpms::Packet& packet, const uint32_t target_frequency) {
const auto hex_formatted = packet.symbols_formatted();
if( log_file.is_ready() ) {
const auto tuning_frequency = receiver_model.tuning_frequency();
// TODO: function doesn't take uint64_t, so when >= 1<<32, weirdness will ensue!
const auto tuning_frequency_str = to_string_dec_uint(tuning_frequency, 10);
const auto tuning_frequency_str = to_string_dec_uint(target_frequency, 10);
std::string entry = tuning_frequency_str + " FSK 38.4 19.2 " + hex_formatted.data + "/" + hex_formatted.errors;
log_file.write_entry(packet.received_at(), entry);
@ -239,21 +238,31 @@ TPMSAppView::TPMSAppView(NavigationView&) {
}
);
receiver_model.set_baseband_configuration({
radio::set_tuning_frequency(tuning_frequency());
radio::set_rf_amp(false);
radio::set_lna_gain(32);
radio::set_vga_gain(32);
radio::set_baseband_rate(sampling_rate);
radio::set_baseband_decimation_by(1);
radio::set_baseband_filter_bandwidth(baseband_bandwidth);
radio::set_direction(rf::Direction::Receive);
BasebandConfigurationMessage message { {
.mode = 5,
.sampling_rate = 2457600,
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(1750000);
receiver_model.set_rf_amp(false);
receiver_model.set_lna(32);
receiver_model.set_vga(32);
receiver_model.set_tuning_frequency(315000000);
receiver_model.enable();
} };
shared_memory.baseband_queue.push(message);
}
TPMSAppView::~TPMSAppView() {
receiver_model.disable();
shared_memory.baseband_queue.push_and_wait(
BasebandConfigurationMessage {
.configuration = { },
}
);
radio::disable();
EventDispatcher::message_map().unregister_handler(Message::ID::TPMSPacket);
}
@ -267,7 +276,7 @@ void TPMSAppView::set_parent_rect(const Rect new_parent_rect) {
}
void TPMSAppView::on_packet(const tpms::Packet& packet) {
logger.on_packet(packet);
logger.on_packet(packet, target_frequency());
const auto reading_opt = packet.reading();
if( reading_opt.is_valid() ) {
@ -282,4 +291,12 @@ void TPMSAppView::on_show_list() {
recent_entries_view.focus();
}
uint32_t TPMSAppView::target_frequency() const {
return initial_target_frequency;
}
uint32_t TPMSAppView::tuning_frequency() const {
return target_frequency() - (sampling_rate / 4);
}
} /* namespace ui */

View File

@ -186,7 +186,7 @@ using TPMSRecentEntries = RecentEntries<tpms::Reading, TPMSRecentEntry>;
class TPMSLogger {
public:
void on_packet(const tpms::Packet& packet);
void on_packet(const tpms::Packet& packet, const uint32_t target_frequency);
private:
LogFile log_file { "tpms.txt" };
@ -212,6 +212,10 @@ public:
std::string title() const override { return "TPMS"; };
private:
static constexpr uint32_t initial_target_frequency = 315000000;
static constexpr uint32_t sampling_rate = 2457600;
static constexpr uint32_t baseband_bandwidth = 1750000;
TPMSRecentEntries recent;
TPMSLogger logger;
@ -219,6 +223,9 @@ private:
void on_packet(const tpms::Packet& packet);
void on_show_list();
uint32_t target_frequency() const;
uint32_t tuning_frequency() const;
};
} /* namespace ui */