More btle improvements (#1549)

* Cleanup of BLE Rx naming and added switching between the two.
Fixed bug in packet count not resetting when opening new file in BLE Tx
* Bug fix and color change.
This commit is contained in:
Netro 2023-11-03 03:08:49 -04:00 committed by GitHub
parent f67fe262bb
commit 1639348b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 15 deletions

View File

@ -244,7 +244,7 @@ set(CPPSRC
apps/ais_app.cpp apps/ais_app.cpp
apps/analog_audio_app.cpp apps/analog_audio_app.cpp
apps/analog_tv_app.cpp apps/analog_tv_app.cpp
apps/ble_app.cpp apps/ble_rx_app.cpp
apps/ble_tx_app.cpp apps/ble_tx_app.cpp
apps/capture_app.cpp apps/capture_app.cpp
apps/ert_app.cpp apps/ert_app.cpp

View File

@ -21,7 +21,9 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#include "ble_app.hpp" #include "ble_rx_app.hpp"
#include "ble_tx_app.hpp"
#include "ui_modemsetup.hpp" #include "ui_modemsetup.hpp"
#include "modems.hpp" #include "modems.hpp"
@ -198,7 +200,7 @@ static std::uint64_t get_freq_by_channel_number(uint8_t channel_number) {
} }
void BLERxView::focus() { void BLERxView::focus() {
field_frequency.focus(); options_channel.focus();
} }
BLERxView::BLERxView(NavigationView& nav) BLERxView::BLERxView(NavigationView& nav)
@ -216,6 +218,7 @@ BLERxView::BLERxView(NavigationView& nav)
&label_sort, &label_sort,
&options_sort, &options_sort,
&button_message, &button_message,
&button_switch,
&recent_entries_view, &recent_entries_view,
&recent_entries_filter_view, &recent_entries_filter_view,
&recent_entry_detail_view}); &recent_entry_detail_view});
@ -241,6 +244,11 @@ BLERxView::BLERxView(NavigationView& nav)
}); });
}; };
button_switch.on_select = [this, &nav](Button&) {
nav.pop();
nav.push<BLETxView>();
};
field_frequency.set_step(0); field_frequency.set_step(0);
check_log.set_value(logging); check_log.set_value(logging);
@ -254,7 +262,7 @@ BLERxView::BLERxView(NavigationView& nav)
field_frequency.set_value(get_freq_by_channel_number(i)); field_frequency.set_value(get_freq_by_channel_number(i));
channel_number = i; channel_number = i;
baseband::set_btle(channel_number); baseband::set_btlerx(channel_number);
}; };
options_sort.on_change = [this](size_t, int32_t i) { options_sort.on_change = [this](size_t, int32_t i) {
@ -294,7 +302,7 @@ BLERxView::BLERxView(NavigationView& nav)
logger->append(LOG_ROOT_DIR "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT"); logger->append(LOG_ROOT_DIR "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
// Auto-configure modem for LCR RX (will be removed later) // Auto-configure modem for LCR RX (will be removed later)
baseband::set_btle(channel_number); baseband::set_btlerx(channel_number);
receiver_model.enable(); receiver_model.enable();
} }
@ -399,7 +407,7 @@ void BLERxView::on_switch_table(const std::string value) {
void BLERxView::set_parent_rect(const Rect new_parent_rect) { void BLERxView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect); View::set_parent_rect(new_parent_rect);
const Rect content_rect{0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height}; const Rect content_rect{0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height - switch_button_height};
recent_entries_view.set_parent_rect(content_rect); recent_entries_view.set_parent_rect(content_rect);
recent_entry_detail_view.set_parent_rect(content_rect); recent_entry_detail_view.set_parent_rect(content_rect);
recent_entries_filter_view.set_parent_rect(content_rect); recent_entries_filter_view.set_parent_rect(content_rect);

View File

@ -21,8 +21,8 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __BLE_APP_H__ #ifndef __BLE_RX_APP_H__
#define __BLE_APP_H__ #define __BLE_RX_APP_H__
#include "ui.hpp" #include "ui.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
@ -170,7 +170,8 @@ class BLERxView : public View {
std::string filterBuffer{}; std::string filterBuffer{};
std::string filter{}; std::string filter{};
static constexpr auto header_height = 12 + 2 * 16; static constexpr auto header_height = 3 * 16;
static constexpr auto switch_button_height = 3 * 16;
OptionsField options_channel{ OptionsField options_channel{
{0 * 8, 0 * 8}, {0 * 8, 0 * 8},
@ -221,6 +222,10 @@ class BLERxView : public View {
Console console{ Console console{
{0, 4 * 16, 240, 240}}; {0, 4 * 16, 240, 240}};
Button button_switch{
{8 * 8, 16 * 16, 14 * 8, 2 * 16},
"Switch to Tx"};
std::string str_log{""}; std::string str_log{""};
bool logging{false}; bool logging{false};

View File

@ -22,6 +22,7 @@
*/ */
#include "ble_tx_app.hpp" #include "ble_tx_app.hpp"
#include "ble_rx_app.hpp"
#include "ui_fileman.hpp" #include "ui_fileman.hpp"
#include "ui_modemsetup.hpp" #include "ui_modemsetup.hpp"
@ -285,6 +286,7 @@ BLETxView::BLETxView(NavigationView& nav)
&label_mac_address, &label_mac_address,
&text_mac_address, &text_mac_address,
&label_data_packet, &label_data_packet,
&button_switch,
&console}); &console});
field_frequency.set_step(0); field_frequency.set_step(0);
@ -319,10 +321,16 @@ BLETxView::BLETxView(NavigationView& nav)
on_file_changed(new_file_path); on_file_changed(new_file_path);
}; };
}; };
button_switch.on_select = [this, &nav](Button&) {
nav.pop();
nav.push<BLERxView>();
};
} }
void BLETxView::on_file_changed(const fs::path& new_file_path) { void BLETxView::on_file_changed(const fs::path& new_file_path) {
file_path = fs::path(u"/") + new_file_path; file_path = fs::path(u"/") + new_file_path;
num_packets = 0;
{ // Get the size of the data file. { // Get the size of the data file.
File data_file; File data_file;
@ -398,7 +406,7 @@ void BLETxView::update_packet_display(BLETxPacket packet) {
void BLETxView::set_parent_rect(const Rect new_parent_rect) { void BLETxView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect); View::set_parent_rect(new_parent_rect);
const Rect content_rect{0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height}; const Rect content_rect{0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height - switch_button_height};
console.set_parent_rect(content_rect); console.set_parent_rect(content_rect);
} }

View File

@ -154,6 +154,7 @@ class BLETxView : public View {
PKT_TYPE pduType = {DISCOVERY}; PKT_TYPE pduType = {DISCOVERY};
static constexpr auto header_height = 9 * 16; static constexpr auto header_height = 9 * 16;
static constexpr auto switch_button_height = 3 * 16;
Button button_open{ Button button_open{
{0 * 8, 0 * 16, 10 * 8, 2 * 16}, {0 * 8, 0 * 16, 10 * 8, 2 * 16},
@ -249,6 +250,10 @@ class BLETxView : public View {
Console console{ Console console{
{0, 8 * 16, 240, 240}}; {0, 8 * 16, 240, 240}};
Button button_switch{
{8 * 8, 16 * 16, 14 * 8, 2 * 16},
"Switch to Rx"};
std::string str_log{""}; std::string str_log{""};
bool logging{true}; bool logging{true};
bool logging_done{false}; bool logging_done{false};

View File

@ -70,7 +70,7 @@ BTLERxView::BTLERxView(NavigationView& nav)
}; };
// Auto-configure modem for LCR RX (will be removed later) // Auto-configure modem for LCR RX (will be removed later)
baseband::set_btle(channel_number); baseband::set_btlerx(channel_number);
audio::set_rate(audio::Rate::Hz_24000); audio::set_rate(audio::Rate::Hz_24000);
audio::output::start(); audio::output::start();

View File

@ -149,7 +149,7 @@ void set_aprs(const uint32_t baudrate) {
send_message(&message); send_message(&message);
} }
void set_btle(uint8_t channel_number) { void set_btlerx(uint8_t channel_number) {
const BTLERxConfigureMessage message{ const BTLERxConfigureMessage message{
channel_number}; channel_number};
send_message(&message); send_message(&message);

View File

@ -72,7 +72,7 @@ void set_afsk(const uint32_t baudrate, const uint32_t word_length, const uint32_
void set_fsk(const size_t deviation); void set_fsk(const size_t deviation);
void set_aprs(const uint32_t baudrate); void set_aprs(const uint32_t baudrate);
void set_btle(uint8_t channel_number); void set_btlerx(uint8_t channel_number);
void set_btletx(uint8_t channel_number, char* macAddress, char* advertisementData, uint8_t pduType); void set_btletx(uint8_t channel_number, char* macAddress, char* advertisementData, uint8_t pduType);
void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word); void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word);

View File

@ -86,7 +86,7 @@
#include "ais_app.hpp" #include "ais_app.hpp"
#include "analog_audio_app.hpp" #include "analog_audio_app.hpp"
#include "analog_tv_app.hpp" #include "analog_tv_app.hpp"
#include "ble_app.hpp" #include "ble_rx_app.hpp"
#include "ble_tx_app.hpp" #include "ble_tx_app.hpp"
#include "capture_app.hpp" #include "capture_app.hpp"
#include "ert_app.hpp" #include "ert_app.hpp"
@ -551,7 +551,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
{"APRS", Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push<APRSRXView>(); }}, {"APRS", Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push<APRSRXView>(); }},
{"Audio", Color::green(), &bitmap_icon_speaker, [&nav]() { nav.push<AnalogAudioView>(); }}, {"Audio", Color::green(), &bitmap_icon_speaker, [&nav]() { nav.push<AnalogAudioView>(); }},
//{"BTLE", Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push<BTLERxView>(); }}, //{"BTLE", Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push<BTLERxView>(); }},
{"BLE", Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push<BLERxView>(); }}, {"BLE Rx", Color::green(), &bitmap_icon_btle, [&nav]() { nav.push<BLERxView>(); }},
{"ERT Meter", Color::green(), &bitmap_icon_ert, [&nav]() { nav.push<ERTAppView>(); }}, {"ERT Meter", Color::green(), &bitmap_icon_ert, [&nav]() { nav.push<ERTAppView>(); }},
{"Level", Color::green(), &bitmap_icon_options_radio, [&nav]() { nav.push<LevelView>(); }}, {"Level", Color::green(), &bitmap_icon_options_radio, [&nav]() { nav.push<LevelView>(); }},
{"NRF", Color::yellow(), &bitmap_icon_nrf, [&nav]() { nav.push<NRFRxView>(); }}, {"NRF", Color::yellow(), &bitmap_icon_nrf, [&nav]() { nav.push<NRFRxView>(); }},