Skip to content

Commit

Permalink
fix: report own version as Firmware 1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jul 5, 2024
1 parent ceb6110 commit 5853f86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/cc/src/cc/VersionCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ export class VersionCCReport extends VersionCC {
} else {
if (!/^\d+\.\d+(\.\d+)?$/.test(options.protocolVersion)) {
throw new ZWaveError(
`protocolVersion must be a string in the format "major.minor", received "${options.protocolVersion}"`,
`protocolVersion must be a string in the format "major.minor" or "major.minor.patch", received "${options.protocolVersion}"`,
ZWaveErrorCodes.Argument_Invalid,
);
} else if (
Expand All @@ -689,7 +689,7 @@ export class VersionCCReport extends VersionCC {
)
) {
throw new ZWaveError(
`firmwareVersions must be an array of strings in the format "major.minor", received "${
`firmwareVersions must be an array of strings in the format "major.minor" or "major.minor.patch", received "${
JSON.stringify(
options.firmwareVersions,
)
Expand Down
12 changes: 10 additions & 2 deletions packages/zwave-js/src/lib/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ import { randomBytes } from "node:crypto";
import { EventEmitter } from "node:events";
import path from "node:path";
import { isDeepStrictEqual } from "node:util";
import semver from "semver";
import { RemoveNodeReason } from "../controller/Inclusion";
import { determineNIF } from "../controller/NodeInformationFrame";
import type { Driver } from "../driver/Driver";
import { type Driver, libVersion } from "../driver/Driver";
import { cacheKeys } from "../driver/NetworkCache";
import { type Extended, interpretEx } from "../driver/StateMachineShared";
import type { StatisticsEventCallbacksWithSelf } from "../driver/Statistics";
Expand Down Expand Up @@ -4031,10 +4032,17 @@ protocol version: ${this.protocolVersion}`;
& ~EncapsulationFlags.Supervision,
});

const firmwareVersion1 = semver.parse(libVersion, { loose: true })!;

await api.sendReport({
libraryType: ZWaveLibraryTypes["Static Controller"],
protocolVersion: this.driver.controller.protocolVersion!,
firmwareVersions: [this.driver.controller.firmwareVersion!],
firmwareVersions: [
// Firmware 0 is the Z-Wave chip firmware
this.driver.controller.firmwareVersion!,
// Firmware 1 is Z-Wave JS itself
`${firmwareVersion1.major}.${firmwareVersion1.minor}.${firmwareVersion1.patch}`,
],
hardwareVersion: this.driver.options.vendor?.hardwareVersion,
});
}
Expand Down

0 comments on commit 5853f86

Please sign in to comment.