Detecting bluetooth device disconnects/crashes
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
調査の方向性
lib/connection.js から始めて read callback を調査し、長さ 0 のバッファーと読み取りエラーがどのように発生するかを含めて確認します。issue に記載された Bluetooth のシャットダウン動作を再現し、期待される disconnect event とそのタイミングを特定します。長さ 0 のバッファーが有効な接続中に発生することは不可能だと仮定せずに、disconnect の動作が定義され、カバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi!
I couldn't find a way to detect if a connection has crashed or disconnected so I tried to implement my own.
In lib/connection.js, I noticed that - if I printed the chunks of the read method - they stop printing as soon as I turn off my bluetooth device; after ~20seconds of apparent frozen behavior, this method continued working, printing chunks of zero length buffers.
Thus, I added the following line
if(chunk.length == 0){ self.emit('error')}
in
(function read(){
self.isOpen() && self.port.read((err, chunk) => {
process.nextTick(read);
if(err) return self.emit('error', err);
self.emit('data', chunk);
if(chunk.length == 0){ self.emit('error')}
});
})();
This allows me to fetch error events like so:
connect(address, 1, (err, linkage) => {
if (err) {
console.log('connection attempt error');
} else {
linkage.on('error', (err) => {
console.log('disconnected!);
});
}
)}
However my approach assumes I won't be receiving zero length buffers when connected which I realize that might not always be true (or not for all devices);
Also, any thoughts on how to detect the disconnect before the ~20seconds pass?
Thanks!
- 主要言語
- C++
- スター
- 205
- フォーク
- 56
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lsongdev/node-bluetooth のほかの issue
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
lsongdev/node-bluetooth#61 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
lsongdev/node-bluetooth#60 ·
-
Maintenance status? オープン
難易度 1/5 1時間未満 初心者へのやさしさ 10/100
lsongdev/node-bluetooth#55 · コメント 8 件 ·
-
Battery status? オープン
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
lsongdev/node-bluetooth#54 · コメント 1 件 ·
-
BT node オープン
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
lsongdev/node-bluetooth#53 ·
lsongdev/node-bluetooth の issue をすべて見る
似ている issue
-
ai_reviewed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ydb-platform/ydb#53869 · コメント 3 件 ·
-
bug cert blocker needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
project-chip/connectedhomeip#74373 ·
-
upstream update
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
conan-io/conan-center-index#31035 ·
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
vllm-project/vllm-ascend#17329 ·