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 all commits
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
19 changes: 8 additions & 11 deletions firmware/application/apps/ble_rx_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,32 +545,29 @@ void BLERxView::updateEntry(const BlePacketData* packet, BleRecentEntry& entry,
entry.packetData.data[i] = packet->data[i];
}

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

// Only parse name for advertisment packets
if (pdu_type == ADV_IND || pdu_type == ADV_NONCONN_IND || pdu_type == SCAN_RSP || pdu_type == ADV_SCAN_IND) {
// 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;
}
}
}
Expand Down
Loading