mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
BTLE RX: fix for name disappearing (#1575)
* Fix for name disappearing * cleanings --------- Co-authored-by: GullCode <gullradriel@hotmail.com>
This commit is contained in:
parent
5953cb57b0
commit
351f7b13b3
@ -545,32 +545,29 @@ void BLERxView::updateEntry(const BlePacketData* packet, BleRecentEntry& entry,
|
|||||||
entry.packetData.data[i] = packet->data[i];
|
entry.packetData.data[i] = packet->data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.nameString = "";
|
|
||||||
entry.include_name = check_name.value();
|
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) {
|
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 currentByte = 0;
|
||||||
uint8_t length = 0;
|
uint8_t length = 0;
|
||||||
uint8_t type = 0;
|
uint8_t type = 0;
|
||||||
|
|
||||||
bool stringFound = false;
|
std::string decoded_data;
|
||||||
|
|
||||||
for (currentByte = 0; (currentByte < entry.packetData.dataLen);) {
|
for (currentByte = 0; (currentByte < entry.packetData.dataLen);) {
|
||||||
length = entry.packetData.data[currentByte++];
|
length = entry.packetData.data[currentByte++];
|
||||||
type = entry.packetData.data[currentByte++];
|
type = entry.packetData.data[currentByte++];
|
||||||
|
|
||||||
// Subtract 1 because type is part of the length.
|
// Subtract 1 because type is part of the length.
|
||||||
for (int i = 0; i < length - 1; i++) {
|
for (int i = 0; i < length - 1; i++) {
|
||||||
if (((type == 0x08) || (type == 0x09)) && !stringFound) {
|
if (type == 0x08 || type == 0x09) {
|
||||||
entry.nameString += (char)entry.packetData.data[currentByte];
|
decoded_data += (char)entry.packetData.data[currentByte];
|
||||||
}
|
}
|
||||||
|
|
||||||
currentByte++;
|
currentByte++;
|
||||||
}
|
}
|
||||||
|
if (!decoded_data.empty()) {
|
||||||
if (!entry.nameString.empty()) {
|
entry.nameString = std::move(decoded_data);
|
||||||
stringFound = true;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user