@zwave-js/nvmedit 15.15.3 → 15.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/convert.d.ts +6 -5
- package/build/cjs/convert.js.map +2 -2
- package/build/cjs/lib/NVM3.d.ts +6 -5
- package/build/cjs/lib/NVM3.js.map +2 -2
- package/build/cjs/lib/NVM500.js +1 -1
- package/build/cjs/lib/NVM500.js.map +2 -2
- package/build/cjs/lib/common/definitions.d.ts +5 -5
- package/build/cjs/lib/common/definitions.js.map +1 -1
- package/build/cjs/lib/common/routeCache.d.ts +2 -2
- package/build/cjs/lib/common/routeCache.js.map +2 -2
- package/build/cjs/lib/common/sucUpdateEntry.d.ts +2 -2
- package/build/cjs/lib/common/sucUpdateEntry.js.map +2 -2
- package/build/cjs/lib/common/utils.d.ts +3 -2
- package/build/cjs/lib/common/utils.js.map +2 -2
- package/build/cjs/lib/io/BufferedNVMReader.d.ts +3 -2
- package/build/cjs/lib/io/BufferedNVMReader.js.map +2 -2
- package/build/cjs/lib/io/NVMFileIO.d.ts +3 -2
- package/build/cjs/lib/io/NVMFileIO.js.map +2 -2
- package/build/cjs/lib/io/NVMMemoryIO.d.ts +4 -3
- package/build/cjs/lib/io/NVMMemoryIO.js.map +2 -2
- package/build/cjs/lib/nvm3/adapter.js.map +2 -2
- package/build/cjs/lib/nvm3/files/ApplicationCCsFile.js +1 -1
- package/build/cjs/lib/nvm3/files/ApplicationCCsFile.js.map +1 -1
- package/build/cjs/lib/nvm3/files/ApplicationRFConfigFile.js +1 -1
- package/build/cjs/lib/nvm3/files/ApplicationRFConfigFile.js.map +1 -1
- package/build/cjs/lib/nvm3/files/ApplicationTypeFile.js +1 -1
- package/build/cjs/lib/nvm3/files/ApplicationTypeFile.js.map +1 -1
- package/build/cjs/lib/nvm3/files/ControllerInfoFile.d.ts +3 -3
- package/build/cjs/lib/nvm3/files/ControllerInfoFile.js +1 -1
- package/build/cjs/lib/nvm3/files/ControllerInfoFile.js.map +2 -2
- package/build/cjs/lib/nvm3/files/NVMFile.d.ts +2 -2
- package/build/cjs/lib/nvm3/files/NVMFile.js.map +2 -2
- package/build/cjs/lib/nvm3/files/NodeInfoFiles.js +3 -3
- package/build/cjs/lib/nvm3/files/NodeInfoFiles.js.map +2 -2
- package/build/cjs/lib/nvm3/files/ProtocolNodeMaskFiles.js +2 -2
- package/build/cjs/lib/nvm3/files/ProtocolNodeMaskFiles.js.map +1 -1
- package/build/cjs/lib/nvm3/files/RouteCacheFiles.js +2 -2
- package/build/cjs/lib/nvm3/files/RouteCacheFiles.js.map +1 -1
- package/build/cjs/lib/nvm3/files/SUCUpdateEntriesFile.js +2 -2
- package/build/cjs/lib/nvm3/files/SUCUpdateEntriesFile.js.map +1 -1
- package/build/cjs/lib/nvm3/files/VersionFiles.js +1 -1
- package/build/cjs/lib/nvm3/files/VersionFiles.js.map +1 -1
- package/build/cjs/lib/nvm3/object.d.ts +3 -2
- package/build/cjs/lib/nvm3/object.js.map +2 -2
- package/build/cjs/lib/nvm3/page.d.ts +2 -1
- package/build/cjs/lib/nvm3/page.js.map +2 -2
- package/build/cjs/lib/nvm500/EntryParsers.d.ts +4 -4
- package/build/cjs/lib/nvm500/EntryParsers.js.map +2 -2
- package/build/cjs/lib/nvm500/adapter.js +4 -2
- package/build/cjs/lib/nvm500/adapter.js.map +2 -2
- package/build/cjs/lib/nvm500/shared.d.ts +2 -1
- package/build/cjs/lib/nvm500/shared.js.map +2 -2
- package/build/esm/convert.d.ts +6 -5
- package/build/esm/convert.d.ts.map +1 -1
- package/build/esm/convert.js +1 -1
- package/build/esm/convert.js.map +1 -1
- package/build/esm/lib/NVM3.d.ts +6 -5
- package/build/esm/lib/NVM3.d.ts.map +1 -1
- package/build/esm/lib/NVM3.js +1 -1
- package/build/esm/lib/NVM3.js.map +1 -1
- package/build/esm/lib/NVM500.js +1 -1
- package/build/esm/lib/NVM500.js.map +1 -1
- package/build/esm/lib/common/definitions.d.ts +5 -5
- package/build/esm/lib/common/definitions.d.ts.map +1 -1
- package/build/esm/lib/common/routeCache.d.ts +2 -2
- package/build/esm/lib/common/routeCache.d.ts.map +1 -1
- package/build/esm/lib/common/routeCache.js.map +1 -1
- package/build/esm/lib/common/sucUpdateEntry.d.ts +2 -2
- package/build/esm/lib/common/sucUpdateEntry.d.ts.map +1 -1
- package/build/esm/lib/common/sucUpdateEntry.js.map +1 -1
- package/build/esm/lib/common/utils.d.ts +3 -2
- package/build/esm/lib/common/utils.d.ts.map +1 -1
- package/build/esm/lib/common/utils.js.map +1 -1
- package/build/esm/lib/io/BufferedNVMReader.d.ts +3 -2
- package/build/esm/lib/io/BufferedNVMReader.d.ts.map +1 -1
- package/build/esm/lib/io/BufferedNVMReader.js.map +1 -1
- package/build/esm/lib/io/NVMFileIO.d.ts +3 -2
- package/build/esm/lib/io/NVMFileIO.d.ts.map +1 -1
- package/build/esm/lib/io/NVMFileIO.js.map +1 -1
- package/build/esm/lib/io/NVMMemoryIO.d.ts +4 -3
- package/build/esm/lib/io/NVMMemoryIO.d.ts.map +1 -1
- package/build/esm/lib/io/NVMMemoryIO.js.map +1 -1
- package/build/esm/lib/nvm3/adapter.d.ts.map +1 -1
- package/build/esm/lib/nvm3/adapter.js.map +1 -1
- package/build/esm/lib/nvm3/files/ApplicationCCsFile.js +1 -1
- package/build/esm/lib/nvm3/files/ApplicationCCsFile.js.map +1 -1
- package/build/esm/lib/nvm3/files/ApplicationRFConfigFile.js +1 -1
- package/build/esm/lib/nvm3/files/ApplicationRFConfigFile.js.map +1 -1
- package/build/esm/lib/nvm3/files/ApplicationTypeFile.js +1 -1
- package/build/esm/lib/nvm3/files/ApplicationTypeFile.js.map +1 -1
- package/build/esm/lib/nvm3/files/ControllerInfoFile.d.ts +3 -3
- package/build/esm/lib/nvm3/files/ControllerInfoFile.d.ts.map +1 -1
- package/build/esm/lib/nvm3/files/ControllerInfoFile.js +1 -1
- package/build/esm/lib/nvm3/files/ControllerInfoFile.js.map +1 -1
- package/build/esm/lib/nvm3/files/NVMFile.d.ts +2 -2
- package/build/esm/lib/nvm3/files/NVMFile.d.ts.map +1 -1
- package/build/esm/lib/nvm3/files/NVMFile.js.map +1 -1
- package/build/esm/lib/nvm3/files/NodeInfoFiles.d.ts.map +1 -1
- package/build/esm/lib/nvm3/files/NodeInfoFiles.js +3 -3
- package/build/esm/lib/nvm3/files/NodeInfoFiles.js.map +1 -1
- package/build/esm/lib/nvm3/files/ProtocolNodeMaskFiles.js +2 -2
- package/build/esm/lib/nvm3/files/ProtocolNodeMaskFiles.js.map +1 -1
- package/build/esm/lib/nvm3/files/RouteCacheFiles.js +2 -2
- package/build/esm/lib/nvm3/files/RouteCacheFiles.js.map +1 -1
- package/build/esm/lib/nvm3/files/SUCUpdateEntriesFile.js +2 -2
- package/build/esm/lib/nvm3/files/SUCUpdateEntriesFile.js.map +1 -1
- package/build/esm/lib/nvm3/files/VersionFiles.js +1 -1
- package/build/esm/lib/nvm3/files/VersionFiles.js.map +1 -1
- package/build/esm/lib/nvm3/object.d.ts +3 -2
- package/build/esm/lib/nvm3/object.d.ts.map +1 -1
- package/build/esm/lib/nvm3/object.js.map +1 -1
- package/build/esm/lib/nvm3/page.d.ts +2 -1
- package/build/esm/lib/nvm3/page.d.ts.map +1 -1
- package/build/esm/lib/nvm3/page.js.map +1 -1
- package/build/esm/lib/nvm500/EntryParsers.d.ts +4 -4
- package/build/esm/lib/nvm500/EntryParsers.d.ts.map +1 -1
- package/build/esm/lib/nvm500/EntryParsers.js.map +1 -1
- package/build/esm/lib/nvm500/adapter.d.ts.map +1 -1
- package/build/esm/lib/nvm500/adapter.js +7 -2
- package/build/esm/lib/nvm500/adapter.js.map +1 -1
- package/build/esm/lib/nvm500/shared.d.ts +2 -1
- package/build/esm/lib/nvm500/shared.d.ts.map +1 -1
- package/build/esm/lib/nvm500/shared.js.map +1 -1
- package/package.json +7 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bytes, type TypedClassDecorator } from "@zwave-js/shared";
|
|
1
|
+
import { Bytes, type BytesView, type TypedClassDecorator } from "@zwave-js/shared";
|
|
2
2
|
import type { NVM3Object } from "../object.js";
|
|
3
3
|
export interface NVMFileBaseOptions {
|
|
4
4
|
fileId?: number;
|
|
@@ -20,7 +20,7 @@ export declare class NVMFile {
|
|
|
20
20
|
/**
|
|
21
21
|
* Creates an instance of the NVM file that is contained in the given NVM object
|
|
22
22
|
*/
|
|
23
|
-
static from(fileId: number, data:
|
|
23
|
+
static from(fileId: number, data: BytesView, fileVersion: string): NVMFile;
|
|
24
24
|
/**
|
|
25
25
|
* Serializes this NVMFile into an NVM Object
|
|
26
26
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/NVMFile.ts"],
|
|
4
|
-
"sourcesContent": ["import { ZWaveError, ZWaveErrorCodes } from \"@zwave-js/core\";\nimport { createSimpleReflectionDecorator } from \"@zwave-js/core/reflection\";\nimport {\n\tBytes,\n\ttype TypedClassDecorator,\n\tisUint8Array,\n\tnum2hex,\n} from \"@zwave-js/shared\";\nimport {\n\tFragmentType,\n\tNVM3_MAX_OBJ_SIZE_SMALL,\n\tObjectType,\n} from \"../consts.js\";\nimport type { NVM3Object } from \"../object.js\";\n\nexport interface NVMFileBaseOptions {\n\tfileId?: number;\n\tfileVersion: string;\n}\nexport interface NVMFileDeserializationOptions extends NVMFileBaseOptions {\n\tfileId: number;\n\tdata: Bytes;\n}\n\nexport function gotDeserializationOptions(\n\toptions: NVMFileOptions,\n): options is NVMFileDeserializationOptions {\n\treturn \"data\" in options && isUint8Array(options.data);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface NVMFileCreationOptions extends NVMFileBaseOptions {}\n\nexport type NVMFileOptions =\n\t| NVMFileCreationOptions\n\t| NVMFileDeserializationOptions;\n\nexport class NVMFile {\n\tpublic constructor(options: NVMFileOptions) {\n\t\tthis.fileVersion = options.fileVersion;\n\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.fileId = options.fileId;\n\t\t\tthis.payload = options.data;\n\t\t} else {\n\t\t\tconst fileId = options.fileId ?? getNVMFileID(this);\n\t\t\tif (typeof fileId === \"number\") {\n\t\t\t\tthis.fileId = fileId;\n\t\t\t}\n\t\t\tthis.payload = new Bytes();\n\t\t}\n\t}\n\n\tprotected payload: Bytes;\n\tpublic fileId: number = 0;\n\tpublic fileVersion: string;\n\n\t/**\n\t * Creates an instance of the NVM file that is contained in the given NVM object\n\t */\n\tpublic static from(\n\t\tfileId: number,\n\t\tdata:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAAA,kBAA4C;AAC5C,wBAAgD;AAChD,
|
|
4
|
+
"sourcesContent": ["import { ZWaveError, ZWaveErrorCodes } from \"@zwave-js/core\";\nimport { createSimpleReflectionDecorator } from \"@zwave-js/core/reflection\";\nimport {\n\tBytes,\n\ttype BytesView,\n\ttype TypedClassDecorator,\n\tisUint8Array,\n\tnum2hex,\n} from \"@zwave-js/shared\";\nimport {\n\tFragmentType,\n\tNVM3_MAX_OBJ_SIZE_SMALL,\n\tObjectType,\n} from \"../consts.js\";\nimport type { NVM3Object } from \"../object.js\";\n\nexport interface NVMFileBaseOptions {\n\tfileId?: number;\n\tfileVersion: string;\n}\nexport interface NVMFileDeserializationOptions extends NVMFileBaseOptions {\n\tfileId: number;\n\tdata: Bytes;\n}\n\nexport function gotDeserializationOptions(\n\toptions: NVMFileOptions,\n): options is NVMFileDeserializationOptions {\n\treturn \"data\" in options && isUint8Array(options.data);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface NVMFileCreationOptions extends NVMFileBaseOptions {}\n\nexport type NVMFileOptions =\n\t| NVMFileCreationOptions\n\t| NVMFileDeserializationOptions;\n\nexport class NVMFile {\n\tpublic constructor(options: NVMFileOptions) {\n\t\tthis.fileVersion = options.fileVersion;\n\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.fileId = options.fileId;\n\t\t\tthis.payload = options.data;\n\t\t} else {\n\t\t\tconst fileId = options.fileId ?? getNVMFileID(this);\n\t\t\tif (typeof fileId === \"number\") {\n\t\t\t\tthis.fileId = fileId;\n\t\t\t}\n\t\t\tthis.payload = new Bytes();\n\t\t}\n\t}\n\n\tprotected payload: Bytes;\n\tpublic fileId: number = 0;\n\tpublic fileVersion: string;\n\n\t/**\n\t * Creates an instance of the NVM file that is contained in the given NVM object\n\t */\n\tpublic static from(\n\t\tfileId: number,\n\t\tdata: BytesView,\n\t\tfileVersion: string,\n\t): NVMFile {\n\t\tconst Constructor = getNVMFileConstructor(fileId)!;\n\t\treturn new Constructor({\n\t\t\tfileId,\n\t\t\tfileVersion,\n\t\t\tdata,\n\t\t});\n\t}\n\n\t/**\n\t * Serializes this NVMFile into an NVM Object\n\t */\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (!this.fileId) {\n\t\t\tthrow new Error(\"The NVM file ID must be set before serializing\");\n\t\t}\n\t\treturn {\n\t\t\tkey: this.fileId,\n\t\t\tdata: this.payload,\n\t\t\t// We only support large and small data objects for now\n\t\t\ttype: this.payload.length <= NVM3_MAX_OBJ_SIZE_SMALL\n\t\t\t\t? ObjectType.DataSmall\n\t\t\t\t: ObjectType.DataLarge,\n\t\t\t// By default output unfragmented objects, they will be split later\n\t\t\tfragmentType: FragmentType.None,\n\t\t};\n\t}\n\n\tpublic toJSON(): Record<string, any> {\n\t\treturn {\n\t\t\t\"file ID\": `0x${\n\t\t\t\tthis.fileId.toString(16)\n\t\t\t} (${this.constructor.name})`,\n\t\t};\n\t}\n}\n\nconst METADATA_nvmFileID = Symbol(\"nvmFileID\");\nconst METADATA_nvmFileIDMap = Symbol(\"nvmFileIDMap\");\n\ntype NVMFileIDMap = Map<\n\tnumber | ((id: number) => boolean),\n\tNVMFileConstructor<NVMFile>\n>;\n\nexport type NVMFileConstructor<T extends NVMFile> = typeof NVMFile & {\n\tnew (options: any): T;\n};\n\n/**\n * Defines the ID associated with a NVM file class\n */\nexport function nvmFileID<Class extends typeof NVMFile>(\n\tid: number | ((id: number) => boolean),\n): TypedClassDecorator<Class> {\n\treturn (messageClass) => {\n\t\tReflect.defineMetadata(METADATA_nvmFileID, id, messageClass);\n\n\t\t// also store a map in the NVMFile metadata for lookup.\n\t\tconst map: NVMFileIDMap =\n\t\t\tReflect.getMetadata(METADATA_nvmFileIDMap, NVMFile) || new Map();\n\t\tmap.set(id, messageClass as unknown as NVMFileConstructor<NVMFile>);\n\t\tReflect.defineMetadata(METADATA_nvmFileIDMap, map, NVMFile);\n\t};\n}\n\n/**\n * Retrieves the file ID defined for a NVM file class\n */\nexport function getNVMFileID<T extends NVMFile>(\n\tid: T,\n): number | ((id: number) => boolean) {\n\t// get the class constructor\n\tconst constr = id.constructor;\n\t// retrieve the current metadata\n\tconst ret: number | undefined = id instanceof NVMFile\n\t\t? Reflect.getMetadata(METADATA_nvmFileID, constr)\n\t\t: undefined;\n\tif (ret == undefined) {\n\t\tthrow new ZWaveError(\n\t\t\t`No NVM file ID defined for ${constr.name}!`,\n\t\t\tZWaveErrorCodes.CC_Invalid,\n\t\t);\n\t}\n\treturn ret;\n}\n\n/**\n * Looks up the NVM file constructor for a given file ID\n */\nexport function getNVMFileConstructor(\n\tid: number,\n): NVMFileConstructor<NVMFile> | undefined {\n\t// Retrieve the constructor map from the NVMFile class\n\tconst map = Reflect.getMetadata(METADATA_nvmFileIDMap, NVMFile) as\n\t\t| NVMFileIDMap\n\t\t| undefined;\n\tif (map != undefined) {\n\t\tif (map.has(id)) return map.get(id);\n\t\t// Otherwise loop through predicates\n\t\tfor (const [key, value] of map.entries()) {\n\t\t\tif (typeof key === \"function\" && key(id)) return value;\n\t\t}\n\t}\n}\n\n/**\n * Retrieves the file ID defined for a NVM file class\n */\nexport function getNVMFileIDStatic<T extends NVMFileConstructor<NVMFile>>(\n\tclassConstructor: T,\n): number | ((id: number) => boolean) {\n\t// retrieve the current metadata\n\tconst ret = Reflect.getMetadata(METADATA_nvmFileID, classConstructor);\n\tif (ret == undefined) {\n\t\tthrow new ZWaveError(\n\t\t\t`No NVM file ID defined for ${classConstructor.name}!`,\n\t\t\tZWaveErrorCodes.CC_Invalid,\n\t\t);\n\t}\n\treturn ret;\n}\n\nexport type NVMSection = \"application\" | \"protocol\";\n\nconst nvmSectionDecorator = createSimpleReflectionDecorator<\n\ttypeof NVMFile,\n\t[section: NVMSection]\n>({\n\tname: \"nvmSection\",\n});\n\n/** Defines in which section an NVM file is stored */\nexport const nvmSection = nvmSectionDecorator.decorator;\n\n/** Returns in which section an NVM file is stored (using an instance of the file) */\nexport const getNVMSection = nvmSectionDecorator.lookupValue;\n\n/** Returns in which section an NVM file is stored (using the constructor of the file) */\nexport const getNVMSectionStatic = nvmSectionDecorator.lookupValueStatic;\n\n/** Returns in which NVM section the file with the given ID resides in */\nexport function getNVMSectionByFileID(fileId: number): NVMSection {\n\tconst File = getNVMFileConstructor(fileId);\n\tlet ret: NVMSection | undefined;\n\tif (File) {\n\t\tret = getNVMSectionStatic(File);\n\t}\n\tif (ret) return ret;\n\n\tthrow new ZWaveError(\n\t\t`NVM section for file with ID ${\n\t\t\tnum2hex(fileId)\n\t\t} could not be determined`,\n\t\tZWaveErrorCodes.Argument_Invalid,\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAAA,kBAA4C;AAC5C,wBAAgD;AAChD,oBAMO;AACP,oBAIO;AAYD,SAAU,0BACf,SAAuB;AAEvB,SAAO,UAAU,eAAW,4BAAa,QAAQ,IAAI;AACtD;AAJgB;AAaV,MAAO,QAAO;EAtCpB,OAsCoB;;;EACnB,YAAmB,SAAuB;AACzC,SAAK,cAAc,QAAQ;AAE3B,QAAI,0BAA0B,OAAO,GAAG;AACvC,WAAK,SAAS,QAAQ;AACtB,WAAK,UAAU,QAAQ;IACxB,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G9D,MAAI,OAAO,QAAW;AACrB,QAAI,IAAI,IAAI,EAAE;AAAG,aAAO,IAAI,IAAI,EAAE;AAElC,eAAW,CAAC,KAAK,KAAK,KAAK,IAAI,QAAO,GAAI;AACzC,UAAI,OAAO,QAAQ,cAAc,IAAI,EAAE;AAAG,eAAO;IAClD;EACD;AACD;AAdgB;AAmBV,SAAU,mBACf,kBAAmB;AAGnB,QAAM,MAAM,QAAQ,YAAY,oBAAoB,gBAAgB;AACpE,MAAI,OAAO,QAAW;AACrB,UAAM,IAAI,uBACT,8BAA8B,iBAAiB,IAAI,KACnD,4BAAgB,UAAU;EAE5B;AACA,SAAO;AACR;AAZgB;AAgBhB,MAAM,0BAAsB,mDAG1B;EACD,MAAM;CACN;AAGM,MAAM,aAAa,oBAAoB;AAGvC,MAAM,gBAAgB,oBAAoB;AAG1C,MAAM,sBAAsB,oBAAoB;AAGjD,SAAU,sBAAsB,QAAc;AACnD,QAAM,OAAO,sBAAsB,MAAM;AACzC,MAAI;AACJ,MAAI,MAAM;AACT,UAAM,oBAAoB,IAAI;EAC/B;AACA,MAAI;AAAK,WAAO;AAEhB,QAAM,IAAI,uBACT,oCACC,uBAAQ,MAAM,CACf,4BACA,4BAAgB,gBAAgB;AAElC;AAdgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -224,7 +224,7 @@ let NodeInfoFileV0 = (() => {
|
|
|
224
224
|
this.payload = encodeNodeInfo(this.nodeInfo);
|
|
225
225
|
return super.serialize();
|
|
226
226
|
}
|
|
227
|
-
//
|
|
227
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
228
228
|
toJSON() {
|
|
229
229
|
return {
|
|
230
230
|
...super.toJSON(),
|
|
@@ -289,7 +289,7 @@ let NodeInfoFileV1 = (() => {
|
|
|
289
289
|
}
|
|
290
290
|
return super.serialize();
|
|
291
291
|
}
|
|
292
|
-
//
|
|
292
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
293
293
|
toJSON() {
|
|
294
294
|
return {
|
|
295
295
|
...super.toJSON(),
|
|
@@ -354,7 +354,7 @@ let LRNodeInfoFileV5 = (() => {
|
|
|
354
354
|
}
|
|
355
355
|
return super.serialize();
|
|
356
356
|
}
|
|
357
|
-
//
|
|
357
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
358
358
|
toJSON() {
|
|
359
359
|
return {
|
|
360
360
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/NodeInfoFiles.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\ttype DataRate,\n\ttype FLiRS,\n\tMAX_NODES,\n\tMAX_NODES_LR,\n\tNUM_NODEMASK_BYTES,\n\ttype NodeProtocolInfo,\n\tNodeType,\n\tencodeBitMask,\n\tencodeNodeProtocolInfo,\n\tparseBitMask,\n\tparseNodeProtocolInfo,\n} from \"@zwave-js/core\";\nimport { Bytes, pick } from \"@zwave-js/shared\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport const NODEINFOS_PER_FILE_V1 = 4;\nexport const LR_NODEINFOS_PER_FILE_V5 = 50;\nconst NODEINFO_SIZE = 1 + 5 + NUM_NODEMASK_BYTES;\nconst LR_NODEINFO_SIZE = 3;\nconst EMPTY_NODEINFO_FILL = 0xff;\nconst emptyNodeInfo = new Uint8Array(NODEINFO_SIZE).fill(EMPTY_NODEINFO_FILL);\n\nexport interface NodeInfo\n\textends Omit<NodeProtocolInfo, \"hasSpecificDeviceClass\">\n{\n\tnodeId: number;\n\tgenericDeviceClass: number;\n\tspecificDeviceClass?: number | null;\n\tneighbors: number[];\n\tsucUpdateIndex: number;\n}\n\nfunction parseNodeInfo(\n\tnodeId: number,\n\tbuffer: Uint8Array,\n\toffset: number,\n): NodeInfo {\n\tconst { hasSpecificDeviceClass, ...protocolInfo } = parseNodeProtocolInfo(\n\t\tbuffer,\n\t\toffset,\n\t);\n\tconst genericDeviceClass = buffer[offset + 3];\n\tconst specificDeviceClass = hasSpecificDeviceClass\n\t\t? buffer[offset + 4]\n\t\t: null;\n\tconst neighbors = parseBitMask(\n\t\tbuffer.subarray(offset + 5, offset + 5 + NUM_NODEMASK_BYTES),\n\t);\n\tconst sucUpdateIndex = buffer[offset + 5 + NUM_NODEMASK_BYTES];\n\treturn {\n\t\tnodeId,\n\t\t...protocolInfo,\n\t\tgenericDeviceClass,\n\t\tspecificDeviceClass,\n\t\tneighbors,\n\t\tsucUpdateIndex,\n\t};\n}\n\nfunction encodeNodeInfo(nodeInfo: NodeInfo): Bytes {\n\tconst ret = new Bytes(NODEINFO_SIZE);\n\n\tconst hasSpecificDeviceClass = nodeInfo.specificDeviceClass != null;\n\tconst protocolInfo: NodeProtocolInfo = {\n\t\t...pick(nodeInfo, [\n\t\t\t\"isListening\",\n\t\t\t\"isFrequentListening\",\n\t\t\t\"isRouting\",\n\t\t\t\"supportedDataRates\",\n\t\t\t\"protocolVersion\",\n\t\t\t\"optionalFunctionality\",\n\t\t\t\"nodeType\",\n\t\t\t\"supportsSecurity\",\n\t\t\t\"supportsBeaming\",\n\t\t]),\n\t\thasSpecificDeviceClass,\n\t};\n\tret.set(encodeNodeProtocolInfo(protocolInfo), 0);\n\n\tret[3] = nodeInfo.genericDeviceClass;\n\tif (hasSpecificDeviceClass) ret[4] = nodeInfo.specificDeviceClass!;\n\tret.set(encodeBitMask(nodeInfo.neighbors, MAX_NODES), 5);\n\tret[5 + NUM_NODEMASK_BYTES] = nodeInfo.sucUpdateIndex;\n\n\treturn ret;\n}\n\nexport interface LRNodeInfo\n\textends Omit<NodeProtocolInfo, \"hasSpecificDeviceClass\">\n{\n\tnodeId: number;\n\tgenericDeviceClass: number;\n\tspecificDeviceClass?: number | null;\n}\n\nfunction parseLRNodeInfo(\n\tnodeId: number,\n\tbuffer: Uint8Array,\n\toffset: number,\n): LRNodeInfo {\n\t// The node info in LR NVM files is packed:\n\t// Byte 0 CAPABILITY:\n\t// Bit 0: Routing (?)\n\t// Bit 1: Listening\n\t// Bit 2: has specific device class (?)\n\t// Bit 3: Beam capability\n\t// Bit 4: Optional functionality\n\t// Bits 5-6: FLiRS\n\t// Bit 7: Unused (?)\n\t// Byte 1: Generic device class\n\t// Byte 2: Specific device class\n\n\t// Protocol version is always 3\n\t// Security is always true\n\t// Supported speed is always 100kbps (speed = 0, speed ext = 2)\n\t// Never: routing end node, controller\n\n\tconst capability = buffer[offset];\n\tconst isRouting = !!(capability & 0b0000_0001); // ZWLR Mesh??\n\tconst isListening = !!(capability & 0b0000_0010);\n\tconst hasSpecificDeviceClass = !!(capability & 0b0000_0100);\n\tconst supportsBeaming = !!(capability & 0b0000_1000);\n\tconst optionalFunctionality = !!(capability & 0b0001_0000);\n\tlet isFrequentListening: FLiRS;\n\tswitch (capability & 0b0110_0000) {\n\t\tcase 0b0100_0000:\n\t\t\tisFrequentListening = \"1000ms\";\n\t\t\tbreak;\n\t\tcase 0b0010_0000:\n\t\t\tisFrequentListening = \"250ms\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tisFrequentListening = false;\n\t}\n\tconst nodeType = NodeType[\"End Node\"];\n\tconst supportsSecurity = true;\n\tconst protocolVersion = 3;\n\tconst supportedDataRates: DataRate[] = [100000];\n\n\treturn {\n\t\tnodeId,\n\t\tisRouting,\n\t\tisListening,\n\t\tsupportsBeaming,\n\t\tisFrequentListening,\n\t\toptionalFunctionality,\n\t\tnodeType,\n\t\tsupportsSecurity,\n\t\tprotocolVersion,\n\t\tsupportedDataRates,\n\t\tgenericDeviceClass: buffer[offset + 1],\n\t\tspecificDeviceClass: hasSpecificDeviceClass ? buffer[offset + 2] : null,\n\t};\n}\n\nfunction encodeLRNodeInfo(nodeInfo: LRNodeInfo): Uint8Array {\n\tconst ret = new Bytes(LR_NODEINFO_SIZE);\n\n\tlet capability = 0;\n\tif (nodeInfo.isRouting) capability |= 0b0000_0001;\n\tif (nodeInfo.isListening) capability |= 0b0000_0010;\n\tif (nodeInfo.specificDeviceClass != null) capability |= 0b0000_0100;\n\tif (nodeInfo.supportsBeaming) capability |= 0b0000_1000;\n\tif (nodeInfo.optionalFunctionality) capability |= 0b0001_0000;\n\tif (nodeInfo.isFrequentListening === \"1000ms\") {\n\t\tcapability |= 0b0100_0000;\n\t} else if (nodeInfo.isFrequentListening === \"250ms\") {\n\t\tcapability |= 0b0010_0000;\n\t}\n\n\tret[0] = capability;\n\tret[1] = nodeInfo.genericDeviceClass;\n\tret[2] = nodeInfo.specificDeviceClass ?? 0;\n\n\treturn ret;\n}\n\nexport interface NodeInfoFileV0Options extends NVMFileCreationOptions {\n\tnodeInfo: NodeInfo;\n}\n\nexport const NodeInfoFileV0IDBase = 0x50100;\nexport function nodeIdToNodeInfoFileIDV0(nodeId: number): number {\n\treturn NodeInfoFileV0IDBase + nodeId - 1;\n}\n\n@nvmFileID(\n\t(id) => id >= NodeInfoFileV0IDBase && id < NodeInfoFileV0IDBase + MAX_NODES,\n)\n@nvmSection(\"protocol\")\nexport class NodeInfoFileV0 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | NodeInfoFileV0Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeInfo = parseNodeInfo(\n\t\t\t\tthis.fileId - NodeInfoFileV0IDBase + 1,\n\t\t\t\tthis.payload,\n\t\t\t\t0,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.nodeInfo = options.nodeInfo;\n\t\t}\n\t}\n\n\tpublic nodeInfo: NodeInfo;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.fileId = nodeIdToNodeInfoFileIDV0(this.nodeInfo.nodeId);\n\t\tthis.payload = encodeNodeInfo(this.nodeInfo);\n\t\treturn super.serialize();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\tnodeInfo: this.nodeInfo,\n\t\t};\n\t}\n}\n\nexport interface NodeInfoFileV1Options extends NVMFileCreationOptions {\n\tnodeInfos: NodeInfo[];\n}\n\nexport const NodeInfoFileV1IDBase = 0x50200;\nexport function nodeIdToNodeInfoFileIDV1(nodeId: number): number {\n\treturn (\n\t\tNodeInfoFileV1IDBase + Math.floor((nodeId - 1) / NODEINFOS_PER_FILE_V1)\n\t);\n}\n\n@nvmFileID(\n\t(id) =>\n\t\tid >= NodeInfoFileV1IDBase\n\t\t&& id < NodeInfoFileV1IDBase + MAX_NODES / NODEINFOS_PER_FILE_V1,\n)\n@nvmSection(\"protocol\")\nexport class NodeInfoFileV1 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | NodeInfoFileV1Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeInfos = [];\n\t\t\tfor (let i = 0; i < NODEINFOS_PER_FILE_V1; i++) {\n\t\t\t\tconst nodeId = (this.fileId - NodeInfoFileV1IDBase)\n\t\t\t\t\t\t* NODEINFOS_PER_FILE_V1\n\t\t\t\t\t+ 1\n\t\t\t\t\t+ i;\n\t\t\t\tconst offset = i * NODEINFO_SIZE;\n\t\t\t\tconst entry = this.payload.subarray(\n\t\t\t\t\toffset,\n\t\t\t\t\toffset + NODEINFO_SIZE,\n\t\t\t\t);\n\t\t\t\tif (entry.equals(emptyNodeInfo)) continue;\n\n\t\t\t\tconst nodeInfo = parseNodeInfo(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tentry,\n\t\t\t\t\t0,\n\t\t\t\t);\n\t\t\t\tthis.nodeInfos.push(nodeInfo);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.nodeInfos = options.nodeInfos;\n\t\t}\n\t}\n\n\tpublic nodeInfos: NodeInfo[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\t// The infos must be sorted by node ID\n\t\tthis.nodeInfos.sort((a, b) => a.nodeId - b.nodeId);\n\t\tconst minNodeId = this.nodeInfos[0].nodeId;\n\t\tthis.fileId = nodeIdToNodeInfoFileIDV1(minNodeId);\n\n\t\tthis.payload = new Bytes(NODEINFO_SIZE * NODEINFOS_PER_FILE_V1).fill(\n\t\t\tEMPTY_NODEINFO_FILL,\n\t\t);\n\n\t\tconst minFileNodeId =\n\t\t\tMath.floor((minNodeId - 1) / NODEINFOS_PER_FILE_V1)\n\t\t\t\t* NODEINFOS_PER_FILE_V1\n\t\t\t+ 1;\n\n\t\tfor (const nodeInfo of this.nodeInfos) {\n\t\t\tconst offset = (nodeInfo.nodeId - minFileNodeId) * NODEINFO_SIZE;\n\t\t\tthis.payload.set(encodeNodeInfo(nodeInfo), offset);\n\t\t}\n\n\t\treturn super.serialize();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"node infos\": this.nodeInfos,\n\t\t};\n\t}\n}\n\nexport interface LRNodeInfoFileV5Options extends NVMFileCreationOptions {\n\tnodeInfos: LRNodeInfo[];\n}\n\nexport const LRNodeInfoFileV5IDBase = 0x50800;\nexport function nodeIdToLRNodeInfoFileIDV5(nodeId: number): number {\n\treturn (\n\t\tLRNodeInfoFileV5IDBase\n\t\t+ Math.floor((nodeId - 256) / LR_NODEINFOS_PER_FILE_V5)\n\t);\n}\n\n// Counting starts with 5, because we only implemented this after reaching protocol file format 5\n@nvmFileID(\n\t(id) =>\n\t\tid >= LRNodeInfoFileV5IDBase\n\t\t&& id\n\t\t\t< LRNodeInfoFileV5IDBase + MAX_NODES_LR / LR_NODEINFOS_PER_FILE_V5,\n)\n@nvmSection(\"protocol\")\nexport class LRNodeInfoFileV5 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | LRNodeInfoFileV5Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeInfos = [];\n\t\t\tfor (let i = 0; i < LR_NODEINFOS_PER_FILE_V5; i++) {\n\t\t\t\tconst nodeId = (this.fileId - LRNodeInfoFileV5IDBase)\n\t\t\t\t\t\t* LR_NODEINFOS_PER_FILE_V5\n\t\t\t\t\t+ 256\n\t\t\t\t\t+ i;\n\t\t\t\tconst offset = i * LR_NODEINFO_SIZE;\n\t\t\t\tconst entry = this.payload.subarray(\n\t\t\t\t\toffset,\n\t\t\t\t\toffset + LR_NODEINFO_SIZE,\n\t\t\t\t);\n\t\t\t\tif (entry.equals(emptyNodeInfo)) continue;\n\n\t\t\t\tconst nodeInfo = parseLRNodeInfo(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tentry,\n\t\t\t\t\t0,\n\t\t\t\t);\n\t\t\t\tthis.nodeInfos.push(nodeInfo);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.nodeInfos = options.nodeInfos;\n\t\t}\n\t}\n\n\tpublic nodeInfos: LRNodeInfo[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\t// The infos must be sorted by node ID\n\t\tthis.nodeInfos.sort((a, b) => a.nodeId - b.nodeId);\n\t\tconst minNodeId = this.nodeInfos[0].nodeId;\n\t\tthis.fileId = nodeIdToLRNodeInfoFileIDV5(minNodeId);\n\n\t\tthis.payload = new Bytes(LR_NODEINFO_SIZE * LR_NODEINFOS_PER_FILE_V5)\n\t\t\t.fill(EMPTY_NODEINFO_FILL);\n\n\t\tconst minFileNodeId =\n\t\t\tMath.floor((minNodeId - 256) / LR_NODEINFOS_PER_FILE_V5)\n\t\t\t\t* LR_NODEINFOS_PER_FILE_V5\n\t\t\t+ 256;\n\n\t\tfor (const nodeInfo of this.nodeInfos) {\n\t\t\tconst offset = (nodeInfo.nodeId - minFileNodeId) * LR_NODEINFO_SIZE;\n\t\t\tthis.payload.set(encodeLRNodeInfo(nodeInfo), offset);\n\t\t}\n\n\t\treturn super.serialize();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"node infos\": this.nodeInfos,\n\t\t};\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAYO;AACP,
|
|
4
|
+
"sourcesContent": ["import {\n\ttype DataRate,\n\ttype FLiRS,\n\tMAX_NODES,\n\tMAX_NODES_LR,\n\tNUM_NODEMASK_BYTES,\n\ttype NodeProtocolInfo,\n\tNodeType,\n\tencodeBitMask,\n\tencodeNodeProtocolInfo,\n\tparseBitMask,\n\tparseNodeProtocolInfo,\n} from \"@zwave-js/core\";\nimport { Bytes, type BytesView, pick } from \"@zwave-js/shared\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport const NODEINFOS_PER_FILE_V1 = 4;\nexport const LR_NODEINFOS_PER_FILE_V5 = 50;\nconst NODEINFO_SIZE = 1 + 5 + NUM_NODEMASK_BYTES;\nconst LR_NODEINFO_SIZE = 3;\nconst EMPTY_NODEINFO_FILL = 0xff;\nconst emptyNodeInfo = new Uint8Array(NODEINFO_SIZE).fill(EMPTY_NODEINFO_FILL);\n\nexport interface NodeInfo\n\textends Omit<NodeProtocolInfo, \"hasSpecificDeviceClass\">\n{\n\tnodeId: number;\n\tgenericDeviceClass: number;\n\tspecificDeviceClass?: number | null;\n\tneighbors: number[];\n\tsucUpdateIndex: number;\n}\n\nfunction parseNodeInfo(\n\tnodeId: number,\n\tbuffer: BytesView,\n\toffset: number,\n): NodeInfo {\n\tconst { hasSpecificDeviceClass, ...protocolInfo } = parseNodeProtocolInfo(\n\t\tbuffer,\n\t\toffset,\n\t);\n\tconst genericDeviceClass = buffer[offset + 3];\n\tconst specificDeviceClass = hasSpecificDeviceClass\n\t\t? buffer[offset + 4]\n\t\t: null;\n\tconst neighbors = parseBitMask(\n\t\tbuffer.subarray(offset + 5, offset + 5 + NUM_NODEMASK_BYTES),\n\t);\n\tconst sucUpdateIndex = buffer[offset + 5 + NUM_NODEMASK_BYTES];\n\treturn {\n\t\tnodeId,\n\t\t...protocolInfo,\n\t\tgenericDeviceClass,\n\t\tspecificDeviceClass,\n\t\tneighbors,\n\t\tsucUpdateIndex,\n\t};\n}\n\nfunction encodeNodeInfo(nodeInfo: NodeInfo): Bytes {\n\tconst ret = new Bytes(NODEINFO_SIZE);\n\n\tconst hasSpecificDeviceClass = nodeInfo.specificDeviceClass != null;\n\tconst protocolInfo: NodeProtocolInfo = {\n\t\t...pick(nodeInfo, [\n\t\t\t\"isListening\",\n\t\t\t\"isFrequentListening\",\n\t\t\t\"isRouting\",\n\t\t\t\"supportedDataRates\",\n\t\t\t\"protocolVersion\",\n\t\t\t\"optionalFunctionality\",\n\t\t\t\"nodeType\",\n\t\t\t\"supportsSecurity\",\n\t\t\t\"supportsBeaming\",\n\t\t]),\n\t\thasSpecificDeviceClass,\n\t};\n\tret.set(encodeNodeProtocolInfo(protocolInfo), 0);\n\n\tret[3] = nodeInfo.genericDeviceClass;\n\tif (hasSpecificDeviceClass) ret[4] = nodeInfo.specificDeviceClass!;\n\tret.set(encodeBitMask(nodeInfo.neighbors, MAX_NODES), 5);\n\tret[5 + NUM_NODEMASK_BYTES] = nodeInfo.sucUpdateIndex;\n\n\treturn ret;\n}\n\nexport interface LRNodeInfo\n\textends Omit<NodeProtocolInfo, \"hasSpecificDeviceClass\">\n{\n\tnodeId: number;\n\tgenericDeviceClass: number;\n\tspecificDeviceClass?: number | null;\n}\n\nfunction parseLRNodeInfo(\n\tnodeId: number,\n\tbuffer: BytesView,\n\toffset: number,\n): LRNodeInfo {\n\t// The node info in LR NVM files is packed:\n\t// Byte 0 CAPABILITY:\n\t// Bit 0: Routing (?)\n\t// Bit 1: Listening\n\t// Bit 2: has specific device class (?)\n\t// Bit 3: Beam capability\n\t// Bit 4: Optional functionality\n\t// Bits 5-6: FLiRS\n\t// Bit 7: Unused (?)\n\t// Byte 1: Generic device class\n\t// Byte 2: Specific device class\n\n\t// Protocol version is always 3\n\t// Security is always true\n\t// Supported speed is always 100kbps (speed = 0, speed ext = 2)\n\t// Never: routing end node, controller\n\n\tconst capability = buffer[offset];\n\tconst isRouting = !!(capability & 0b0000_0001); // ZWLR Mesh??\n\tconst isListening = !!(capability & 0b0000_0010);\n\tconst hasSpecificDeviceClass = !!(capability & 0b0000_0100);\n\tconst supportsBeaming = !!(capability & 0b0000_1000);\n\tconst optionalFunctionality = !!(capability & 0b0001_0000);\n\tlet isFrequentListening: FLiRS;\n\tswitch (capability & 0b0110_0000) {\n\t\tcase 0b0100_0000:\n\t\t\tisFrequentListening = \"1000ms\";\n\t\t\tbreak;\n\t\tcase 0b0010_0000:\n\t\t\tisFrequentListening = \"250ms\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tisFrequentListening = false;\n\t}\n\tconst nodeType = NodeType[\"End Node\"];\n\tconst supportsSecurity = true;\n\tconst protocolVersion = 3;\n\tconst supportedDataRates: DataRate[] = [100000];\n\n\treturn {\n\t\tnodeId,\n\t\tisRouting,\n\t\tisListening,\n\t\tsupportsBeaming,\n\t\tisFrequentListening,\n\t\toptionalFunctionality,\n\t\tnodeType,\n\t\tsupportsSecurity,\n\t\tprotocolVersion,\n\t\tsupportedDataRates,\n\t\tgenericDeviceClass: buffer[offset + 1],\n\t\tspecificDeviceClass: hasSpecificDeviceClass ? buffer[offset + 2] : null,\n\t};\n}\n\nfunction encodeLRNodeInfo(nodeInfo: LRNodeInfo): BytesView {\n\tconst ret = new Bytes(LR_NODEINFO_SIZE);\n\n\tlet capability = 0;\n\tif (nodeInfo.isRouting) capability |= 0b0000_0001;\n\tif (nodeInfo.isListening) capability |= 0b0000_0010;\n\tif (nodeInfo.specificDeviceClass != null) capability |= 0b0000_0100;\n\tif (nodeInfo.supportsBeaming) capability |= 0b0000_1000;\n\tif (nodeInfo.optionalFunctionality) capability |= 0b0001_0000;\n\tif (nodeInfo.isFrequentListening === \"1000ms\") {\n\t\tcapability |= 0b0100_0000;\n\t} else if (nodeInfo.isFrequentListening === \"250ms\") {\n\t\tcapability |= 0b0010_0000;\n\t}\n\n\tret[0] = capability;\n\tret[1] = nodeInfo.genericDeviceClass;\n\tret[2] = nodeInfo.specificDeviceClass ?? 0;\n\n\treturn ret;\n}\n\nexport interface NodeInfoFileV0Options extends NVMFileCreationOptions {\n\tnodeInfo: NodeInfo;\n}\n\nexport const NodeInfoFileV0IDBase = 0x50100;\nexport function nodeIdToNodeInfoFileIDV0(nodeId: number): number {\n\treturn NodeInfoFileV0IDBase + nodeId - 1;\n}\n\n@nvmFileID(\n\t(id) => id >= NodeInfoFileV0IDBase && id < NodeInfoFileV0IDBase + MAX_NODES,\n)\n@nvmSection(\"protocol\")\nexport class NodeInfoFileV0 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | NodeInfoFileV0Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeInfo = parseNodeInfo(\n\t\t\t\tthis.fileId - NodeInfoFileV0IDBase + 1,\n\t\t\t\tthis.payload,\n\t\t\t\t0,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.nodeInfo = options.nodeInfo;\n\t\t}\n\t}\n\n\tpublic nodeInfo: NodeInfo;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.fileId = nodeIdToNodeInfoFileIDV0(this.nodeInfo.nodeId);\n\t\tthis.payload = encodeNodeInfo(this.nodeInfo);\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\tnodeInfo: this.nodeInfo,\n\t\t};\n\t}\n}\n\nexport interface NodeInfoFileV1Options extends NVMFileCreationOptions {\n\tnodeInfos: NodeInfo[];\n}\n\nexport const NodeInfoFileV1IDBase = 0x50200;\nexport function nodeIdToNodeInfoFileIDV1(nodeId: number): number {\n\treturn (\n\t\tNodeInfoFileV1IDBase + Math.floor((nodeId - 1) / NODEINFOS_PER_FILE_V1)\n\t);\n}\n\n@nvmFileID(\n\t(id) =>\n\t\tid >= NodeInfoFileV1IDBase\n\t\t&& id < NodeInfoFileV1IDBase + MAX_NODES / NODEINFOS_PER_FILE_V1,\n)\n@nvmSection(\"protocol\")\nexport class NodeInfoFileV1 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | NodeInfoFileV1Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeInfos = [];\n\t\t\tfor (let i = 0; i < NODEINFOS_PER_FILE_V1; i++) {\n\t\t\t\tconst nodeId = (this.fileId - NodeInfoFileV1IDBase)\n\t\t\t\t\t\t* NODEINFOS_PER_FILE_V1\n\t\t\t\t\t+ 1\n\t\t\t\t\t+ i;\n\t\t\t\tconst offset = i * NODEINFO_SIZE;\n\t\t\t\tconst entry = this.payload.subarray(\n\t\t\t\t\toffset,\n\t\t\t\t\toffset + NODEINFO_SIZE,\n\t\t\t\t);\n\t\t\t\tif (entry.equals(emptyNodeInfo)) continue;\n\n\t\t\t\tconst nodeInfo = parseNodeInfo(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tentry,\n\t\t\t\t\t0,\n\t\t\t\t);\n\t\t\t\tthis.nodeInfos.push(nodeInfo);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.nodeInfos = options.nodeInfos;\n\t\t}\n\t}\n\n\tpublic nodeInfos: NodeInfo[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\t// The infos must be sorted by node ID\n\t\tthis.nodeInfos.sort((a, b) => a.nodeId - b.nodeId);\n\t\tconst minNodeId = this.nodeInfos[0].nodeId;\n\t\tthis.fileId = nodeIdToNodeInfoFileIDV1(minNodeId);\n\n\t\tthis.payload = new Bytes(NODEINFO_SIZE * NODEINFOS_PER_FILE_V1).fill(\n\t\t\tEMPTY_NODEINFO_FILL,\n\t\t);\n\n\t\tconst minFileNodeId =\n\t\t\tMath.floor((minNodeId - 1) / NODEINFOS_PER_FILE_V1)\n\t\t\t\t* NODEINFOS_PER_FILE_V1\n\t\t\t+ 1;\n\n\t\tfor (const nodeInfo of this.nodeInfos) {\n\t\t\tconst offset = (nodeInfo.nodeId - minFileNodeId) * NODEINFO_SIZE;\n\t\t\tthis.payload.set(encodeNodeInfo(nodeInfo), offset);\n\t\t}\n\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"node infos\": this.nodeInfos,\n\t\t};\n\t}\n}\n\nexport interface LRNodeInfoFileV5Options extends NVMFileCreationOptions {\n\tnodeInfos: LRNodeInfo[];\n}\n\nexport const LRNodeInfoFileV5IDBase = 0x50800;\nexport function nodeIdToLRNodeInfoFileIDV5(nodeId: number): number {\n\treturn (\n\t\tLRNodeInfoFileV5IDBase\n\t\t+ Math.floor((nodeId - 256) / LR_NODEINFOS_PER_FILE_V5)\n\t);\n}\n\n// Counting starts with 5, because we only implemented this after reaching protocol file format 5\n@nvmFileID(\n\t(id) =>\n\t\tid >= LRNodeInfoFileV5IDBase\n\t\t&& id\n\t\t\t< LRNodeInfoFileV5IDBase + MAX_NODES_LR / LR_NODEINFOS_PER_FILE_V5,\n)\n@nvmSection(\"protocol\")\nexport class LRNodeInfoFileV5 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | LRNodeInfoFileV5Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeInfos = [];\n\t\t\tfor (let i = 0; i < LR_NODEINFOS_PER_FILE_V5; i++) {\n\t\t\t\tconst nodeId = (this.fileId - LRNodeInfoFileV5IDBase)\n\t\t\t\t\t\t* LR_NODEINFOS_PER_FILE_V5\n\t\t\t\t\t+ 256\n\t\t\t\t\t+ i;\n\t\t\t\tconst offset = i * LR_NODEINFO_SIZE;\n\t\t\t\tconst entry = this.payload.subarray(\n\t\t\t\t\toffset,\n\t\t\t\t\toffset + LR_NODEINFO_SIZE,\n\t\t\t\t);\n\t\t\t\tif (entry.equals(emptyNodeInfo)) continue;\n\n\t\t\t\tconst nodeInfo = parseLRNodeInfo(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tentry,\n\t\t\t\t\t0,\n\t\t\t\t);\n\t\t\t\tthis.nodeInfos.push(nodeInfo);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.nodeInfos = options.nodeInfos;\n\t\t}\n\t}\n\n\tpublic nodeInfos: LRNodeInfo[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\t// The infos must be sorted by node ID\n\t\tthis.nodeInfos.sort((a, b) => a.nodeId - b.nodeId);\n\t\tconst minNodeId = this.nodeInfos[0].nodeId;\n\t\tthis.fileId = nodeIdToLRNodeInfoFileIDV5(minNodeId);\n\n\t\tthis.payload = new Bytes(LR_NODEINFO_SIZE * LR_NODEINFOS_PER_FILE_V5)\n\t\t\t.fill(EMPTY_NODEINFO_FILL);\n\n\t\tconst minFileNodeId =\n\t\t\tMath.floor((minNodeId - 256) / LR_NODEINFOS_PER_FILE_V5)\n\t\t\t\t* LR_NODEINFOS_PER_FILE_V5\n\t\t\t+ 256;\n\n\t\tfor (const nodeInfo of this.nodeInfos) {\n\t\t\tconst offset = (nodeInfo.nodeId - minFileNodeId) * LR_NODEINFO_SIZE;\n\t\t\tthis.payload.set(encodeLRNodeInfo(nodeInfo), offset);\n\t\t}\n\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/expl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AAA,uBAAA;;IACZ,YACC,SAAgE;AAEhE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,aAAK,YAAY,CAAA;AACjB,iBAAS,IAAI,GAAG,IAAI,0BAA0B,KAAK;AAClD,gBAAM,UAAU,KAAK,SAAS,0BAC1B,2BACD,MACA;AACH,gBAAM,SAAS,IAAI;AACnB,gBAAM,QAAQ,KAAK,QAAQ,SAC1B,QACA,SAAS,gBAAgB;AAE1B,cAAI,MAAM,OAAO,aAAa;AAAG;AAEjC,gBAAM,WAAW,gBAChB,QACA,OACA,CAAC;AAEF,eAAK,UAAU,KAAK,QAAQ;QAC7B;MACD,OAAO;AACN,aAAK,YAAY,QAAQ;MAC1B;IACD;IAEO;IAEA,YAAS;AAEf,WAAK,UAAU,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;AACjD,YAAM,YAAY,KAAK,UAAU,CAAC,EAAE;AACpC,WAAK,SAAS,2BAA2B,SAAS;AAElD,WAAK,UAAU,IAAI,oBAAM,mBAAmB,wBAAwB,EAClE,KAAK,mBAAmB;AAE1B,YAAM,gBACL,KAAK,OAAO,YAAY,OAAO,wBAAwB,IACpD,2BACD;AAEH,iBAAW,YAAY,KAAK,WAAW;AACtC,cAAM,UAAU,SAAS,SAAS,iBAAiB;AACnD,aAAK,QAAQ,IAAI,iBAAiB,QAAQ,GAAG,MAAM;MACpD;AAEA,aAAO,MAAM,UAAS;IACvB;;IAGO,SAAM;AACZ,aAAO;QACN,GAAG,MAAM,OAAM;QACf,cAAc,KAAK;;IAErB;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -105,7 +105,7 @@ class ProtocolNodeMaskFile extends import_NVMFile.NVMFile {
|
|
|
105
105
|
this.payload = (0, import_core.encodeBitMask)([...this.nodeIdSet], import_core.NODE_ID_MAX);
|
|
106
106
|
return super.serialize();
|
|
107
107
|
}
|
|
108
|
-
//
|
|
108
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
109
109
|
toJSON() {
|
|
110
110
|
return {
|
|
111
111
|
...super.toJSON(),
|
|
@@ -345,7 +345,7 @@ let ProtocolLRNodeListFile = (() => {
|
|
|
345
345
|
this.payload = (0, import_core.encodeBitMask)([...this.nodeIdSet], 1279, 256);
|
|
346
346
|
return super.serialize();
|
|
347
347
|
}
|
|
348
|
-
//
|
|
348
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
349
349
|
toJSON() {
|
|
350
350
|
return {
|
|
351
351
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/ProtocolNodeMaskFiles.ts"],
|
|
4
|
-
"sourcesContent": ["import { NODE_ID_MAX, encodeBitMask, parseBitMask } from \"@zwave-js/core\";\nimport type { Bytes } from \"@zwave-js/shared\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport interface ProtocolNodeMaskFileOptions extends NVMFileCreationOptions {\n\tnodeIds: number[];\n}\n\nexport class ProtocolNodeMaskFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ProtocolNodeMaskFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeIdSet = new Set(parseBitMask(this.payload));\n\t\t} else {\n\t\t\tthis.nodeIdSet = new Set(options.nodeIds);\n\t\t}\n\t}\n\n\tpublic nodeIdSet: Set<number>;\n\tpublic get nodeIds(): number[] {\n\t\treturn [...this.nodeIdSet];\n\t}\n\tpublic set nodeIds(value: number[]) {\n\t\tthis.nodeIdSet = new Set(value);\n\t}\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = encodeBitMask([...this.nodeIdSet], NODE_ID_MAX);\n\t\treturn super.serialize();\n\t}\n\n\t//
|
|
4
|
+
"sourcesContent": ["import { NODE_ID_MAX, encodeBitMask, parseBitMask } from \"@zwave-js/core\";\nimport type { Bytes } from \"@zwave-js/shared\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport interface ProtocolNodeMaskFileOptions extends NVMFileCreationOptions {\n\tnodeIds: number[];\n}\n\nexport class ProtocolNodeMaskFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ProtocolNodeMaskFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeIdSet = new Set(parseBitMask(this.payload));\n\t\t} else {\n\t\t\tthis.nodeIdSet = new Set(options.nodeIds);\n\t\t}\n\t}\n\n\tpublic nodeIdSet: Set<number>;\n\tpublic get nodeIds(): number[] {\n\t\treturn [...this.nodeIdSet];\n\t}\n\tpublic set nodeIds(value: number[]) {\n\t\tthis.nodeIdSet = new Set(value);\n\t}\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = encodeBitMask([...this.nodeIdSet], NODE_ID_MAX);\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"node IDs\": [...this.nodeIdSet].join(\", \"),\n\t\t};\n\t}\n}\n\nexport const ProtocolPreferredRepeatersFileID = 0x50002;\n\n@nvmFileID(ProtocolPreferredRepeatersFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolPreferredRepeatersFile extends ProtocolNodeMaskFile {}\n\nexport const ProtocolNodeListFileID = 0x50005;\n\n@nvmFileID(ProtocolNodeListFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolNodeListFile extends ProtocolNodeMaskFile {}\n\nexport const ProtocolAppRouteLockNodeMaskFileID = 0x50006;\n\n@nvmFileID(ProtocolAppRouteLockNodeMaskFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolAppRouteLockNodeMaskFile extends ProtocolNodeMaskFile {}\n\nexport const ProtocolRouteSlaveSUCNodeMaskFileID = 0x50007;\n\n@nvmFileID(ProtocolRouteSlaveSUCNodeMaskFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolRouteSlaveSUCNodeMaskFile extends ProtocolNodeMaskFile {}\n\nexport const ProtocolSUCPendingUpdateNodeMaskFileID = 0x50008;\n\n@nvmFileID(ProtocolSUCPendingUpdateNodeMaskFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolSUCPendingUpdateNodeMaskFile\n\textends ProtocolNodeMaskFile\n{}\n\nexport const ProtocolVirtualNodeMaskFileID = 0x50009;\n\n@nvmFileID(ProtocolVirtualNodeMaskFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolVirtualNodeMaskFile extends ProtocolNodeMaskFile {}\n\nexport const ProtocolPendingDiscoveryNodeMaskFileID = 0x5000a;\n\n@nvmFileID(ProtocolPendingDiscoveryNodeMaskFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolPendingDiscoveryNodeMaskFile\n\textends ProtocolNodeMaskFile\n{}\n\nexport const ProtocolRouteCacheExistsNodeMaskFileID = 0x5000b;\n\n@nvmFileID(ProtocolRouteCacheExistsNodeMaskFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolRouteCacheExistsNodeMaskFile\n\textends ProtocolNodeMaskFile\n{}\n\nexport const ProtocolLRNodeListFileID = 0x5000c;\n\n@nvmFileID(ProtocolLRNodeListFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolLRNodeListFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ProtocolNodeMaskFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.nodeIdSet = new Set(parseBitMask(this.payload, 256));\n\t\t} else {\n\t\t\tthis.nodeIdSet = new Set(options.nodeIds);\n\t\t}\n\t}\n\n\tpublic nodeIdSet: Set<number>;\n\tpublic get nodeIds(): number[] {\n\t\treturn [...this.nodeIdSet];\n\t}\n\tpublic set nodeIds(value: number[]) {\n\t\tthis.nodeIdSet = new Set(value);\n\t}\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\t// There are only 128 bytes for the bitmask, so the LR node IDs only go up to 1279\n\t\tthis.payload = encodeBitMask([...this.nodeIdSet], 1279, 256);\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"node IDs\": [...this.nodeIdSet].join(\", \"),\n\t\t};\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAyD;AAGzD,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMD,MAAO,6BAA6B,uBAAO;SAAA;;;EAChD,YACC,SAAoE;AAEpE,UAAM,OAAO;AACb,YAAI,0CAA0B,OAAO,GAAG;AACvC,WAAK,YAAY,IAAI,QAAI,0BAAa,KAAK,OAAO,CAAC;IACpD,OAAO;AACN,WAAK,YAAY,IAAI,IAAI,QAAQ,OAAO;IACzC;EACD;EAEO;EACP,IAAW,UAAO;AACjB,WAAO,CAAC,GAAG,KAAK,SAAS;EAC1B;EACA,IAAW,QAAQ,OAAe;AACjC,SAAK,YAAY,IAAI,IAAI,KAAK;EAC/B;EAEO,YAAS;AACf,SAAK,cAAU,2BAAc,CAAC,GAAG,KAAK,SAAS,GAAG,uBAAW;AAC7D,WAAO,MAAM,UAAS;EACvB;;EAGO,SAAM;AACZ,WAAO;MACN,GAAG,MAAM,OAAM;MACf,YAAY,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UAAU,CAAC;;;;oBACqB;8CAAA,YAAO;WAAA;;;;;;;;AAAnD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACZ,YACC,SAAoE;AAEpE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,aAAK,YAAY,IAAI,QAAI,0BAAa,KAAK,SAAS,GAAG,CAAC;MACzD,OAAO;AACN,aAAK,YAAY,IAAI,IAAI,QAAQ,OAAO;MACzC;IACD;IAEO;IACP,IAAW,UAAO;AACjB,aAAO,CAAC,GAAG,KAAK,SAAS;IAC1B;IACA,IAAW,QAAQ,OAAe;AACjC,WAAK,YAAY,IAAI,IAAI,KAAK;IAC/B;IAEO,YAAS;AAEf,WAAK,cAAU,2BAAc,CAAC,GAAG,KAAK,SAAS,GAAG,MAAM,GAAG;AAC3D,aAAO,MAAM,UAAS;IACvB;;IAGO,SAAM;AACZ,aAAO;QACN,GAAG,MAAM,OAAM;QACf,YAAY,CAAC,GAAG,KAAK,SAAS,EAAE,KAAK,IAAI;;IAE3C;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -118,7 +118,7 @@ let RouteCacheFileV0 = (() => {
|
|
|
118
118
|
]);
|
|
119
119
|
return super.serialize();
|
|
120
120
|
}
|
|
121
|
-
//
|
|
121
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
122
122
|
toJSON() {
|
|
123
123
|
return {
|
|
124
124
|
...super.toJSON(),
|
|
@@ -188,7 +188,7 @@ let RouteCacheFileV1 = (() => {
|
|
|
188
188
|
}
|
|
189
189
|
return super.serialize();
|
|
190
190
|
}
|
|
191
|
-
//
|
|
191
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
192
192
|
toJSON() {
|
|
193
193
|
return {
|
|
194
194
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/RouteCacheFiles.ts"],
|
|
4
|
-
"sourcesContent": ["import { MAX_NODES, MAX_REPEATERS } from \"@zwave-js/core\";\nimport { Bytes } from \"@zwave-js/shared\";\nimport {\n\tEMPTY_ROUTECACHE_FILL,\n\tROUTECACHE_SIZE,\n\ttype RouteCache,\n\temptyRouteCache,\n\tencodeRoute,\n\tparseRoute,\n} from \"../../common/routeCache.js\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport const ROUTECACHES_PER_FILE_V1 = 8;\n\nexport interface RouteCacheFileV0Options extends NVMFileCreationOptions {\n\trouteCache: RouteCache;\n}\n\nexport const RouteCacheFileV0IDBase = 0x50400;\nexport function nodeIdToRouteCacheFileIDV0(nodeId: number): number {\n\treturn RouteCacheFileV0IDBase + nodeId - 1;\n}\n\n@nvmFileID(\n\t(id) =>\n\t\tid >= RouteCacheFileV0IDBase && id < RouteCacheFileV0IDBase + MAX_NODES,\n)\n@nvmSection(\"protocol\")\nexport class RouteCacheFileV0 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | RouteCacheFileV0Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tconst nodeId = this.fileId - RouteCacheFileV0IDBase + 1;\n\t\t\tconst lwr = parseRoute(this.payload, 0);\n\t\t\tconst nlwr = parseRoute(this.payload, MAX_REPEATERS + 1);\n\t\t\tthis.routeCache = { nodeId, lwr, nlwr };\n\t\t} else {\n\t\t\tthis.routeCache = options.routeCache;\n\t\t}\n\t}\n\n\tpublic routeCache: RouteCache;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.fileId = nodeIdToRouteCacheFileIDV0(this.routeCache.nodeId);\n\t\tthis.payload = Bytes.concat([\n\t\t\tencodeRoute(this.routeCache.lwr),\n\t\t\tencodeRoute(this.routeCache.nlwr),\n\t\t]);\n\t\treturn super.serialize();\n\t}\n\n\t//
|
|
4
|
+
"sourcesContent": ["import { MAX_NODES, MAX_REPEATERS } from \"@zwave-js/core\";\nimport { Bytes } from \"@zwave-js/shared\";\nimport {\n\tEMPTY_ROUTECACHE_FILL,\n\tROUTECACHE_SIZE,\n\ttype RouteCache,\n\temptyRouteCache,\n\tencodeRoute,\n\tparseRoute,\n} from \"../../common/routeCache.js\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport const ROUTECACHES_PER_FILE_V1 = 8;\n\nexport interface RouteCacheFileV0Options extends NVMFileCreationOptions {\n\trouteCache: RouteCache;\n}\n\nexport const RouteCacheFileV0IDBase = 0x50400;\nexport function nodeIdToRouteCacheFileIDV0(nodeId: number): number {\n\treturn RouteCacheFileV0IDBase + nodeId - 1;\n}\n\n@nvmFileID(\n\t(id) =>\n\t\tid >= RouteCacheFileV0IDBase && id < RouteCacheFileV0IDBase + MAX_NODES,\n)\n@nvmSection(\"protocol\")\nexport class RouteCacheFileV0 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | RouteCacheFileV0Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tconst nodeId = this.fileId - RouteCacheFileV0IDBase + 1;\n\t\t\tconst lwr = parseRoute(this.payload, 0);\n\t\t\tconst nlwr = parseRoute(this.payload, MAX_REPEATERS + 1);\n\t\t\tthis.routeCache = { nodeId, lwr, nlwr };\n\t\t} else {\n\t\t\tthis.routeCache = options.routeCache;\n\t\t}\n\t}\n\n\tpublic routeCache: RouteCache;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.fileId = nodeIdToRouteCacheFileIDV0(this.routeCache.nodeId);\n\t\tthis.payload = Bytes.concat([\n\t\t\tencodeRoute(this.routeCache.lwr),\n\t\t\tencodeRoute(this.routeCache.nlwr),\n\t\t]);\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\trouteCache: this.routeCache,\n\t\t};\n\t}\n}\n\nexport interface RouteCacheFileV1Options extends NVMFileCreationOptions {\n\trouteCaches: RouteCache[];\n}\n\nexport const RouteCacheFileV1IDBase = 0x51400;\nexport function nodeIdToRouteCacheFileIDV1(nodeId: number): number {\n\treturn (\n\t\tRouteCacheFileV1IDBase\n\t\t+ Math.floor((nodeId - 1) / ROUTECACHES_PER_FILE_V1)\n\t);\n}\n\n@nvmFileID(\n\t(id) =>\n\t\tid >= RouteCacheFileV1IDBase\n\t\t&& id < RouteCacheFileV1IDBase + MAX_NODES / ROUTECACHES_PER_FILE_V1,\n)\n@nvmSection(\"protocol\")\nexport class RouteCacheFileV1 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | RouteCacheFileV1Options,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.routeCaches = [];\n\t\t\tfor (let i = 0; i < ROUTECACHES_PER_FILE_V1; i++) {\n\t\t\t\tconst offset = i * 2 * (MAX_REPEATERS + 1);\n\t\t\t\tconst entry = this.payload.subarray(\n\t\t\t\t\toffset,\n\t\t\t\t\toffset + 2 * (MAX_REPEATERS + 1),\n\t\t\t\t);\n\t\t\t\tif (entry.equals(emptyRouteCache)) continue;\n\n\t\t\t\tconst nodeId = (this.fileId - RouteCacheFileV1IDBase)\n\t\t\t\t\t\t* ROUTECACHES_PER_FILE_V1\n\t\t\t\t\t+ 1\n\t\t\t\t\t+ i;\n\t\t\t\tconst lwr = parseRoute(this.payload, offset);\n\t\t\t\tconst nlwr = parseRoute(\n\t\t\t\t\tthis.payload,\n\t\t\t\t\toffset + MAX_REPEATERS + 1,\n\t\t\t\t);\n\n\t\t\t\tthis.routeCaches.push({ nodeId, lwr, nlwr });\n\t\t\t}\n\t\t} else {\n\t\t\tthis.routeCaches = options.routeCaches;\n\t\t}\n\t}\n\n\tpublic routeCaches: RouteCache[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\t// The route infos must be sorted by node ID\n\t\tthis.routeCaches.sort((a, b) => a.nodeId - b.nodeId);\n\t\tconst minNodeId = this.routeCaches[0].nodeId;\n\t\tthis.fileId = nodeIdToRouteCacheFileIDV1(minNodeId);\n\n\t\tthis.payload = new Bytes(ROUTECACHES_PER_FILE_V1 * ROUTECACHE_SIZE)\n\t\t\t.fill(EMPTY_ROUTECACHE_FILL);\n\n\t\tconst minFileNodeId =\n\t\t\tMath.floor((minNodeId - 1) / ROUTECACHES_PER_FILE_V1)\n\t\t\t\t* ROUTECACHES_PER_FILE_V1\n\t\t\t+ 1;\n\n\t\tfor (const routeCache of this.routeCaches) {\n\t\t\tconst offset = (routeCache.nodeId - minFileNodeId)\n\t\t\t\t* ROUTECACHE_SIZE;\n\t\t\tconst routes = Bytes.concat([\n\t\t\t\tencodeRoute(routeCache.lwr),\n\t\t\t\tencodeRoute(routeCache.nlwr),\n\t\t\t]);\n\t\t\tthis.payload.set(routes, offset);\n\t\t}\n\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"route caches\": this.routeCaches,\n\t\t};\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAyC;AACzC,oBAAsB;AACtB,wBAOO;AAEP,qBAOO;;;;;;;;;;;;;;;;;;;;;;;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AAO,MAAM,UAAS;IACvB;;IAGO,SAAM;AACZ,aAAO;QACN,GAAG,MAAM,OAAM;QACf,gBAAgB,KAAK;;IAEvB;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -118,7 +118,7 @@ let SUCUpdateEntriesFileV0 = (() => {
|
|
|
118
118
|
}
|
|
119
119
|
return super.serialize();
|
|
120
120
|
}
|
|
121
|
-
//
|
|
121
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
122
122
|
toJSON() {
|
|
123
123
|
return {
|
|
124
124
|
...super.toJSON(),
|
|
@@ -178,7 +178,7 @@ let SUCUpdateEntriesFileV5 = (() => {
|
|
|
178
178
|
}
|
|
179
179
|
return super.serialize();
|
|
180
180
|
}
|
|
181
|
-
//
|
|
181
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
182
182
|
toJSON() {
|
|
183
183
|
return {
|
|
184
184
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/SUCUpdateEntriesFile.ts"],
|
|
4
|
-
"sourcesContent": ["import { Bytes } from \"@zwave-js/shared\";\nimport { SUC_MAX_UPDATES, SUC_UPDATE_ENTRY_SIZE } from \"../../../consts.js\";\nimport {\n\ttype SUCUpdateEntry,\n\tencodeSUCUpdateEntry,\n\tparseSUCUpdateEntry,\n} from \"../../common/sucUpdateEntry.js\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport const SUC_UPDATES_PER_FILE_V5 = 8;\n\nexport interface SUCUpdateEntriesFileOptions extends NVMFileCreationOptions {\n\tupdateEntries: SUCUpdateEntry[];\n}\n\nexport const SUCUpdateEntriesFileIDV0 = 0x50003;\n\n@nvmFileID(SUCUpdateEntriesFileIDV0)\n@nvmSection(\"protocol\")\nexport class SUCUpdateEntriesFileV0 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | SUCUpdateEntriesFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.updateEntries = [];\n\t\t\tfor (let entry = 0; entry < SUC_MAX_UPDATES; entry++) {\n\t\t\t\tconst offset = entry * SUC_UPDATE_ENTRY_SIZE;\n\t\t\t\tconst updateEntry = parseSUCUpdateEntry(this.payload, offset);\n\t\t\t\tif (updateEntry) this.updateEntries.push(updateEntry);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.updateEntries = options.updateEntries;\n\t\t}\n\t}\n\n\tpublic updateEntries: SUCUpdateEntry[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = new Bytes(SUC_MAX_UPDATES * SUC_UPDATE_ENTRY_SIZE).fill(\n\t\t\t0,\n\t\t);\n\t\tfor (let i = 0; i < this.updateEntries.length; i++) {\n\t\t\tconst offset = i * SUC_UPDATE_ENTRY_SIZE;\n\t\t\tconst entry = this.updateEntries[i];\n\t\t\tthis.payload.set(encodeSUCUpdateEntry(entry), offset);\n\t\t}\n\t\treturn super.serialize();\n\t}\n\n\t//
|
|
4
|
+
"sourcesContent": ["import { Bytes } from \"@zwave-js/shared\";\nimport { SUC_MAX_UPDATES, SUC_UPDATE_ENTRY_SIZE } from \"../../../consts.js\";\nimport {\n\ttype SUCUpdateEntry,\n\tencodeSUCUpdateEntry,\n\tparseSUCUpdateEntry,\n} from \"../../common/sucUpdateEntry.js\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport const SUC_UPDATES_PER_FILE_V5 = 8;\n\nexport interface SUCUpdateEntriesFileOptions extends NVMFileCreationOptions {\n\tupdateEntries: SUCUpdateEntry[];\n}\n\nexport const SUCUpdateEntriesFileIDV0 = 0x50003;\n\n@nvmFileID(SUCUpdateEntriesFileIDV0)\n@nvmSection(\"protocol\")\nexport class SUCUpdateEntriesFileV0 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | SUCUpdateEntriesFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.updateEntries = [];\n\t\t\tfor (let entry = 0; entry < SUC_MAX_UPDATES; entry++) {\n\t\t\t\tconst offset = entry * SUC_UPDATE_ENTRY_SIZE;\n\t\t\t\tconst updateEntry = parseSUCUpdateEntry(this.payload, offset);\n\t\t\t\tif (updateEntry) this.updateEntries.push(updateEntry);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.updateEntries = options.updateEntries;\n\t\t}\n\t}\n\n\tpublic updateEntries: SUCUpdateEntry[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = new Bytes(SUC_MAX_UPDATES * SUC_UPDATE_ENTRY_SIZE).fill(\n\t\t\t0,\n\t\t);\n\t\tfor (let i = 0; i < this.updateEntries.length; i++) {\n\t\t\tconst offset = i * SUC_UPDATE_ENTRY_SIZE;\n\t\t\tconst entry = this.updateEntries[i];\n\t\t\tthis.payload.set(encodeSUCUpdateEntry(entry), offset);\n\t\t}\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"SUC update entries\": this.updateEntries,\n\t\t};\n\t}\n}\n\nexport const SUCUpdateEntriesFileV5IDBase = 0x54000;\nexport const SUCUpdateEntriesFileV5IDMax = SUCUpdateEntriesFileV5IDBase\n\t+ SUC_MAX_UPDATES / SUC_UPDATES_PER_FILE_V5\n\t- 1;\nexport function sucUpdateIndexToSUCUpdateEntriesFileIDV5(\n\tindex: number,\n): number {\n\treturn (\n\t\tSUCUpdateEntriesFileV5IDBase\n\t\t+ Math.floor(index / SUC_UPDATES_PER_FILE_V5)\n\t);\n}\n\n@nvmFileID(\n\t(id) =>\n\t\tid >= SUCUpdateEntriesFileV5IDBase\n\t\t&& id <= SUCUpdateEntriesFileV5IDMax,\n)\n@nvmSection(\"protocol\")\nexport class SUCUpdateEntriesFileV5 extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | SUCUpdateEntriesFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.updateEntries = [];\n\t\t\tfor (let entry = 0; entry < SUC_UPDATES_PER_FILE_V5; entry++) {\n\t\t\t\tconst offset = entry * SUC_UPDATE_ENTRY_SIZE;\n\t\t\t\tconst updateEntry = parseSUCUpdateEntry(this.payload, offset);\n\t\t\t\tif (updateEntry) this.updateEntries.push(updateEntry);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.updateEntries = options.updateEntries;\n\t\t}\n\t}\n\n\tpublic updateEntries: SUCUpdateEntry[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = new Bytes(\n\t\t\tSUC_UPDATES_PER_FILE_V5 * SUC_UPDATE_ENTRY_SIZE,\n\t\t).fill(0xff);\n\t\tfor (let i = 0; i < this.updateEntries.length; i++) {\n\t\t\tconst offset = i * SUC_UPDATE_ENTRY_SIZE;\n\t\t\tconst entry = this.updateEntries[i];\n\t\t\tthis.payload.set(encodeSUCUpdateEntry(entry), offset);\n\t\t}\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\t\"SUC update entries\": this.updateEntries,\n\t\t};\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAsB;AACtB,oBAAuD;AAC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lC,0BACA,CAAC,OACA,MAAM,gCACH,MAAM,2BAA2B,OAErC,2BAAW,UAAU,CAAC;;;;oBACqB;8CAAA,YAAO;WAAA;;;;;;;;AAAnD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;IACZ,YACC,SAAoE;AAEpE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,aAAK,gBAAgB,CAAA;AACrB,iBAAS,QAAQ,GAAG,QAAQ,yBAAyB,SAAS;AAC7D,gBAAM,SAAS,QAAQ;AACvB,gBAAM,kBAAc,2CAAoB,KAAK,SAAS,MAAM;AAC5D,cAAI;AAAa,iBAAK,cAAc,KAAK,WAAW;QACrD;MACD,OAAO;AACN,aAAK,gBAAgB,QAAQ;MAC9B;IACD;IAEO;IAEA,YAAS;AACf,WAAK,UAAU,IAAI,oBAClB,0BAA0B,mCAAqB,EAC9C,KAAK,GAAI;AACX,eAAS,IAAI,GAAG,IAAI,KAAK,cAAc,QAAQ,KAAK;AACnD,cAAM,SAAS,IAAI;AACnB,cAAM,QAAQ,KAAK,cAAc,CAAC;AAClC,aAAK,QAAQ,QAAI,4CAAqB,KAAK,GAAG,MAAM;MACrD;AACA,aAAO,MAAM,UAAS;IACvB;;IAGO,SAAM;AACZ,aAAO;QACN,GAAG,MAAM,OAAM;QACf,sBAAsB,KAAK;;IAE7B;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -101,7 +101,7 @@ class VersionFile extends import_NVMFile.NVMFile {
|
|
|
101
101
|
]);
|
|
102
102
|
return super.serialize();
|
|
103
103
|
}
|
|
104
|
-
//
|
|
104
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
105
105
|
toJSON() {
|
|
106
106
|
return {
|
|
107
107
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/VersionFiles.ts"],
|
|
4
|
-
"sourcesContent": ["import { Bytes } from \"@zwave-js/shared\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport interface VersionFileOptions extends NVMFileCreationOptions {\n\tformat: number;\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n}\n\nexport class VersionFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | VersionFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.format = this.payload[3];\n\t\t\tthis.major = this.payload[2];\n\t\t\tthis.minor = this.payload[1];\n\t\t\tthis.patch = this.payload[0];\n\t\t} else {\n\t\t\tthis.format = options.format;\n\t\t\tthis.major = options.major;\n\t\t\tthis.minor = options.minor;\n\t\t\tthis.patch = options.patch;\n\t\t}\n\t}\n\n\tpublic format: number;\n\tpublic major: number;\n\tpublic minor: number;\n\tpublic patch: number;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.patch,\n\t\t\tthis.minor,\n\t\t\tthis.major,\n\t\t\tthis.format,\n\t\t]);\n\t\treturn super.serialize();\n\t}\n\n\t//
|
|
4
|
+
"sourcesContent": ["import { Bytes } from \"@zwave-js/shared\";\nimport type { NVM3Object } from \"../object.js\";\nimport {\n\tNVMFile,\n\ttype NVMFileCreationOptions,\n\ttype NVMFileDeserializationOptions,\n\tgotDeserializationOptions,\n\tnvmFileID,\n\tnvmSection,\n} from \"./NVMFile.js\";\n\nexport interface VersionFileOptions extends NVMFileCreationOptions {\n\tformat: number;\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n}\n\nexport class VersionFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | VersionFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.format = this.payload[3];\n\t\t\tthis.major = this.payload[2];\n\t\t\tthis.minor = this.payload[1];\n\t\t\tthis.patch = this.payload[0];\n\t\t} else {\n\t\t\tthis.format = options.format;\n\t\t\tthis.major = options.major;\n\t\t\tthis.minor = options.minor;\n\t\t\tthis.patch = options.patch;\n\t\t}\n\t}\n\n\tpublic format: number;\n\tpublic major: number;\n\tpublic minor: number;\n\tpublic patch: number;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = Bytes.from([\n\t\t\tthis.patch,\n\t\t\tthis.minor,\n\t\t\tthis.major,\n\t\t\tthis.format,\n\t\t]);\n\t\treturn super.serialize();\n\t}\n\n\t// oxlint-disable-next-line typescript/explicit-module-boundary-types\n\tpublic toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\tformat: this.format,\n\t\t\tversion: `${this.major}.${this.minor}.${this.patch}`,\n\t\t};\n\t}\n}\n\nexport const ApplicationVersionFileID = 0x51000;\n\n@nvmFileID(ApplicationVersionFileID)\n@nvmSection(\"application\")\nexport class ApplicationVersionFile extends VersionFile {}\n\n// The 800 series has a shared application/protocol file system\n// and uses a different ID for the application version file\nexport const ApplicationVersionFile800ID = 0x41000;\n\n@nvmFileID(ApplicationVersionFile800ID)\n@nvmSection(\"application\")\nexport class ApplicationVersionFile800 extends VersionFile {}\n\nexport const ProtocolVersionFileID = 0x50000;\n\n@nvmFileID(ProtocolVersionFileID)\n@nvmSection(\"protocol\")\nexport class ProtocolVersionFile extends VersionFile {}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAsB;AAEtB,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASD,MAAO,oBAAoB,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EN,MAAM,wBAAwB;IAIxB,uBAAmB,MAAA;8BAF/B,0BAAU,qBAAqB,OAC/B,2BAAW,UAAU,CAAC;;;;oBACkB;2CAAA,YAAW;WAAA;;;;;;;;AAApD,mBAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,wBAAA,YAAA,uBAAA;;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BytesView } from "@zwave-js/shared";
|
|
1
2
|
import { FragmentType, ObjectType } from "./consts.js";
|
|
2
3
|
export interface NVM3ObjectHeader {
|
|
3
4
|
offset: number;
|
|
@@ -15,9 +16,9 @@ export interface NVM3Object {
|
|
|
15
16
|
type: ObjectType;
|
|
16
17
|
fragmentType: FragmentType;
|
|
17
18
|
key: number;
|
|
18
|
-
data?:
|
|
19
|
+
data?: BytesView;
|
|
19
20
|
}
|
|
20
|
-
export declare function serializeObject(obj: NVM3Object):
|
|
21
|
+
export declare function serializeObject(obj: NVM3Object): BytesView;
|
|
21
22
|
export declare function fragmentLargeObject(obj: NVM3Object & {
|
|
22
23
|
type: ObjectType.DataLarge | ObjectType.CounterLarge;
|
|
23
24
|
}, maxFirstFragmentSizeWithHeader: number, maxFragmentSizeWithHeader: number): NVM3Object[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/nvm3/object.ts"],
|
|
4
|
-
"sourcesContent": ["import { Bytes } from \"@zwave-js/shared\";\nimport {\n\tFragmentType,\n\tNVM3_CODE_LARGE_SHIFT,\n\tNVM3_CODE_SMALL_SHIFT,\n\tNVM3_COUNTER_SIZE,\n\tNVM3_OBJ_FRAGTYPE_MASK,\n\tNVM3_OBJ_FRAGTYPE_SHIFT,\n\tNVM3_OBJ_HEADER_SIZE_LARGE,\n\tNVM3_OBJ_HEADER_SIZE_SMALL,\n\tNVM3_OBJ_KEY_MASK,\n\tNVM3_OBJ_KEY_SHIFT,\n\tNVM3_OBJ_LARGE_LEN_MASK,\n\tNVM3_OBJ_TYPE_MASK,\n\tNVM3_WORD_SIZE,\n\tObjectType,\n} from \"./consts.js\";\nimport { computeBergerCode, computeBergerCodeMulti } from \"./utils.js\";\n\nexport interface NVM3ObjectHeader {\n\toffset: number;\n\ttype: ObjectType;\n\tkey: number;\n\tfragmentType: FragmentType;\n\t/** The length of the header */\n\theaderSize: number;\n\t/** The length of the object data */\n\tfragmentSize: number;\n\t/** The total length of the object in the NVM */\n\talignedSize: number;\n}\n\nexport interface NVM3Object {\n\ttype: ObjectType;\n\tfragmentType: FragmentType;\n\tkey: number;\n\tdata?:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Bytes, type BytesView } from \"@zwave-js/shared\";\nimport {\n\tFragmentType,\n\tNVM3_CODE_LARGE_SHIFT,\n\tNVM3_CODE_SMALL_SHIFT,\n\tNVM3_COUNTER_SIZE,\n\tNVM3_OBJ_FRAGTYPE_MASK,\n\tNVM3_OBJ_FRAGTYPE_SHIFT,\n\tNVM3_OBJ_HEADER_SIZE_LARGE,\n\tNVM3_OBJ_HEADER_SIZE_SMALL,\n\tNVM3_OBJ_KEY_MASK,\n\tNVM3_OBJ_KEY_SHIFT,\n\tNVM3_OBJ_LARGE_LEN_MASK,\n\tNVM3_OBJ_TYPE_MASK,\n\tNVM3_WORD_SIZE,\n\tObjectType,\n} from \"./consts.js\";\nimport { computeBergerCode, computeBergerCodeMulti } from \"./utils.js\";\n\nexport interface NVM3ObjectHeader {\n\toffset: number;\n\ttype: ObjectType;\n\tkey: number;\n\tfragmentType: FragmentType;\n\t/** The length of the header */\n\theaderSize: number;\n\t/** The length of the object data */\n\tfragmentSize: number;\n\t/** The total length of the object in the NVM */\n\talignedSize: number;\n}\n\nexport interface NVM3Object {\n\ttype: ObjectType;\n\tfragmentType: FragmentType;\n\tkey: number;\n\tdata?: BytesView;\n}\n\nexport function serializeObject(obj: NVM3Object): BytesView {\n\tconst isLarge = obj.type === ObjectType.DataLarge\n\t\t|| obj.type === ObjectType.CounterLarge;\n\tconst headerSize = isLarge\n\t\t? NVM3_OBJ_HEADER_SIZE_LARGE\n\t\t: NVM3_OBJ_HEADER_SIZE_SMALL;\n\tconst dataLength = obj.data?.length ?? 0;\n\tconst ret = new Bytes(dataLength + headerSize);\n\n\t// Write header\n\tif (isLarge) {\n\t\tlet hdr2 = dataLength & NVM3_OBJ_LARGE_LEN_MASK;\n\n\t\tconst hdr1 = (obj.type & NVM3_OBJ_TYPE_MASK)\n\t\t\t| ((obj.key & NVM3_OBJ_KEY_MASK) << NVM3_OBJ_KEY_SHIFT)\n\t\t\t| ((obj.fragmentType & NVM3_OBJ_FRAGTYPE_MASK)\n\t\t\t\t<< NVM3_OBJ_FRAGTYPE_SHIFT);\n\n\t\tconst bergerCode = computeBergerCodeMulti(\n\t\t\t[hdr1, hdr2],\n\t\t\t32 + NVM3_CODE_LARGE_SHIFT,\n\t\t);\n\t\thdr2 |= bergerCode << NVM3_CODE_LARGE_SHIFT;\n\n\t\tret.writeInt32LE(hdr1, 0);\n\t\tret.writeInt32LE(hdr2, 4);\n\t} else {\n\t\tlet typeAndLen = obj.type;\n\t\tif (typeAndLen === ObjectType.DataSmall && dataLength > 0) {\n\t\t\ttypeAndLen += dataLength;\n\t\t}\n\t\tlet hdr1 = (typeAndLen & NVM3_OBJ_TYPE_MASK)\n\t\t\t| ((obj.key & NVM3_OBJ_KEY_MASK) << NVM3_OBJ_KEY_SHIFT);\n\t\tconst bergerCode = computeBergerCode(hdr1, NVM3_CODE_SMALL_SHIFT);\n\t\thdr1 |= bergerCode << NVM3_CODE_SMALL_SHIFT;\n\n\t\tret.writeInt32LE(hdr1, 0);\n\t}\n\n\t// Write data\n\tif (obj.data) {\n\t\tret.set(obj.data, headerSize);\n\t}\n\treturn ret;\n}\n\nexport function fragmentLargeObject(\n\tobj: NVM3Object & { type: ObjectType.DataLarge | ObjectType.CounterLarge },\n\tmaxFirstFragmentSizeWithHeader: number,\n\tmaxFragmentSizeWithHeader: number,\n): NVM3Object[] {\n\tconst ret: NVM3Object[] = [];\n\n\tif (\n\t\tobj.data!.length + NVM3_OBJ_HEADER_SIZE_LARGE\n\t\t\t<= maxFirstFragmentSizeWithHeader\n\t) {\n\t\treturn [obj];\n\t}\n\n\tlet offset = 0;\n\twhile (offset < obj.data!.length) {\n\t\tconst fragmentSize = offset === 0\n\t\t\t? maxFirstFragmentSizeWithHeader - NVM3_OBJ_HEADER_SIZE_LARGE\n\t\t\t: maxFragmentSizeWithHeader - NVM3_OBJ_HEADER_SIZE_LARGE;\n\t\tconst data = obj.data!.subarray(offset, offset + fragmentSize);\n\n\t\tret.push({\n\t\t\ttype: obj.type,\n\t\t\tkey: obj.key,\n\t\t\tfragmentType: offset === 0\n\t\t\t\t? FragmentType.First\n\t\t\t\t: data.length + NVM3_OBJ_HEADER_SIZE_LARGE\n\t\t\t\t\t\t< maxFragmentSizeWithHeader\n\t\t\t\t? FragmentType.Last\n\t\t\t\t: FragmentType.Next,\n\t\t\tdata,\n\t\t});\n\n\t\toffset += fragmentSize;\n\t}\n\n\treturn ret;\n}\n\nexport function getAlignedSize(size: number): number {\n\treturn (size + NVM3_WORD_SIZE - 1) & ~(NVM3_WORD_SIZE - 1);\n}\n\nexport function getHeaderSize(obj: NVM3Object): number {\n\tswitch (obj.type) {\n\t\tcase ObjectType.Deleted:\n\t\tcase ObjectType.CounterSmall:\n\t\tcase ObjectType.DataSmall:\n\t\t\treturn NVM3_OBJ_HEADER_SIZE_SMALL;\n\t\tcase ObjectType.CounterLarge:\n\t\tcase ObjectType.DataLarge:\n\t\t\treturn NVM3_OBJ_HEADER_SIZE_LARGE;\n\t}\n}\n\nexport function getFragmentSize(obj: NVM3Object): number {\n\tswitch (obj.type) {\n\t\tcase ObjectType.Deleted:\n\t\t\treturn 0;\n\t\tcase ObjectType.CounterSmall:\n\t\t\treturn NVM3_COUNTER_SIZE;\n\t\tcase ObjectType.DataSmall:\n\t\tcase ObjectType.DataLarge:\n\t\tcase ObjectType.CounterLarge:\n\t\t\treturn obj.data?.length ?? 0;\n\t}\n}\n\nexport function getRequiredSpace(obj: NVM3Object): number {\n\treturn getHeaderSize(obj) + getAlignedSize(getFragmentSize(obj));\n}\n\nexport function getObjectHeader(\n\tobj: NVM3Object,\n\toffset: number,\n): NVM3ObjectHeader {\n\tconst headerSize = getHeaderSize(obj);\n\tconst fragmentSize = getFragmentSize(obj);\n\treturn {\n\t\toffset,\n\t\tkey: obj.key,\n\t\ttype: obj.type,\n\t\tfragmentType: obj.fragmentType,\n\t\theaderSize,\n\t\tfragmentSize,\n\t\talignedSize: headerSize + getAlignedSize(fragmentSize),\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAAA,oBAAsC;AACtC,oBAeO;AACP,mBAA0D;AAsBpD,SAAU,gBAAgB,KAAe;AAC9C,QAAM,UAAU,IAAI,SAAS,yBAAW,aACpC,IAAI,SAAS,yBAAW;AAC5B,QAAM,aAAa,UAChB,2CACA;AACH,QAAM,aAAa,IAAI,MAAM,UAAU;AACvC,QAAM,MAAM,IAAI,oBAAM,aAAa,UAAU;AAG7C,MAAI,SAAS;AACZ,QAAI,OAAO,aAAa;AAExB,UAAM,OAAQ,IAAI,OAAO,oCACpB,IAAI,MAAM,oCAAsB,oCAChC,IAAI,eAAe,yCACnB;AAEL,UAAM,iBAAa,qCAClB,CAAC,MAAM,IAAI,GACX,KAAK,mCAAqB;AAE3B,YAAQ,cAAc;AAEtB,QAAI,aAAa,MAAM,CAAC;AACxB,QAAI,aAAa,MAAM,CAAC;EACzB,OAAO;AACN,QAAI,aAAa,IAAI;AACrB,QAAI,eAAe,yBAAW,aAAa,aAAa,GAAG;A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AAaV,SAAU,iBAAiB,KAAe;AAC/C,SAAO,cAAc,GAAG,IAAI,eAAe,gBAAgB,GAAG,CAAC;AAChE;AAFgB;AAIV,SAAU,gBACf,KACA,QAAc;AAEd,QAAM,aAAa,cAAc,GAAG;AACpC,QAAM,eAAe,gBAAgB,GAAG;AACxC,SAAO;IACN;IACA,KAAK,IAAI;IACT,MAAM,IAAI;IACV,cAAc,IAAI;IAClB;IACA;IACA,aAAa,aAAa,eAAe,YAAY;;AAEvD;AAfgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BytesView } from "@zwave-js/shared";
|
|
1
2
|
import { type PageStatus, type PageWriteSize } from "./consts.js";
|
|
2
3
|
import type { NVM3Object } from "./object.js";
|
|
3
4
|
export interface NVM3PageHeader {
|
|
@@ -17,5 +18,5 @@ export interface NVM3Page {
|
|
|
17
18
|
}
|
|
18
19
|
export declare function pageSizeToBits(pageSize: number): number;
|
|
19
20
|
export declare function pageSizeFromBits(bits: number): number;
|
|
20
|
-
export declare function serializePageHeader(header: Omit<NVM3PageHeader, "offset">):
|
|
21
|
+
export declare function serializePageHeader(header: Omit<NVM3PageHeader, "offset">): BytesView;
|
|
21
22
|
//# sourceMappingURL=page.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/nvm3/page.ts"],
|
|
4
|
-
"sourcesContent": ["import { Bytes } from \"@zwave-js/shared\";\nimport {\n\tNVM3_MIN_PAGE_SIZE,\n\tNVM3_PAGE_COUNTER_MASK,\n\tNVM3_PAGE_COUNTER_SIZE,\n\tNVM3_PAGE_HEADER_SIZE,\n\tNVM3_PAGE_MAGIC,\n\ttype PageStatus,\n\ttype PageWriteSize,\n} from \"./consts.js\";\nimport type { NVM3Object } from \"./object.js\";\nimport { computeBergerCode } from \"./utils.js\";\n\nexport interface NVM3PageHeader {\n\toffset: number;\n\tversion: number;\n\teraseCount: number;\n\tstatus: PageStatus;\n\tencrypted: boolean;\n\tpageSize: number;\n\twriteSize: PageWriteSize;\n\tmemoryMapped: boolean;\n\tdeviceFamily: number;\n}\n\nexport interface NVM3Page {\n\theader: NVM3PageHeader;\n\tobjects: NVM3Object[];\n}\n\n// The page size field has a value from 0 to 7 describing page sizes from 512 to 65536 bytes\nexport function pageSizeToBits(pageSize: number): number {\n\treturn Math.ceil(Math.log2(pageSize) - Math.log2(NVM3_MIN_PAGE_SIZE));\n}\n\nexport function pageSizeFromBits(bits: number): number {\n\treturn NVM3_MIN_PAGE_SIZE * Math.pow(2, bits);\n}\n\nexport function serializePageHeader(\n\theader: Omit<NVM3PageHeader, \"offset\">,\n):
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Bytes, type BytesView } from \"@zwave-js/shared\";\nimport {\n\tNVM3_MIN_PAGE_SIZE,\n\tNVM3_PAGE_COUNTER_MASK,\n\tNVM3_PAGE_COUNTER_SIZE,\n\tNVM3_PAGE_HEADER_SIZE,\n\tNVM3_PAGE_MAGIC,\n\ttype PageStatus,\n\ttype PageWriteSize,\n} from \"./consts.js\";\nimport type { NVM3Object } from \"./object.js\";\nimport { computeBergerCode } from \"./utils.js\";\n\nexport interface NVM3PageHeader {\n\toffset: number;\n\tversion: number;\n\teraseCount: number;\n\tstatus: PageStatus;\n\tencrypted: boolean;\n\tpageSize: number;\n\twriteSize: PageWriteSize;\n\tmemoryMapped: boolean;\n\tdeviceFamily: number;\n}\n\nexport interface NVM3Page {\n\theader: NVM3PageHeader;\n\tobjects: NVM3Object[];\n}\n\n// The page size field has a value from 0 to 7 describing page sizes from 512 to 65536 bytes\nexport function pageSizeToBits(pageSize: number): number {\n\treturn Math.ceil(Math.log2(pageSize) - Math.log2(NVM3_MIN_PAGE_SIZE));\n}\n\nexport function pageSizeFromBits(bits: number): number {\n\treturn NVM3_MIN_PAGE_SIZE * Math.pow(2, bits);\n}\n\nexport function serializePageHeader(\n\theader: Omit<NVM3PageHeader, \"offset\">,\n): BytesView {\n\tconst ret = new Bytes(NVM3_PAGE_HEADER_SIZE);\n\n\tret.writeUInt16LE(header.version, 0);\n\tret.writeUInt16LE(NVM3_PAGE_MAGIC, 2);\n\n\tlet eraseCount = header.eraseCount & NVM3_PAGE_COUNTER_MASK;\n\tconst eraseCountCode = computeBergerCode(\n\t\teraseCount,\n\t\tNVM3_PAGE_COUNTER_SIZE,\n\t);\n\teraseCount |= eraseCountCode << NVM3_PAGE_COUNTER_SIZE;\n\tret.writeInt32LE(eraseCount, 4);\n\n\tlet eraseCountInv = ~header.eraseCount & NVM3_PAGE_COUNTER_MASK;\n\tconst eraseCountInvCode = computeBergerCode(\n\t\teraseCountInv,\n\t\tNVM3_PAGE_COUNTER_SIZE,\n\t);\n\teraseCountInv |= eraseCountInvCode << NVM3_PAGE_COUNTER_SIZE;\n\tret.writeInt32LE(eraseCountInv, 8);\n\n\tret.writeUInt32LE(header.status, 12);\n\n\tconst devInfo = (header.deviceFamily & 0x7ff)\n\t\t| ((header.writeSize & 0b1) << 11)\n\t\t| ((header.memoryMapped ? 1 : 0) << 12)\n\t\t| (pageSizeToBits(header.pageSize) << 13);\n\tret.writeUInt16LE(devInfo, 16);\n\n\tconst formatInfo = header.encrypted ? 0xfffe : 0xffff;\n\tret.writeUInt16LE(formatInfo, 18);\n\n\treturn ret;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAAA,oBAAsC;AACtC,oBAQO;AAEP,mBAAkC;AAoB5B,SAAU,eAAe,UAAgB;AAC9C,SAAO,KAAK,KAAK,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,gCAAkB,CAAC;AACrE;AAFgB;AAIV,SAAU,iBAAiB,MAAY;AAC5C,SAAO,mCAAqB,KAAK,IAAI,GAAG,IAAI;AAC7C;AAFgB;AAIV,SAAU,oBACf,QAAsC;AAEtC,QAAM,MAAM,IAAI,oBAAM,mCAAqB;AAE3C,MAAI,cAAc,OAAO,SAAS,CAAC;AACnC,MAAI,cAAc,+BAAiB,CAAC;AAEpC,MAAI,aAAa,OAAO,aAAa;AACrC,QAAM,qBAAiB,gCACtB,YACA,oCAAsB;AAEvB,gBAAc,kBAAkB;AAChC,MAAI,aAAa,YAAY,CAAC;AAE9B,MAAI,gBAAgB,CAAC,OAAO,aAAa;AACzC,QAAM,wBAAoB,gCACzB,eACA,oCAAsB;AAEvB,mBAAiB,qBAAqB;AACtC,MAAI,aAAa,eAAe,CAAC;AAEjC,MAAI,cAAc,OAAO,QAAQ,EAAE;AAEnC,QAAM,UAAW,OAAO,eAAe,QAClC,OAAO,YAAY,MAAQ,MAC3B,OAAO,eAAe,IAAI,MAAM,KACjC,eAAe,OAAO,QAAQ,KAAK;AACvC,MAAI,cAAc,SAAS,EAAE;AAE7B,QAAM,aAAa,OAAO,YAAY,QAAS;AAC/C,MAAI,cAAc,YAAY,EAAE;AAEhC,SAAO;AACR;AApCgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NodeProtocolInfo } from "@zwave-js/core";
|
|
2
|
-
import { Bytes } from "@zwave-js/shared";
|
|
2
|
+
import { Bytes, type BytesView } from "@zwave-js/shared";
|
|
3
3
|
import type { NVMModuleType } from "./shared.js";
|
|
4
4
|
export interface NVMDescriptor {
|
|
5
5
|
manufacturerID: number;
|
|
@@ -9,19 +9,19 @@ export interface NVMDescriptor {
|
|
|
9
9
|
firmwareVersion: string;
|
|
10
10
|
protocolVersion: string;
|
|
11
11
|
}
|
|
12
|
-
export declare function parseNVMDescriptor(data:
|
|
12
|
+
export declare function parseNVMDescriptor(data: BytesView, offset?: number): NVMDescriptor;
|
|
13
13
|
export declare function encodeNVMDescriptor(descriptor: NVMDescriptor): Bytes;
|
|
14
14
|
export interface NVMModuleDescriptor {
|
|
15
15
|
size: number;
|
|
16
16
|
type: NVMModuleType;
|
|
17
17
|
version: string;
|
|
18
18
|
}
|
|
19
|
-
export declare function parseNVMModuleDescriptor(data:
|
|
19
|
+
export declare function parseNVMModuleDescriptor(data: BytesView, offset?: number): NVMModuleDescriptor;
|
|
20
20
|
export declare function encodeNVMModuleDescriptor(descriptior: NVMModuleDescriptor): Bytes;
|
|
21
21
|
export interface NVM500NodeInfo extends Omit<NodeProtocolInfo, "hasSpecificDeviceClass"> {
|
|
22
22
|
genericDeviceClass: number;
|
|
23
23
|
specificDeviceClass: number | null;
|
|
24
24
|
}
|
|
25
|
-
export declare function parseNVM500NodeInfo(buffer:
|
|
25
|
+
export declare function parseNVM500NodeInfo(buffer: BytesView, offset: number): NVM500NodeInfo;
|
|
26
26
|
export declare function encodeNVM500NodeInfo(nodeInfo: NVM500NodeInfo): Bytes;
|
|
27
27
|
//# sourceMappingURL=EntryParsers.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/nvm500/EntryParsers.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\ttype NodeProtocolInfo,\n\tencodeNodeProtocolInfo,\n\tparseNodeProtocolInfo,\n} from \"@zwave-js/core\";\nimport { Bytes } from \"@zwave-js/shared\";\nimport type { NVMModuleType } from \"./shared.js\";\n\nexport interface NVMDescriptor {\n\tmanufacturerID: number;\n\tfirmwareID: number;\n\tproductType: number;\n\tproductID: number;\n\tfirmwareVersion: string;\n\tprotocolVersion: string;\n}\n\nexport function parseNVMDescriptor(\n\tdata:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAAA,kBAIO;AACP,
|
|
4
|
+
"sourcesContent": ["import {\n\ttype NodeProtocolInfo,\n\tencodeNodeProtocolInfo,\n\tparseNodeProtocolInfo,\n} from \"@zwave-js/core\";\nimport { Bytes, type BytesView } from \"@zwave-js/shared\";\nimport type { NVMModuleType } from \"./shared.js\";\n\nexport interface NVMDescriptor {\n\tmanufacturerID: number;\n\tfirmwareID: number;\n\tproductType: number;\n\tproductID: number;\n\tfirmwareVersion: string;\n\tprotocolVersion: string;\n}\n\nexport function parseNVMDescriptor(\n\tdata: BytesView,\n\toffset: number = 0,\n): NVMDescriptor {\n\tconst buffer = Bytes.view(data);\n\treturn {\n\t\tmanufacturerID: buffer.readUInt16BE(offset),\n\t\tfirmwareID: buffer.readUInt16BE(offset + 2),\n\t\tproductType: buffer.readUInt16BE(offset + 4),\n\t\tproductID: buffer.readUInt16BE(offset + 6),\n\t\tfirmwareVersion: `${buffer[offset + 8]}.${buffer[offset + 9]}`,\n\t\t// Z-Wave protocol versions are formatted as \"6.07\" and similar\n\t\tprotocolVersion: `${buffer[offset + 10]}.${\n\t\t\tbuffer[offset + 11].toString().padStart(\n\t\t\t\t2,\n\t\t\t\t\"0\",\n\t\t\t)\n\t\t}`,\n\t};\n}\n\nexport function encodeNVMDescriptor(descriptor: NVMDescriptor): Bytes {\n\tconst ret = new Bytes(12);\n\tret.writeUInt16BE(descriptor.manufacturerID, 0);\n\tret.writeUInt16BE(descriptor.firmwareID, 2);\n\tret.writeUInt16BE(descriptor.productType, 4);\n\tret.writeUInt16BE(descriptor.productID, 6);\n\tconst fwVersionParts = descriptor.firmwareVersion\n\t\t.split(\".\")\n\t\t.map((i) => parseInt(i));\n\tret[8] = fwVersionParts[0];\n\tret[9] = fwVersionParts[1];\n\tconst protocolVersionParts = descriptor.protocolVersion\n\t\t.split(\".\")\n\t\t.map((i) => parseInt(i));\n\tret[10] = protocolVersionParts[0];\n\tret[11] = protocolVersionParts[1];\n\treturn ret;\n}\n\nexport interface NVMModuleDescriptor {\n\tsize: number;\n\ttype: NVMModuleType;\n\tversion: string;\n}\n\nexport function parseNVMModuleDescriptor(\n\tdata: BytesView,\n\toffset: number = 0,\n): NVMModuleDescriptor {\n\tconst buffer = Bytes.view(data);\n\treturn {\n\t\tsize: buffer.readUInt16BE(offset),\n\t\ttype: buffer[offset + 2],\n\t\tversion: `${buffer[offset + 3]}.${buffer[offset + 4]}`,\n\t};\n}\n\nexport function encodeNVMModuleDescriptor(\n\tdescriptior: NVMModuleDescriptor,\n): Bytes {\n\tconst ret = new Bytes(5);\n\tret.writeUInt16BE(descriptior.size, 0);\n\tret[2] = descriptior.type;\n\tconst versionParts = descriptior.version.split(\".\").map((i) => parseInt(i));\n\tret[3] = versionParts[0];\n\tret[4] = versionParts[1];\n\treturn ret;\n}\n\nexport interface NVM500NodeInfo\n\textends Omit<NodeProtocolInfo, \"hasSpecificDeviceClass\">\n{\n\tgenericDeviceClass: number;\n\tspecificDeviceClass: number | null;\n}\n\nexport function parseNVM500NodeInfo(\n\tbuffer: BytesView,\n\toffset: number,\n): NVM500NodeInfo {\n\tconst { hasSpecificDeviceClass, ...protocolInfo } = parseNodeProtocolInfo(\n\t\tbuffer,\n\t\toffset,\n\t);\n\tconst genericDeviceClass = buffer[offset + 3];\n\tconst specificDeviceClass = hasSpecificDeviceClass\n\t\t? buffer[offset + 4]\n\t\t: null;\n\treturn {\n\t\t...protocolInfo,\n\t\tgenericDeviceClass,\n\t\tspecificDeviceClass,\n\t};\n}\n\nexport function encodeNVM500NodeInfo(nodeInfo: NVM500NodeInfo): Bytes {\n\treturn Bytes.concat([\n\t\tencodeNodeProtocolInfo({\n\t\t\t...nodeInfo,\n\t\t\thasSpecificDeviceClass: !!nodeInfo.specificDeviceClass,\n\t\t}),\n\t\tBytes.from([\n\t\t\tnodeInfo.genericDeviceClass,\n\t\t\tnodeInfo.specificDeviceClass ?? 0,\n\t\t]),\n\t]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAAA,kBAIO;AACP,oBAAsC;AAYhC,SAAU,mBACf,MACA,SAAiB,GAAC;AAElB,QAAM,SAAS,oBAAM,KAAK,IAAI;AAC9B,SAAO;IACN,gBAAgB,OAAO,aAAa,MAAM;IAC1C,YAAY,OAAO,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,QAAM,eAAe,YAAY,QAAQ,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,SAAS,CAAC,CAAC;AAC1E,MAAI,CAAC,IAAI,aAAa,CAAC;AACvB,MAAI,CAAC,IAAI,aAAa,CAAC;AACvB,SAAO;AACR;AAVgB;AAmBV,SAAU,oBACf,QACA,QAAc;AAEd,QAAM,EAAE,wBAAwB,GAAG,aAAY,QAAK,mCACnD,QACA,MAAM;AAEP,QAAM,qBAAqB,OAAO,SAAS,CAAC;AAC5C,QAAM,sBAAsB,yBACzB,OAAO,SAAS,CAAC,IACjB;AACH,SAAO;IACN,GAAG;IACH;IACA;;AAEF;AAjBgB;AAmBV,SAAU,qBAAqB,UAAwB;AAC5D,SAAO,oBAAM,OAAO;QACnB,oCAAuB;MACtB,GAAG;MACH,wBAAwB,CAAC,CAAC,SAAS;KACnC;IACD,oBAAM,KAAK;MACV,SAAS;MACT,SAAS,uBAAuB;KAChC;GACD;AACF;AAXgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -253,7 +253,7 @@ class NVM500Adapter {
|
|
|
253
253
|
return this.setOnly("NVM_SYSTEM_STATE", value);
|
|
254
254
|
case "commandClasses": {
|
|
255
255
|
await this.setOnly("EEOFFSET_CMDCLASS_LEN_far", value.length);
|
|
256
|
-
const CCs =
|
|
256
|
+
const CCs = Array.from({ length: import_shared2.APPL_NODEPARM_MAX }).fill(255);
|
|
257
257
|
for (let i = 0; i < value.length; i++) {
|
|
258
258
|
if (i < import_shared2.APPL_NODEPARM_MAX) {
|
|
259
259
|
CCs[i] = value[i];
|
|
@@ -283,7 +283,9 @@ class NVM500Adapter {
|
|
|
283
283
|
}
|
|
284
284
|
case "sucUpdateEntries": {
|
|
285
285
|
const entries = value;
|
|
286
|
-
const sucUpdateEntries =
|
|
286
|
+
const sucUpdateEntries = Array.from({
|
|
287
|
+
length: import_consts.SUC_MAX_UPDATES
|
|
288
|
+
}).fill(void 0);
|
|
287
289
|
for (let i = 0; i < entries.length; i++) {
|
|
288
290
|
if (i < import_consts.SUC_MAX_UPDATES) {
|
|
289
291
|
sucUpdateEntries[i] = entries[i];
|