Skip to content

Commit 677788e

Browse files
committed
download stack binaries on demand
1 parent 79b23d9 commit 677788e

7 files changed

Lines changed: 79 additions & 13 deletions

.github/workflows/run-zwave-wsl.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ jobs:
1515
- name: Checkout repository
1616
uses: actions/checkout@v4
1717

18-
- name: Extract CTT setup files
19-
shell: powershell
20-
run: |
21-
Write-Host "Extracting CTT setup archive..."
22-
.\setup\extract-setup-archive.ps1
23-
2418
- name: Setup Node.js
2519
uses: actions/setup-node@v4
2620
with:
@@ -41,10 +35,21 @@ jobs:
4135
sudo apt-get update
4236
sudo apt-get install -y libc6:i386 libstdc++6:i386
4337
38+
- name: Download Z-Wave stack binaries
39+
env:
40+
GH_TOKEN: ${{ secrets.ZW_STACK_TOKEN }}
41+
run: npm run setup
42+
4443
- name: Make Z-Wave binaries executable
4544
shell: wsl-bash {0}
4645
run: chmod +x zwave_stack/bin/*.elf
4746

47+
- name: Extract CTT setup files
48+
shell: powershell
49+
run: |
50+
Write-Host "Extracting CTT setup archive..."
51+
.\setup\extract-setup-archive.ps1
52+
4853
- name: Copy Z-Wave storage to WSL native filesystem
4954
shell: wsl-bash {0}
5055
run: |

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ ctt/project/Log
77
# Directories extracted from setup.zip on CI
88
zwave_stack/storage/
99
zwave-js/storage/
10-
zwave-js/log/
10+
zwave-js/log/
11+
12+
# Z-Wave stack binaries (downloaded via setup script)
13+
zwave_stack/bin/*.elf

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"start": "node --experimental-transform-types src/start.ts",
1010
"devices": "node --experimental-transform-types src/start.ts --devices-only",
1111
"ctt": "ctt/bin/CTT-Remote.exe ctt/project/zwave-js.cttsln",
12-
"create-setup-archive": "powershell -ExecutionPolicy Bypass -File setup/create-setup-archive.ps1"
12+
"create-setup-archive": "powershell -ExecutionPolicy Bypass -File setup/create-setup-archive.ps1",
13+
"setup": "node --experimental-transform-types setup/download-zwave-stack.ts"
1314
},
1415
"keywords": [],
1516
"author": "",

setup/download-zwave-stack.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { execSync } from "node:child_process";
2+
import { copyFileSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
3+
import { tmpdir } from "node:os";
4+
import { join } from "node:path";
5+
6+
const REPO = "Z-Wave-Alliance/z-wave-stack-binaries";
7+
const OUTPUT_DIR = "zwave_stack/bin";
8+
9+
const BINARIES = [
10+
{
11+
pattern: /^ZW_zwave_ncp_serial_api_controller_.*_REALTIME_DEBUG\.elf$/,
12+
output: "ZW_zwave_ncp_serial_api_controller.elf",
13+
},
14+
{
15+
pattern: /^ZW_zwave_ncp_serial_api_end_device_.*_REALTIME_DEBUG\.elf$/,
16+
output: "ZW_zwave_ncp_serial_api_end_device.elf",
17+
},
18+
];
19+
20+
const tempDir = mkdtempSync(join(tmpdir(), "zwave-stack-"));
21+
22+
try {
23+
console.log("Downloading latest Z-Wave stack binaries...");
24+
execSync(
25+
`gh release download --repo ${REPO} --pattern "*Linux.tar.gz" -D "${tempDir}"`,
26+
{ stdio: "inherit" },
27+
);
28+
29+
const tarball = readdirSync(tempDir).find((f) => f.endsWith(".tar.gz"));
30+
if (!tarball) {
31+
throw new Error("No tarball found in downloaded files");
32+
}
33+
34+
console.log(`Extracting ${tarball}...`);
35+
execSync(`tar -xzf "${join(tempDir, tarball)}" -C "${tempDir}"`, {
36+
stdio: "inherit",
37+
});
38+
39+
const binDir = join(tempDir, "bin");
40+
const files = readdirSync(binDir);
41+
42+
for (const { pattern, output } of BINARIES) {
43+
const match = files.find((f) => pattern.test(f));
44+
if (!match) {
45+
throw new Error(`No file matching ${pattern} found`);
46+
}
47+
48+
const src = join(binDir, match);
49+
const dest = join(OUTPUT_DIR, output);
50+
console.log(`Copying ${match} -> ${output}`);
51+
copyFileSync(src, dest);
52+
}
53+
54+
console.log("Done!");
55+
} finally {
56+
rmSync(tempDir, { recursive: true, force: true });
57+
}
Binary file not shown.
Binary file not shown.

zwave_stack/run.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ echo "Starting Z-Wave Stack..."
66

77
# Start 3 controllers
88
echo "Starting Controller 1 (Z-Wave JS) on port 5000..."
9-
./zwave_stack/bin/ZW_zwave_ncp_serial_api_controller_25_9_0_x86_REALTIME_DEBUG.elf --port 5000 --storage ./zwave_stack/storage/controller1 &
9+
./zwave_stack/bin/ZW_zwave_ncp_serial_api_controller.elf --port 5000 --storage ./zwave_stack/storage/controller1 &
1010

1111
echo "Starting Controller 2 (CTT) on port 5001..."
12-
./zwave_stack/bin/ZW_zwave_ncp_serial_api_controller_25_9_0_x86_REALTIME_DEBUG.elf --port 5001 --storage ./zwave_stack/storage/controller2 &
12+
./zwave_stack/bin/ZW_zwave_ncp_serial_api_controller.elf --port 5001 --storage ./zwave_stack/storage/controller2 &
1313

1414
echo "Starting Controller 3 (CTT) on port 5002..."
15-
./zwave_stack/bin/ZW_zwave_ncp_serial_api_controller_25_9_0_x86_REALTIME_DEBUG.elf --port 5002 --storage ./zwave_stack/storage/controller3 &
15+
./zwave_stack/bin/ZW_zwave_ncp_serial_api_controller.elf --port 5002 --storage ./zwave_stack/storage/controller3 &
1616

1717
# Start 2 end devices
1818
echo "Starting End Device 1 on port 5003..."
19-
./zwave_stack/bin/ZW_zwave_ncp_serial_api_end_device_25_9_0_x86_REALTIME_DEBUG.elf --port 5003 --storage ./zwave_stack/storage/enddevice1 &
19+
./zwave_stack/bin/ZW_zwave_ncp_serial_api_end_device.elf --port 5003 --storage ./zwave_stack/storage/enddevice1 &
2020

2121
echo "Starting End Device 2 on port 5004..."
22-
./zwave_stack/bin/ZW_zwave_ncp_serial_api_end_device_25_9_0_x86_REALTIME_DEBUG.elf --port 5004 --storage ./zwave_stack/storage/enddevice2 &
22+
./zwave_stack/bin/ZW_zwave_ncp_serial_api_end_device.elf --port 5004 --storage ./zwave_stack/storage/enddevice2 &
2323

2424
# Start the Zniffer simulator
2525
echo "Starting Zniffer on port 4905..."

0 commit comments

Comments
 (0)