diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index 680048db..856d867f 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -244,7 +244,7 @@ set(CPPSRC apps/ais_app.cpp apps/analog_audio_app.cpp apps/analog_tv_app.cpp - apps/ble_app.cpp + apps/ble_rx_app.cpp apps/ble_tx_app.cpp apps/capture_app.cpp apps/ert_app.cpp diff --git a/firmware/application/apps/ble_app.cpp b/firmware/application/apps/ble_rx_app.cpp similarity index 97% rename from firmware/application/apps/ble_app.cpp rename to firmware/application/apps/ble_rx_app.cpp index e98994ed..8fccb720 100644 --- a/firmware/application/apps/ble_app.cpp +++ b/firmware/application/apps/ble_rx_app.cpp @@ -21,7 +21,9 @@ * Boston, MA 02110-1301, USA. */ -#include "ble_app.hpp" +#include "ble_rx_app.hpp" +#include "ble_tx_app.hpp" + #include "ui_modemsetup.hpp" #include "modems.hpp" @@ -198,7 +200,7 @@ static std::uint64_t get_freq_by_channel_number(uint8_t channel_number) { } void BLERxView::focus() { - field_frequency.focus(); + options_channel.focus(); } BLERxView::BLERxView(NavigationView& nav) @@ -216,6 +218,7 @@ BLERxView::BLERxView(NavigationView& nav) &label_sort, &options_sort, &button_message, + &button_switch, &recent_entries_view, &recent_entries_filter_view, &recent_entry_detail_view}); @@ -241,6 +244,11 @@ BLERxView::BLERxView(NavigationView& nav) }); }; + button_switch.on_select = [this, &nav](Button&) { + nav.pop(); + nav.push(); + }; + field_frequency.set_step(0); check_log.set_value(logging); @@ -254,7 +262,7 @@ BLERxView::BLERxView(NavigationView& nav) field_frequency.set_value(get_freq_by_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) { @@ -294,7 +302,7 @@ BLERxView::BLERxView(NavigationView& nav) logger->append(LOG_ROOT_DIR "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT"); // Auto-configure modem for LCR RX (will be removed later) - baseband::set_btle(channel_number); + baseband::set_btlerx(channel_number); 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) { 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_entry_detail_view.set_parent_rect(content_rect); recent_entries_filter_view.set_parent_rect(content_rect); diff --git a/firmware/application/apps/ble_app.hpp b/firmware/application/apps/ble_rx_app.hpp similarity index 96% rename from firmware/application/apps/ble_app.hpp rename to firmware/application/apps/ble_rx_app.hpp index 033963a0..8aac62c9 100644 --- a/firmware/application/apps/ble_app.hpp +++ b/firmware/application/apps/ble_rx_app.hpp @@ -21,8 +21,8 @@ * Boston, MA 02110-1301, USA. */ -#ifndef __BLE_APP_H__ -#define __BLE_APP_H__ +#ifndef __BLE_RX_APP_H__ +#define __BLE_RX_APP_H__ #include "ui.hpp" #include "ui_navigation.hpp" @@ -170,7 +170,8 @@ class BLERxView : public View { std::string filterBuffer{}; 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{ {0 * 8, 0 * 8}, @@ -221,6 +222,10 @@ class BLERxView : public View { Console console{ {0, 4 * 16, 240, 240}}; + Button button_switch{ + {8 * 8, 16 * 16, 14 * 8, 2 * 16}, + "Switch to Tx"}; + std::string str_log{""}; bool logging{false}; diff --git a/firmware/application/apps/ble_tx_app.cpp b/firmware/application/apps/ble_tx_app.cpp index 50db581f..1f7dfb80 100644 --- a/firmware/application/apps/ble_tx_app.cpp +++ b/firmware/application/apps/ble_tx_app.cpp @@ -22,6 +22,7 @@ */ #include "ble_tx_app.hpp" +#include "ble_rx_app.hpp" #include "ui_fileman.hpp" #include "ui_modemsetup.hpp" @@ -285,6 +286,7 @@ BLETxView::BLETxView(NavigationView& nav) &label_mac_address, &text_mac_address, &label_data_packet, + &button_switch, &console}); field_frequency.set_step(0); @@ -319,10 +321,16 @@ BLETxView::BLETxView(NavigationView& nav) on_file_changed(new_file_path); }; }; + + button_switch.on_select = [this, &nav](Button&) { + nav.pop(); + nav.push(); + }; } void BLETxView::on_file_changed(const fs::path& new_file_path) { file_path = fs::path(u"/") + new_file_path; + num_packets = 0; { // Get the size of the 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) { 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); } diff --git a/firmware/application/apps/ble_tx_app.hpp b/firmware/application/apps/ble_tx_app.hpp index 144691ba..761d425d 100644 --- a/firmware/application/apps/ble_tx_app.hpp +++ b/firmware/application/apps/ble_tx_app.hpp @@ -154,6 +154,7 @@ class BLETxView : public View { PKT_TYPE pduType = {DISCOVERY}; static constexpr auto header_height = 9 * 16; + static constexpr auto switch_button_height = 3 * 16; Button button_open{ {0 * 8, 0 * 16, 10 * 8, 2 * 16}, @@ -249,6 +250,10 @@ class BLETxView : public View { Console console{ {0, 8 * 16, 240, 240}}; + Button button_switch{ + {8 * 8, 16 * 16, 14 * 8, 2 * 16}, + "Switch to Rx"}; + std::string str_log{""}; bool logging{true}; bool logging_done{false}; diff --git a/firmware/application/apps/ui_btle_rx.cpp b/firmware/application/apps/ui_btle_rx.cpp index a7272011..0f33fdb7 100644 --- a/firmware/application/apps/ui_btle_rx.cpp +++ b/firmware/application/apps/ui_btle_rx.cpp @@ -70,7 +70,7 @@ BTLERxView::BTLERxView(NavigationView& nav) }; // 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::output::start(); diff --git a/firmware/application/baseband_api.cpp b/firmware/application/baseband_api.cpp index e71cb923..1e3c2897 100644 --- a/firmware/application/baseband_api.cpp +++ b/firmware/application/baseband_api.cpp @@ -149,7 +149,7 @@ void set_aprs(const uint32_t baudrate) { send_message(&message); } -void set_btle(uint8_t channel_number) { +void set_btlerx(uint8_t channel_number) { const BTLERxConfigureMessage message{ channel_number}; send_message(&message); diff --git a/firmware/application/baseband_api.hpp b/firmware/application/baseband_api.hpp index 82c80050..dd39b638 100644 --- a/firmware/application/baseband_api.hpp +++ b/firmware/application/baseband_api.hpp @@ -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_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_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word); diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 96e89538..b5c68608 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -86,7 +86,7 @@ #include "ais_app.hpp" #include "analog_audio_app.hpp" #include "analog_tv_app.hpp" -#include "ble_app.hpp" +#include "ble_rx_app.hpp" #include "ble_tx_app.hpp" #include "capture_app.hpp" #include "ert_app.hpp" @@ -551,7 +551,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) { {"APRS", Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push(); }}, {"Audio", Color::green(), &bitmap_icon_speaker, [&nav]() { nav.push(); }}, //{"BTLE", Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push(); }}, - {"BLE", Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push(); }}, + {"BLE Rx", Color::green(), &bitmap_icon_btle, [&nav]() { nav.push(); }}, {"ERT Meter", Color::green(), &bitmap_icon_ert, [&nav]() { nav.push(); }}, {"Level", Color::green(), &bitmap_icon_options_radio, [&nav]() { nav.push(); }}, {"NRF", Color::yellow(), &bitmap_icon_nrf, [&nav]() { nav.push(); }},