Skip to content
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

Fix type annotation for ServiceData #194

Closed
konistehrad opened this issue Apr 16, 2024 · 5 comments · Fixed by #195
Closed

Fix type annotation for ServiceData #194

konistehrad opened this issue Apr 16, 2024 · 5 comments · Fixed by #195

Comments

@konistehrad
Copy link

konistehrad commented Apr 16, 2024

I’m currently implementing Improv WiFi in CircuitPython for release as a library, but I’m having trouble hitting one part of the specification, namely the service data format. Specifically: I don’t see any example code on how to attach it to an Advertisement, or how to modify its UUID to the requisite value of 4677. Any assistance you could provide would be much appreciated. Thanks!

@dhalbert
Copy link
Collaborator

ServiceData is a class in advertising/standard.py. You pass its constructor a Service, which includes a UUID. There is an an example of using ServiceData in the Eddystone beacon library: https://github.com/adafruit/Adafruit_CircuitPython_BLE_Eddystone/blob/main/adafruit_ble_eddystone/__init__.py

@konistehrad
Copy link
Author

Right, I did see that. The Eddystone tip is a good one I'm going to eval that now. In the meantime, are the type annotations for ServiceData's constructor incorrect? They claim to take a Characteristic, should that be a Service?

https://github.com/adafruit/Adafruit_CircuitPython_BLE/blob/main/adafruit_ble/advertising/standard.py#L356

@dhalbert
Copy link
Collaborator

Yup, that's definitely an annotation bug -- thanks for pointing that out. I'll change the title and submit a PR for that.

@dhalbert dhalbert changed the title How to utilize ServiceData advertising field? (Improv WiFi) Fix type annotation for ServiceData Apr 16, 2024
@konistehrad
Copy link
Author

Awesome thanks for being so quick on this. I'm not sure if this is the best place to continue the conversation, but what's the correct way to consume StreamIn and StreamOut? In particular, there's an RPC Command characteristic that must receive multiple packets to form itself, and while I've found some templates to do this (in for example adafruit_ble_apple_notification_center) nothing concrete has shown its head. Is there some kind of template code to use Generators to monitor characteristics, or is that the best to reference?

@tannewt
Copy link
Member

tannewt commented Apr 24, 2024

Awesome thanks for being so quick on this. I'm not sure if this is the best place to continue the conversation, but what's the correct way to consume StreamIn and StreamOut? In particular, there's an RPC Command characteristic that must receive multiple packets to form itself, and while I've found some templates to do this (in for example adafruit_ble_apple_notification_center) nothing concrete has shown its head. Is there some kind of template code to use Generators to monitor characteristics, or is that the best to reference?

Discord's #circuitpython-dev may be a better place. If you are using Adafruit hardware then the technical support forum. The UART example is probably the best use reference: https://github.com/adafruit/Adafruit_CircuitPython_BLE/blob/main/examples/ble_uart_echo_client.py

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 a pull request may close this issue.

3 participants