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

Expose JavaScript peripheral advertisments #95

Closed
wants to merge 2 commits into from

Conversation

davidtaylor-juul
Copy link
Contributor

Expose an advertisements property on JsPeripheral via the Web BLE watchAdvertisements method.

The code to do this was already there in order to provide the rssi() functionality. This change provides general access to the peripheral advertisements, and re-implements rssi() using the new property.

There are use cases where certain information is vended solely via the advertisements, so it can be necessary to obtain the advertisements from a connected peripheral in the case where the scanner was not used initially.

@davidtaylor-juul davidtaylor-juul requested review from a team and sdonn3 April 29, 2021 00:21
Comment on lines +68 to +70
runCatching {
offer(Advertisement(it as BluetoothAdvertisingEvent))
}.onFailure {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than use runCatching, we should bump the Coroutines version and use trySend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A quick scan shows five other instances of runCatching in this repo - perhaps the use of this pattern should be reviewed more broadly as a separate issue?

Copy link
Member

Choose a reason for hiding this comment

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

Ya, I am going to update the other usages soon. 👍

@davidtaylor-juul
Copy link
Contributor Author

Closing this PR as decided against exposing this asymmetric portion of API and deferring for now, perhaps until the Web Bluetooth scanning interface is ratified.

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