|
45 | 45 | //| """Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`."""
|
46 | 46 | //| ...
|
47 | 47 | //|
|
48 |
| -//| def matches(self, prefixes: ScanEntry, *, all: bool = True) -> bool: |
49 |
| -//| """Returns True if the ScanEntry matches all prefixes when ``all`` is True. This is stricter |
| 48 | +//| def matches(self, prefixes: ScanEntry, *, match_all: bool = True) -> bool: |
| 49 | +//| """Returns True if the ScanEntry matches all prefixes when ``match_all`` is True. This is stricter |
50 | 50 | //| than the scan filtering which accepts any advertisements that match any of the prefixes
|
51 |
| -//| where all is False.""" |
| 51 | +//| where ``match_all`` is False. |
| 52 | +//| |
| 53 | +//| ``all`` also works for ``match_all`` but will be removed in CircuitPython 8.""" |
52 | 54 | //| ...
|
53 | 55 | //|
|
54 | 56 | STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
55 | 57 | bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
56 | 58 |
|
57 |
| - enum { ARG_prefixes, ARG_all }; |
| 59 | + enum { ARG_prefixes, ARG_all, ARG_match_all }; |
58 | 60 | static const mp_arg_t allowed_args[] = {
|
59 | 61 | { MP_QSTR_prefixes, MP_ARG_OBJ | MP_ARG_REQUIRED },
|
60 | 62 | { MP_QSTR_all, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
|
| 63 | + { MP_QSTR_match_all, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, |
61 | 64 | };
|
62 | 65 |
|
63 | 66 | mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
64 | 67 | mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
65 | 68 |
|
| 69 | + bool match_all = args[ARG_all].u_bool && args[ARG_match_all].u_bool; |
66 | 70 |
|
67 | 71 | mp_buffer_info_t bufinfo;
|
68 | 72 | mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ);
|
69 |
| - return mp_obj_new_bool(common_hal_bleio_scanentry_matches(self, bufinfo.buf, bufinfo.len, args[ARG_all].u_bool)); |
| 73 | + return mp_obj_new_bool(common_hal_bleio_scanentry_matches(self, bufinfo.buf, bufinfo.len, match_all)); |
70 | 74 | }
|
71 | 75 | STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 2, bleio_scanentry_matches);
|
72 | 76 |
|
|
0 commit comments