Skip to content

Commit

Permalink
[FL-3940] Work around incorrect serial port handling by the OS (#4040)
Browse files Browse the repository at this point in the history
* fix: js sdk flipper detection
* chore: bump ver

Co-authored-by: あく <[email protected]>
  • Loading branch information
portasynthinca3 and skotopes authored Dec 23, 2024
1 parent 6d20bc7 commit 631d7a4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion applications/system/js_app/packages/fz-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flipperdevices/fz-sdk",
"version": "0.1.2",
"version": "0.1.3",
"description": "Type declarations and documentation for native JS modules available on Flipper Zero",
"keywords": [
"flipper",
Expand Down
13 changes: 6 additions & 7 deletions applications/system/js_app/packages/fz-sdk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions applications/system/js_app/packages/fz-sdk/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,21 @@ async function build(config) {

async function upload(config) {
const appFile = fs.readFileSync(config.input, "utf8");
const flippers = (await SerialPort.list()).filter(x => x.serialNumber?.startsWith("flip_"));
const serialPorts = await SerialPort.list();

let flippers = serialPorts
.filter(x => x.serialNumber?.startsWith("flip_"))
.map(x => ({ path: x.path, name: x.serialNumber.replace("flip_", "") }));

if (!flippers.length) {
// some Windows installations don't report the serial number correctly;
// filter by STM VCP VID:PID instead
flippers = serialPorts
.filter(x => x?.vendorId === "0483" && x?.productId === "5740")
.map(x => ({ path: x.path, name: x.path }));
}

if (!flippers) {
if (!flippers.length) {
console.error("No Flippers found");
process.exit(1);
}
Expand Down

0 comments on commit 631d7a4

Please sign in to comment.