Skip to content

CircusPython_BLE: update for CircuitPython 5.0.0-beta.0 #934

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

Merged
merged 2 commits into from
Nov 20, 2019

Conversation

dhalbert
Copy link
Contributor

First redone Learn Guide code for new BLE API. Program structure somewhat simplified.

@tannewt adding you in case you have general BLE-use style suggestions. We might think about some helper functions (like making advertising simpler).

Tested on my CircusPython rig with current Bluefruit app.

@dhalbert dhalbert requested review from tannewt and ladyada November 20, 2019 02:26
@dhalbert
Copy link
Contributor Author

dhalbert commented Nov 20, 2019

I think the most obvious helper function would be to add start_advertising() to Service.

from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

ble = BLERadio()
uart_service = UARTService()
advertisement = ProvideServicesAdvertisement(uart_service)

ble.start_advertising(advertisement)

Reduce that to:

from adafruit_ble import BLERadio
from adafruit_ble.services.nordic import UARTService

ble = BLERadio()
uart_service = UARTService()

uart_service.start_advertising(ble)    # or ble.start_advertising(uart_service)

One less import, and one less line of code.

@dhalbert dhalbert changed the title update for CircuitPython 5.0.0-beta.0 CircusPython_BLE: update for CircuitPython 5.0.0-beta.0 Nov 20, 2019
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated example looks good!

My preference would be to leave the advertising as is rather than add a helper. Adding a helper blurs the two phases of BLE. The first is advertising and the second is service-oriented. It is a little longer but I think it is clearer.

@dhalbert dhalbert merged commit 8fced95 into adafruit:master Nov 20, 2019
@dhalbert dhalbert deleted the cpy5-circuspython branch November 20, 2019 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants