-
Notifications
You must be signed in to change notification settings - Fork 57
Rework the API to use descriptors. #30
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
This makes Advertisement and Service definitions declarative by factoring out parsing logic out into shareable descriptor classes similar to how the Register library works. This also introduces SmartAdapter and SmartConnection which will auto-create the correct Advertisements and Services without requiring any direct use of UUIDs. Instead, classes are used to identify relevant objects to "recognize". This requires adafruit/circuitpython#2236 and relates to adafruit/circuitpython#586.
@theacodes This is the API we chatted about a while back. Would love your thoughts on it. |
Will take a look either tonight or tomorrow. 👍
…On Tue, Oct 22, 2019, 5:34 PM Scott Shawcroft ***@***.***> wrote:
@theacodes <https://github.com/theacodes> This is the API we chatted
about a while back. Would love your thoughts on it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#30?email_source=notifications&email_token=AAB5I46H7AQOYHKZIPTPALTQP6LXZA5CNFSM4JD2FBT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB7UP4Q#issuecomment-545212402>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5I465Z2QO7SKJXXN62DLQP6LXZANCNFSM4JD2FBTQ>
.
|
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.
I like the descriptor design. 👍
Left some other comments, you can take or leave them.
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.
Incomplete review, here are my comments so far.
This renames Smart* to BLE* and removes the smart recognition. It is replaced by knowing the type of what we're interested at use time only. Only printing Service lists is now dumber. Interal variables to _bleio classes are now public as bleio_* instead so that other classes in the library can access them and its clearer what they are.
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.
Ok, please take another look. Things have been simplified and the two bluefruit examples also updated.
Some simple pylint failures. |
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 big talk we had: I have a much better understanding now of the internal structure. Any further internal changes will affect the user API very little or not at all. Only have minor stuff (and pylint fixes).
Thanks also for the reorg, removing the core.py stuff: the source structure is cleaner now.
|
||
ble = BLERadio() | ||
while True: | ||
while ble.connected and any(UARTService in connection for connection in ble.connections): |
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.
Yeah, we really need a helper for this. Maybe:
ble.find_service(UARTService)
With a behavior of Helper method that looks through all connections for a given service and returns the first one found.
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.
We're merging this now and will look for API helpers, etc. when rewriting the current examples. Thanks and we'll keep all these in mind.
k = Keyboard(hid.devices) | ||
kl = KeyboardLayoutUS(k) | ||
while True: | ||
while not ble.connected: |
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 spinning on connected
is becoming a pattern. Maybe a helper ble.wait_for_connection()
with an optional timeout?
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.
Merging this now to keep up with the corresponding CircuitPython PR: adafruit/circuitpython#2236
Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1305 to 1.0.3 from 1.0.2: > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SSD1305#5 from makermelissa/master Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.6.0 from 3.5.6: > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#51 from makermelissa/master > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#47 from Johennes/feature/numpy Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 3.0.0 from 1.0.2: > Merge pull request adafruit/Adafruit_CircuitPython_BLE#34 from dhalbert/check-cpy-version > Merge pull request adafruit/Adafruit_CircuitPython_BLE#32 from dhalbert/doc-and-cleanup > Merge pull request adafruit/Adafruit_CircuitPython_BLE#31 from dhalbert/char-fixes-and-float > Merge pull request adafruit/Adafruit_CircuitPython_BLE#30 from tannewt/api_rework > Merge pull request adafruit/Adafruit_CircuitPython_BLE#29 from adafruit/dherrada-patch-1 > Merge pull request adafruit/Adafruit_CircuitPython_BLE#25 from kattni/plotter-code > Merge pull request adafruit/Adafruit_CircuitPython_BLE#23 from kattni/update-color-picker > Merge pull request adafruit/Adafruit_CircuitPython_BLE#22 from kattni/update-color-picker > Merge pull request adafruit/Adafruit_CircuitPython_BLE#21 from kattni/cpb-color-picker > Merge pull request adafruit/Adafruit_CircuitPython_BLE#18 from dhalbert/bleio-api-revamp > Merge pull request adafruit/Adafruit_CircuitPython_BLE#17 from dhalbert/demo-central > Merge pull request adafruit/Adafruit_CircuitPython_BLE#16 from dhalbert/pairing > Merge pull request adafruit/Adafruit_CircuitPython_BLE#15 from dhalbert/python-advertisement-data
Thank you so much for taking this on @dhalbert.
This makes Advertisement and Service definitions declarative by
factoring out parsing logic out into shareable descriptor classes
similar to how the Register library works.
This also introduces SmartAdapter and SmartConnection which will
auto-create the correct Advertisements and Services without requiring
any direct use of UUIDs. Instead, classes are used to identify
relevant objects to "recognize".
I've added comments to the examples on which should work. I just confirmed that UART mostly still works. The client device safe moded for some reason but I'm out of debugging time. After a button reset it worked ok.
This requires adafruit/circuitpython#2236 and
relates to adafruit/circuitpython#586.