Merge pull request #3036 from dhalbert/prefix-match-all
Fix ScanEntry prefix matching for any=False
This commit is contained in:
commit
0e3cad04b7
@ -56,11 +56,16 @@ bool bleio_scanentry_data_matches(const uint8_t* data, size_t len, const uint8_t
|
|||||||
if (prefixes_length == 0) {
|
if (prefixes_length == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (len == 0) {
|
||||||
|
// Prefixes exist, but no data.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while(i < prefixes_length) {
|
while(i < prefixes_length) {
|
||||||
uint8_t prefix_length = prefixes[i];
|
uint8_t prefix_length = prefixes[i];
|
||||||
i += 1;
|
i += 1;
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
|
bool prefix_matched = false;
|
||||||
while (j < len) {
|
while (j < len) {
|
||||||
uint8_t structure_length = data[j];
|
uint8_t structure_length = data[j];
|
||||||
j += 1;
|
j += 1;
|
||||||
@ -71,13 +76,18 @@ bool bleio_scanentry_data_matches(const uint8_t* data, size_t len, const uint8_t
|
|||||||
if (any) {
|
if (any) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (!any) {
|
prefix_matched = true;
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
j += structure_length;
|
j += structure_length;
|
||||||
}
|
}
|
||||||
|
// If all (!any), the current prefix must have matched at least one field.
|
||||||
|
if (!prefix_matched && !any) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
i += prefix_length;
|
i += prefix_length;
|
||||||
}
|
}
|
||||||
|
// All prefixes matched some field (if !any), or none did (if any).
|
||||||
return !any;
|
return !any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user