diff options
| author | Dan Halbert <halbert@halwitz.org> | 2020-06-15 16:35:51 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2020-06-15 16:35:51 -0400 |
| commit | 81896930c7a91447c8830003e8cf92dce28db3d4 (patch) | |
| tree | abf757304c649327ce2add99d92b287f8b494a8e /shared-module | |
| parent | 9285252fbcbe4db654bc69621210883380fb6981 (diff) | |
Fix ScanEntry prefix matching for all
Diffstat (limited to 'shared-module')
| -rw-r--r-- | shared-module/_bleio/ScanEntry.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/shared-module/_bleio/ScanEntry.c b/shared-module/_bleio/ScanEntry.c index 785209c4a..91712baad 100644 --- a/shared-module/_bleio/ScanEntry.c +++ b/shared-module/_bleio/ScanEntry.c @@ -56,12 +56,19 @@ bool bleio_scanentry_data_matches(const uint8_t* data, size_t len, const uint8_t if (prefixes_length == 0) { return true; } + if (len == 0) { + // Prefixes exist, but no data. + return false; + } size_t i = 0; while(i < prefixes_length) { uint8_t prefix_length = prefixes[i]; i += 1; size_t j = 0; + bool prefix_matched = false; + mp_printf(&mp_plat_print,"i %d\n", i); // XXX while (j < len) { + mp_printf(&mp_plat_print," j %d\n", j); // XXX uint8_t structure_length = data[j]; j += 1; if (structure_length == 0) { @@ -71,13 +78,21 @@ bool bleio_scanentry_data_matches(const uint8_t* data, size_t len, const uint8_t if (any) { return true; } - } else if (!any) { - return false; + prefix_matched = true; + mp_printf(&mp_plat_print," match\n"); // XXX + break; } j += structure_length; } + // If all (!any), the current prefix must have matched at least one field. + if (!prefix_matched && !any) { + mp_printf(&mp_plat_print,"<prefix not matched\n"); // XXX + return false; + } i += prefix_length; } + // All prefixes matched some field (if !any), or none did (if any). + mp_printf(&mp_plat_print,"<all matched\n"); // XXX return !any; } |
