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

Disconnect gracefully when error occures #4

Merged
merged 1 commit into from
Nov 21, 2022

Conversation

holgerl
Copy link
Contributor

@holgerl holgerl commented Aug 2, 2022

Instead of printing the error, you can gracefully disconnect every time with finally. The console will look liek this in event of an error:

ble.js:7 Requesting Bluetooth Device...
ble.js:15 Connecting to GATT Server...
ble.js:18 Getting Service...
ble.js:21 Getting Characteristics...
ble.js:27 Reading Characteristics...
ble.js:30 hi!
ble.js:50 disconnect
ble.js:54 Uncaught (in promise) DOMException: GATT Error: Not supported.
    onButtonClick @ ble.js:54
    await in onButtonClick (async)
    onclick @ index.html:10

Instead of printing the error, you can gracefully disconnect every time with finally. The console will look liek this in event of an error:

```
ble.js:7 Requesting Bluetooth Device...
ble.js:15 Connecting to GATT Server...
ble.js:18 Getting Service...
ble.js:21 Getting Characteristics...
ble.js:27 Reading Characteristics...
ble.js:30 hi!
ble.js:50 disconnect
ble.js:54 Uncaught (in promise) DOMException: GATT Error: Not supported.
    onButtonClick @ ble.js:54
    await in onButtonClick (async)
    onclick @ index.html:10
```
@naoki-sawada naoki-sawada merged commit 2e1ef84 into naoki-sawada:master Nov 21, 2022
naoki-sawada added a commit that referenced this pull request Nov 22, 2022
Disconnect method has been moved to the finally block.
#4
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.

None yet

2 participants