lsongdev / lsongdev/node-bluetooth

How can I know if the connection is always open ?

Open
#30 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
205
Forks
56
PR merge metrics
No merged PRs in 30d

Description

Hi,

For beginning thank you for this node module :).

I have an electron program that open a bluetooth connection and listening the event "data".

How can I know if the connection is always open ?

Before write data I check if the connection is open with connection.isOpen() but this method return true if the connection has been open and lost.

I have try to listen the events "closed", "close", "failure" without any success.

If the connection has been open and lost, when I write data I have an uncatched exception:
Error : Error reading from connection.

The calls to the write method is in try/catch block

Node version : v8.12.0
node-bluetooth: v1.2.5

Thank you for your help.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by tracing connection.isOpen(), the connection-loss handling, and the write path in node-bluetooth, then reproduce the failure with the stated Node v8.12.0 and node-bluetooth v1.2.5 versions. Done means a lost connection can be detected reliably before writing and does not produce an uncaught error.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, node.js
Domain
embedded-iot, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.