mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 06:49:24 -05:00
BLE: Minor improvements to fix occasional not start on tx app first time. (#1605)
This commit is contained in:
parent
7bc27038be
commit
175e5e2e8c
@ -167,6 +167,9 @@ void BLETxView::toggle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BLETxView::start() {
|
void BLETxView::start() {
|
||||||
|
baseband::run_image(portapack::spi_flash::image_tag_btle_tx);
|
||||||
|
transmitter_model.enable();
|
||||||
|
|
||||||
int randomChannel = channel_number;
|
int randomChannel = channel_number;
|
||||||
|
|
||||||
if (auto_channel) {
|
if (auto_channel) {
|
||||||
@ -192,27 +195,19 @@ void BLETxView::start() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
transmitter_model.enable();
|
|
||||||
button_play.set_bitmap(&bitmap_stop);
|
button_play.set_bitmap(&bitmap_stop);
|
||||||
is_running = true;
|
is_running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send next packet.
|
// Setup next packet configuration.
|
||||||
progressbar.set_max(packets[current_packet].packet_count);
|
progressbar.set_max(packets[current_packet].packet_count);
|
||||||
baseband::set_btletx(randomChannel, random_mac ? randomMac : packets[current_packet].macAddress, packets[current_packet].advertisementData, pduType);
|
baseband::set_btletx(randomChannel, random_mac ? randomMac : packets[current_packet].macAddress, packets[current_packet].advertisementData, pduType);
|
||||||
|
|
||||||
is_sending = true;
|
|
||||||
|
|
||||||
if ((packet_counter % 10) == 0) {
|
|
||||||
text_packets_sent.set(to_string_dec_uint(packet_counter));
|
|
||||||
}
|
|
||||||
|
|
||||||
packet_counter--;
|
|
||||||
progressbar.set_value(packets[current_packet].packet_count - packet_counter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLETxView::stop() {
|
void BLETxView::stop() {
|
||||||
transmitter_model.disable();
|
transmitter_model.disable();
|
||||||
|
baseband::shutdown();
|
||||||
|
|
||||||
progressbar.set_value(0);
|
progressbar.set_value(0);
|
||||||
button_play.set_bitmap(&bitmap_play);
|
button_play.set_bitmap(&bitmap_play);
|
||||||
check_loop.set_value(false);
|
check_loop.set_value(false);
|
||||||
@ -222,30 +217,39 @@ void BLETxView::stop() {
|
|||||||
is_running = false;
|
is_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BLETxView::reset() {
|
||||||
|
transmitter_model.disable();
|
||||||
|
baseband::shutdown();
|
||||||
|
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
// called each 1/60th of second, so 6 = 100ms
|
// called each 1/60th of second, so 6 = 100ms
|
||||||
void BLETxView::on_timer() {
|
void BLETxView::on_timer() {
|
||||||
if (++mscounter == timer_period) {
|
if (++mscounter == timer_period) {
|
||||||
mscounter = 0;
|
mscounter = 0;
|
||||||
|
|
||||||
if (is_active() && !is_sending) {
|
if (is_active()) {
|
||||||
// Reached end of current packet repeats.
|
// Reached end of current packet repeats.
|
||||||
if (packet_counter == 0) {
|
if (packet_counter == 0) {
|
||||||
// Done sending all packets.
|
// Done sending all packets.
|
||||||
if (current_packet == (num_packets - 1)) {
|
if (current_packet == (num_packets - 1)) {
|
||||||
|
current_packet = 0;
|
||||||
|
|
||||||
// If looping, restart from beginning.
|
// If looping, restart from beginning.
|
||||||
if (check_loop.value()) {
|
if (check_loop.value()) {
|
||||||
update_current_packet(packets[current_packet], 0);
|
update_current_packet(packets[current_packet], current_packet);
|
||||||
start();
|
reset();
|
||||||
} else {
|
} else {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
current_packet++;
|
current_packet++;
|
||||||
update_current_packet(packets[current_packet], current_packet);
|
update_current_packet(packets[current_packet], current_packet);
|
||||||
start();
|
reset();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
start();
|
reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,15 +258,18 @@ void BLETxView::on_timer() {
|
|||||||
void BLETxView::on_tx_progress(const bool done) {
|
void BLETxView::on_tx_progress(const bool done) {
|
||||||
if (done) {
|
if (done) {
|
||||||
if (is_active()) {
|
if (is_active()) {
|
||||||
is_sending = false;
|
if ((packet_counter % 10) == 0) {
|
||||||
|
text_packets_sent.set(to_string_dec_uint(packet_counter));
|
||||||
|
}
|
||||||
|
|
||||||
|
packet_counter--;
|
||||||
|
progressbar.set_value(packets[current_packet].packet_count - packet_counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BLETxView::BLETxView(NavigationView& nav)
|
BLETxView::BLETxView(NavigationView& nav)
|
||||||
: nav_{nav} {
|
: nav_{nav} {
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_btle_tx);
|
|
||||||
|
|
||||||
add_children({&button_open,
|
add_children({&button_open,
|
||||||
&text_filename,
|
&text_filename,
|
||||||
&progressbar,
|
&progressbar,
|
||||||
|
@ -108,6 +108,7 @@ class BLETxView : public View {
|
|||||||
void toggle();
|
void toggle();
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
void reset();
|
||||||
void handle_replay_thread_done(const uint32_t return_code);
|
void handle_replay_thread_done(const uint32_t return_code);
|
||||||
void file_error();
|
void file_error();
|
||||||
bool saveFile(const std::filesystem::path& path);
|
bool saveFile(const std::filesystem::path& path);
|
||||||
@ -142,7 +143,6 @@ class BLETxView : public View {
|
|||||||
char randomMac[13] = "010203040506";
|
char randomMac[13] = "010203040506";
|
||||||
|
|
||||||
bool is_running = false;
|
bool is_running = false;
|
||||||
bool is_sending = false;
|
|
||||||
uint64_t timer_count{0};
|
uint64_t timer_count{0};
|
||||||
int16_t timer_period{1};
|
int16_t timer_period{1};
|
||||||
bool repeatLoop = false;
|
bool repeatLoop = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user