-
-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support 800 series NVM layout and new NVM3 files (#6670)
- Loading branch information
Showing
20 changed files
with
407 additions
and
108 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { cpp2js } from "@zwave-js/shared"; | ||
import { type NVMObject } from ".."; | ||
import { | ||
NVMFile, | ||
type NVMFileCreationOptions, | ||
type NVMFileDeserializationOptions, | ||
getNVMFileIDStatic, | ||
gotDeserializationOptions, | ||
nvmFileID, | ||
} from "./NVMFile"; | ||
|
||
export interface ApplicationNameFileOptions extends NVMFileCreationOptions { | ||
name: string; | ||
} | ||
|
||
@nvmFileID(0x4100c) | ||
export class ApplicationNameFile extends NVMFile { | ||
public constructor( | ||
options: NVMFileDeserializationOptions | ApplicationNameFileOptions, | ||
) { | ||
super(options); | ||
if (gotDeserializationOptions(options)) { | ||
this.name = cpp2js(this.payload.toString("utf8")); | ||
} else { | ||
this.name = options.name; | ||
} | ||
} | ||
|
||
public name: string; | ||
|
||
public serialize(): NVMObject { | ||
// Return a zero-terminated string with a fixed length of 30 bytes | ||
const nameAsString = Buffer.from(this.name, "utf8"); | ||
this.payload = Buffer.alloc(30, 0); | ||
nameAsString.subarray(0, this.payload.length - 1).copy(this.payload); | ||
return super.serialize(); | ||
} | ||
} | ||
export const ApplicationNameFileID = getNVMFileIDStatic(ApplicationNameFile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.