-
Notifications
You must be signed in to change notification settings - Fork 56
ManufacturerData tweak to offer control over ordering of its data fields #97
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
Conversation
…control over order to increase the utility of prefix matching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea, but could you add a comment to ManufacturerData
describing how to take advantage of the ordering?
…luding what it benefits.
I added a single but long line to the inline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please unify the setting of MICROPY_PY_COLLECTIONS_ORDEREDDICT
into the py/circuitpy_* files so it's on by default too? Looks sporadic now.
@kevinjwalters It was for you but it's fine if we do it later. I've opened adafruit/circuitpython#3278 to track it. What prefix matching are you doing where this is important? Ordering of entries in the advertisement seems outside of the BLE spec. |
It's not the ordering of entries in an advertising packet, it's the ordering of entries within manufacturer data field that interests me and that is what this PR affects. In an application I am using the same approach as Adafruit_CircuitPython_BLE/adafruit_ble/advertising/adafruit.py Lines 51 to 60 in 73a8400
I have multiple manufacturer fields so for prefix matching to work for an id number I need to ensure that one appears first. Multiple fields are attractive as I have an optional field and those are supported well by |
Is the |
Are you thinking about whether OrderedCollection might not be present? Right now the library is only usable on nRF boards and via Blinka. However, I'm finishing up an implementation of _bleio for the ESP32 co-processor, used on Metro M4 Airlift, PyPortal, etc., and it's also available as a breakout. I'm not sure there's enough RAM on SAMD21 boards. You could try importing some of adafruit_ble on a SAMD21 and see whether it fits at all. |
Yes, the other ticket shows it AWOL on some SAMD board and inevitably it is the SAMD21 but I wasn't sure what the plan was for
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! Right. I'm ok adding more semantics to ManufacturerData since it's controlled by us.
I'm also ok using OrderedDict. We should have it available on non-M0 builds going forwards. Just need to centralize it's definition to ensure that. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the doc additions. This looks good for the boards we need to support now. collections.OrderedDict
is available on SAMD51.
Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 7.1.0 from 7.0.3: > Merge pull request adafruit/Adafruit_CircuitPython_BLE#97 from kevinjwalters/dictorderchange Updating https://github.com/adafruit/Adafruit_CircuitPython_MatrixPortal to 1.0.1 from 1.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_MatrixPortal#3 from makermelissa/master
This changes
self.data
from an{}
to anOrderedDict()
to offer more control over the data field ordering for the benefit of the prefix matching.On a side note, my understanding is that big python (CPython) has used an insertion ordered implementation for normal
dict
since 3.6 and this has become part of the language spec now in 3.7