Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE Rx/Tx App Cleanup #1570

Merged
merged 19 commits into from
Nov 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Setting to use the name of BLE with a toggle checkbox.
iNetro committed Nov 10, 2023
commit 3b0a838ba88631371470466f113a5564a16b4df5
12 changes: 11 additions & 1 deletion firmware/application/apps/ble_rx_app.cpp
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ void RecentEntriesTable<BleRecentEntries>::draw(
std::string line{};
line.reserve(30);

if (!entry.nameString.empty()) {
if (!entry.nameString.empty() && entry.include_name) {
line = entry.nameString;

if (line.length() < 17) {
@@ -258,6 +258,7 @@ BLERxView::BLERxView(NavigationView& nav)
&options_channel,
&field_frequency,
&check_log,
&check_name,
&label_sort,
&options_sort,
&button_filter,
@@ -294,6 +295,14 @@ BLERxView::BLERxView(NavigationView& nav)
logger->append(LOG_ROOT_DIR "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
};

check_name.set_value(true);

check_name.on_select = [this](Checkbox&, bool v) {

setAllMembersToValue(recent, &BleRecentEntry::include_name, v);
recent_entries_view.set_dirty();
};

options_channel.on_change = [this](size_t, int32_t i) {
field_frequency.set_value(get_freq_by_channel_number(i));
channel_number = i;
@@ -483,6 +492,7 @@ void BLERxView::updateEntry(const BlePacketData* packet, BleRecentEntry& entry)
}

entry.nameString = "";
entry.include_name = check_name.value();

uint8_t currentByte = 0;
uint8_t length = 0;
12 changes: 10 additions & 2 deletions firmware/application/apps/ble_rx_app.hpp
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ struct BleRecentEntry {
std::string timestamp;
std::string dataString;
std::string nameString;
bool include_name;
uint16_t numHits;

BleRecentEntry()
@@ -95,6 +96,7 @@ struct BleRecentEntry {
timestamp{},
dataString{},
nameString{},
include_name{},
numHits{} {
}

@@ -231,15 +233,21 @@ class BLERxView : public View {
{"Name", 4}}};

Button button_filter{
{12 * 8, 3 * 8, 4 * 8, 16},
{11 * 8, 3 * 8, 4 * 8, 16},
"Filter"};

Checkbox check_log{
{20 * 8, 3 * 8},
{17 * 8, 3 * 8},
3,
"Log",
true};

Checkbox check_name{
{23 * 8, 3 * 8},
3,
"Name",
true};

Console console{
{0, 4 * 16, 240, 240}};

11 changes: 11 additions & 0 deletions firmware/application/recent_entries.hpp
Original file line number Diff line number Diff line change
@@ -107,6 +107,17 @@ void resetFilteredEntries(ContainerType& entries, KeySelector keySelector) {
}
}

template <typename ContainerType, typename MemberPtr, typename KeyValue>
void setAllMembersToValue(ContainerType& entries, MemberPtr memberPtr, const KeyValue& keyValue) {
for (auto& entry : entries) {
// Check if the member specified by memberPtr is equal to keyValue
if (entry.*memberPtr != keyValue) {
// Update the member with keyValue
entry.*memberPtr = keyValue;
}
}
}

namespace ui {

using RecentEntriesColumn = std::pair<std::string, size_t>;