mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-11 07:19:34 -05:00
BLE TX: use text viewer to inject rand data WIP (#1613)
This commit is contained in:
parent
7ceefb1b81
commit
8846926b68
@ -310,7 +310,6 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
&options_speed,
|
||||
&options_channel,
|
||||
&options_adv_type,
|
||||
&button_random,
|
||||
&label_packet_index,
|
||||
&text_packet_index,
|
||||
&label_packets_sent,
|
||||
@ -320,7 +319,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
&label_data_packet,
|
||||
&button_save_packet,
|
||||
&button_switch,
|
||||
&console});
|
||||
&dataEditView});
|
||||
|
||||
field_frequency.set_step(0);
|
||||
|
||||
@ -384,16 +383,6 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
button_switch.on_select = [&nav](Button&) {
|
||||
nav.replace<BLERxView>();
|
||||
};
|
||||
|
||||
button_random.on_select = [this](Button&) {
|
||||
text_prompt(
|
||||
nav_,
|
||||
randomBuffer,
|
||||
64,
|
||||
[this](std::string& buffer) {
|
||||
on_random_data_change(buffer);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
BLETxView::BLETxView(
|
||||
@ -469,8 +458,6 @@ void BLETxView::on_data(uint32_t value, bool is_data) {
|
||||
if (is_data) {
|
||||
str_console += (char)(value);
|
||||
}
|
||||
|
||||
console.write(str_console);
|
||||
}
|
||||
|
||||
void BLETxView::on_random_data_change(std::string value) {
|
||||
@ -488,23 +475,38 @@ void BLETxView::update_current_packet(BLETxPacket packet, uint32_t currentIndex)
|
||||
|
||||
text_mac_address.set(formattedMacAddress);
|
||||
|
||||
console.clear(true);
|
||||
|
||||
for (const std::string& str : strings) {
|
||||
console.writeln(str);
|
||||
}
|
||||
|
||||
packet_counter = packet.packet_count;
|
||||
current_packet = currentIndex;
|
||||
|
||||
dataFile.create(dataTempFilePath);
|
||||
|
||||
for (const std::string& str : strings) {
|
||||
dataFile.write(str.c_str(), str.size());
|
||||
dataFile.write("\n", 1);
|
||||
;
|
||||
}
|
||||
|
||||
dataFile.~File();
|
||||
|
||||
auto result = FileWrapper::open(dataTempFilePath);
|
||||
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
dataFileWrapper = *std::move(result);
|
||||
|
||||
dataEditView.set_font_zoom(true);
|
||||
dataEditView.set_file(*dataFileWrapper);
|
||||
}
|
||||
|
||||
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 - switch_button_height};
|
||||
console.set_parent_rect(content_rect);
|
||||
dataEditView.set_parent_rect(content_rect);
|
||||
}
|
||||
|
||||
BLETxView::~BLETxView() {
|
||||
delete_file(dataTempFilePath);
|
||||
transmitter_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_transmitter.hpp"
|
||||
#include "ui_text_editor.hpp"
|
||||
#include "ui_freq_field.hpp"
|
||||
#include "ui_record_view.hpp"
|
||||
#include "app_settings.hpp"
|
||||
@ -157,6 +158,13 @@ class BLETxView : public View {
|
||||
bool random_mac = false;
|
||||
bool file_override = false;
|
||||
|
||||
TextViewer dataEditView{
|
||||
{0, 9 * 16, 240, 240}};
|
||||
|
||||
std::unique_ptr<FileWrapper> dataFileWrapper{};
|
||||
File dataFile{};
|
||||
std::filesystem::path dataTempFilePath{u"BLETX/dataFileTemp.TXT"};
|
||||
|
||||
static constexpr uint8_t mac_address_size_str{12};
|
||||
static constexpr uint8_t max_packet_size_str{62};
|
||||
static constexpr uint8_t max_packet_repeat_str{10};
|
||||
@ -170,7 +178,7 @@ class BLETxView : public View {
|
||||
|
||||
PKT_TYPE pduType = {PKT_TYPE_DISCOVERY};
|
||||
|
||||
static constexpr auto header_height = 10 * 16;
|
||||
static constexpr auto header_height = 9 * 16;
|
||||
static constexpr auto switch_button_height = 3 * 16;
|
||||
|
||||
Button button_open{
|
||||
@ -242,33 +250,29 @@ class BLETxView : public View {
|
||||
{"SCAN_RSP", PKT_TYPE_SCAN_RSP},
|
||||
{"CONNECT_REQ", PKT_TYPE_CONNECT_REQ}}};
|
||||
|
||||
Button button_random{
|
||||
{0 * 8, 8 * 8, 11 * 8, 16},
|
||||
"Random Data"};
|
||||
|
||||
Labels label_packet_index{
|
||||
{{0 * 8, 12 * 8}, "Packet Index:", Color::light_grey()}};
|
||||
{{0 * 8, 10 * 8}, "Packet Index:", Color::light_grey()}};
|
||||
|
||||
Text text_packet_index{
|
||||
{13 * 8, 6 * 16, 12 * 8, 16},
|
||||
{13 * 8, 5 * 16, 12 * 8, 16},
|
||||
"-"};
|
||||
|
||||
Labels label_packets_sent{
|
||||
{{0 * 8, 14 * 8}, "Packets Left:", Color::light_grey()}};
|
||||
{{0 * 8, 12 * 8}, "Packets Left:", Color::light_grey()}};
|
||||
|
||||
Text text_packets_sent{
|
||||
{13 * 8, 6 * 16, 14 * 8, 16},
|
||||
"-"};
|
||||
|
||||
Labels label_mac_address{
|
||||
{{0 * 8, 16 * 8}, "Mac Address:", Color::light_grey()}};
|
||||
{{0 * 8, 14 * 8}, "Mac Address:", Color::light_grey()}};
|
||||
|
||||
Text text_mac_address{
|
||||
{12 * 8, 8 * 16, 20 * 8, 16},
|
||||
{12 * 8, 7 * 16, 20 * 8, 16},
|
||||
"-"};
|
||||
|
||||
Labels label_data_packet{
|
||||
{{0 * 8, 16 * 9}, "Packet Data:", Color::light_grey()}};
|
||||
{{0 * 8, 8 * 16}, "Packet Data:", Color::light_grey()}};
|
||||
|
||||
Console console{
|
||||
{0, 9 * 16, 240, 240}};
|
||||
|
Loading…
Reference in New Issue
Block a user