Skip to content

Commit 67869a7

Browse files
stoprocentMarek Serafin
and
Marek Serafin
authored
feat(hci): added missing reset function (#4)
* chore(actions): on pull request * fix(prebuildify): patch only on cross * feat(hci): added missing reset function * fix(hci): cleanup reset --------- Co-authored-by: Marek Serafin <[email protected]>
1 parent 6037396 commit 67869a7

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/workflows/build.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Build
22
on:
33
push:
4-
branches:
5-
- main
6-
- beta
4+
pull_request:
75
concurrency:
86
group: build-${{ github.ref }}
97
cancel-in-progress: false
@@ -60,6 +58,7 @@ jobs:
6058
needs: prebuild
6159
name: Release
6260
runs-on: ubuntu-latest
61+
if: github.ref == 'refs/heads/main'
6362
steps:
6463
- uses: actions/checkout@v4
6564
- uses: actions/download-artifact@v4

lib/native.js

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const { BluetoothHciSocket } = require('node-gyp-build')(dir);
55

66
inherits(BluetoothHciSocket, events.EventEmitter);
77

8+
const HCI_COMMAND_PKT = 0x01;
9+
const OGF_HOST_CTL = 0x03;
10+
const OCF_RESET = 0x0003;
11+
812
class BluetoothHciSocketWrapped extends BluetoothHciSocket {
913
start () {
1014
if (this._timer) {
@@ -22,6 +26,14 @@ class BluetoothHciSocketWrapped extends BluetoothHciSocket {
2226
clearInterval(this._timer);
2327
return super.stop();
2428
}
29+
30+
reset () {
31+
const cmd = Buffer.alloc(4);
32+
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
33+
cmd.writeUInt16LE(OCF_RESET | OGF_HOST_CTL << 10, 1);
34+
cmd.writeUInt8(0x00, 3);
35+
this.write(cmd);
36+
}
2537
}
2638

2739
// extend prototype

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@
6161
},
6262
"scripts": {
6363
"install": "node-gyp-build",
64-
"postinstall": "patch-package",
6564
"lint": "eslint \"**/*.js\"",
6665
"lint-fix": "eslint \"**/*.js\" --fix",
6766
"prebuildify": "prebuildify --napi --target 17.0.0 --force --strip --verbose",
68-
"prebuildify-cross": "prebuildify-cross --napi --target 17.0.0 --force --strip --verbose",
67+
"prebuildify-cross": "patch-package && prebuildify-cross --napi --target 17.0.0 --force --strip --verbose",
6968
"semantic-release": "semantic-release",
7069
"pretest": "npm run rebuild",
7170
"rebuild": "node-gyp rebuild",

0 commit comments

Comments
 (0)