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

BTLE RX: fix for name disappearing #1575

Merged
merged 2 commits into from
Nov 12, 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
cleanings
GullCode committed Nov 12, 2023
commit 9e639b1a50b22f100508c015c56d298725b33716
16 changes: 7 additions & 9 deletions firmware/application/apps/ble_rx_app.cpp
Original file line number Diff line number Diff line change
@@ -547,29 +547,27 @@ void BLERxView::updateEntry(const BlePacketData* packet, BleRecentEntry& entry,

entry.include_name = check_name.value();

// Only parse name for advertisment packets
// Only parse name for advertisment packets and empty name entries
if ((pdu_type == ADV_IND || pdu_type == ADV_NONCONN_IND || pdu_type == SCAN_RSP || pdu_type == ADV_SCAN_IND) && entry.nameString.empty()) {
uint8_t currentByte = 0;
uint8_t length = 0;
uint8_t type = 0;

bool stringFound = false;

std::string decoded_data;
for (currentByte = 0; (currentByte < entry.packetData.dataLen);) {
length = entry.packetData.data[currentByte++];
type = entry.packetData.data[currentByte++];

// Subtract 1 because type is part of the length.
for (int i = 0; i < length - 1; i++) {
if (((type == 0x08) || (type == 0x09)) && !stringFound) {
entry.nameString += (char)entry.packetData.data[currentByte];
if (type == 0x08 || type == 0x09) {
decoded_data += (char)entry.packetData.data[currentByte];
}

currentByte++;
}

if (!entry.nameString.empty()) {
stringFound = true;
if (!decoded_data.empty()) {
entry.nameString = std::move(decoded_data);
break;
}
}
}