@zwave-js/nvmedit 15.16.0 → 15.18.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/lib/NVM500.js +1 -1
- package/build/cjs/lib/NVM500.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.js +1 -1
- package/build/cjs/lib/nvm3/files/ControllerInfoFile.js.map +1 -1
- package/build/cjs/lib/nvm3/files/NodeInfoFiles.js +3 -3
- package/build/cjs/lib/nvm3/files/NodeInfoFiles.js.map +1 -1
- 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/nvm500/adapter.js +4 -2
- package/build/cjs/lib/nvm500/adapter.js.map +2 -2
- package/build/esm/lib/NVM500.js +1 -1
- package/build/esm/lib/NVM500.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.js +1 -1
- package/build/esm/lib/nvm3/files/ControllerInfoFile.js.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/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/package.json +5 -7
package/build/cjs/lib/NVM500.js
CHANGED
|
@@ -322,7 +322,7 @@ class NVM500 {
|
|
|
322
322
|
data.push(new Uint8Array(size).fill(value));
|
|
323
323
|
break;
|
|
324
324
|
case import_shared2.NVMEntryType.NodeMask:
|
|
325
|
-
data.push(
|
|
325
|
+
data.push(Array.from({ length: size }).fill(value));
|
|
326
326
|
break;
|
|
327
327
|
case import_shared2.NVMEntryType.NodeInfo:
|
|
328
328
|
case import_shared2.NVMEntryType.Route:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/NVM500.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tMAX_NODES,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tparseBitMask,\n} from \"@zwave-js/core\";\nimport { Bytes, type BytesView } from \"@zwave-js/shared\";\nimport { type NVM, NVMAccess, type NVMIO } from \"./common/definitions.js\";\nimport { type Route, encodeRoute, parseRoute } from \"./common/routeCache.js\";\nimport {\n\ttype SUCUpdateEntry,\n\tencodeSUCUpdateEntry,\n\tparseSUCUpdateEntry,\n} from \"./common/sucUpdateEntry.js\";\nimport {\n\tnvmReadBuffer,\n\tnvmReadUInt16BE,\n\tnvmWriteBuffer,\n} from \"./common/utils.js\";\nimport {\n\ttype NVM500NodeInfo,\n\ttype NVMDescriptor,\n\ttype NVMModuleDescriptor,\n\tencodeNVM500NodeInfo,\n\tencodeNVMDescriptor,\n\tencodeNVMModuleDescriptor,\n\tparseNVM500NodeInfo,\n\tparseNVMDescriptor,\n\tparseNVMModuleDescriptor,\n} from \"./nvm500/EntryParsers.js\";\nimport { nvm500Impls } from \"./nvm500/impls/index.js\";\nimport {\n\tCONFIGURATION_VALID_0,\n\tCONFIGURATION_VALID_1,\n\tMAGIC_VALUE,\n\ttype NVM500Impl,\n\ttype NVMData,\n\ttype NVMEntryName,\n\tNVMEntrySizes,\n\tNVMEntryType,\n\tNVMModuleType,\n\tROUTECACHE_VALID,\n\ttype ResolvedNVMEntry,\n\ttype ResolvedNVMLayout,\n} from \"./nvm500/shared.js\";\n\nexport interface NVM500Info {\n\tlayout: ResolvedNVMLayout;\n\tlibrary: NVM500Impl[\"library\"];\n\tmoduleDescriptors: Map<NVMEntryName, NVMModuleDescriptor>;\n\tnvmDescriptor: NVMDescriptor;\n}\n\nexport type NVM500EraseOptions = {\n\tlayout: ResolvedNVMLayout;\n\tnvmSize: number;\n\tlibrary: NVM500Impl[\"library\"];\n\tnvmDescriptor: NVMDescriptor;\n};\n\nexport class NVM500 implements NVM<NVMEntryName, NVMData[]> {\n\tpublic constructor(io: NVMIO) {\n\t\tthis._io = io;\n\t}\n\n\tprivate _io: NVMIO;\n\tprivate _access: NVMAccess = NVMAccess.None;\n\n\tprivate _info: NVM500Info | undefined;\n\tpublic get info(): NVM500Info | undefined {\n\t\treturn this._info;\n\t}\n\n\tprivate async ensureReadable(): Promise<void> {\n\t\tif (\n\t\t\tthis._access === NVMAccess.Read\n\t\t\t|| this._access === NVMAccess.ReadWrite\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._access === NVMAccess.Write) {\n\t\t\tawait this._io.close();\n\t\t}\n\t\tthis._access = await this._io.open(NVMAccess.Read);\n\t}\n\n\tprivate async ensureWritable(): Promise<void> {\n\t\tif (\n\t\t\tthis._access === NVMAccess.Write\n\t\t\t|| this._access === NVMAccess.ReadWrite\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._access === NVMAccess.Read) {\n\t\t\tawait this._io.close();\n\t\t}\n\t\tthis._access = await this._io.open(NVMAccess.Write);\n\t}\n\n\tpublic async init(): Promise<NVM500Info> {\n\t\tawait this.ensureReadable();\n\n\t\t// Try the different known layouts to find one that works\n\t\tfor (const impl of nvm500Impls) {\n\t\t\ttry {\n\t\t\t\tconst info = await this.resolveLayout(impl);\n\t\t\t\tif (await this.isLayoutValid(info, impl.protocolVersions)) {\n\t\t\t\t\tthis._info = info;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (!this._info) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"Did not find a matching NVM 500 parser implementation! Make sure that the NVM data belongs to a controller with Z-Wave SDK 6.61 or higher.\",\n\t\t\t\tZWaveErrorCodes.NVM_NotSupported,\n\t\t\t);\n\t\t}\n\n\t\treturn this._info;\n\t}\n\n\tprivate async resolveLayout(impl: NVM500Impl): Promise<NVM500Info> {\n\t\tconst resolvedLayout = new Map<NVMEntryName, ResolvedNVMEntry>();\n\t\tlet nvmDescriptor: NVMDescriptor | undefined;\n\t\tconst moduleDescriptors = new Map<NVMEntryName, NVMModuleDescriptor>();\n\n\t\tlet offset = 0;\n\t\tlet moduleStart = -1;\n\t\tlet moduleSize = -1;\n\t\tconst nvmEnd = await nvmReadUInt16BE(this._io, 0);\n\n\t\tfor (const entry of impl.layout) {\n\t\t\tconst size = entry.size ?? NVMEntrySizes[entry.type];\n\n\t\t\tif (entry.type === NVMEntryType.NVMModuleSize) {\n\t\t\t\tif (moduleStart !== -1) {\n\t\t\t\t\t// All following NVM modules must start at the last module's end\n\t\t\t\t\toffset = moduleStart + moduleSize;\n\t\t\t\t}\n\n\t\t\t\tmoduleStart = offset;\n\t\t\t\tmoduleSize = await nvmReadUInt16BE(this._io, offset);\n\t\t\t} else if (entry.type === NVMEntryType.NVMModuleDescriptor) {\n\t\t\t\t// The module descriptor is always at the end of the module\n\t\t\t\toffset = moduleStart + moduleSize - size;\n\t\t\t}\n\n\t\t\tif (entry.offset != undefined && entry.offset !== offset) {\n\t\t\t\t// The entry has a defined offset but is at the wrong location\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`${entry.name} is at wrong location in NVM buffer!`,\n\t\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst resolvedEntry: ResolvedNVMEntry = {\n\t\t\t\t...entry,\n\t\t\t\toffset,\n\t\t\t\tsize,\n\t\t\t};\n\n\t\t\tif (entry.type === NVMEntryType.NVMDescriptor) {\n\t\t\t\tconst entryData = await this.readRawEntry(resolvedEntry);\n\t\t\t\t// NVMDescriptor is always a single entry\n\t\t\t\tnvmDescriptor = parseNVMDescriptor(entryData[0]);\n\t\t\t} else if (entry.type === NVMEntryType.NVMModuleDescriptor) {\n\t\t\t\tconst entryData = await this.readRawEntry(resolvedEntry);\n\t\t\t\t// NVMModuleDescriptor is always a single entry\n\t\t\t\tconst descriptor = parseNVMModuleDescriptor(\n\t\t\t\t\tentryData[0],\n\t\t\t\t);\n\t\t\t\tif (descriptor.size !== moduleSize) {\n\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\"NVM module descriptor size does not match module size!\",\n\t\t\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tmoduleDescriptors.set(entry.name, descriptor);\n\t\t\t}\n\n\t\t\tresolvedLayout.set(entry.name, resolvedEntry);\n\n\t\t\t// Skip forward\n\t\t\toffset += size * entry.count;\n\t\t\tif (offset >= nvmEnd) break;\n\t\t}\n\n\t\tif (!nvmDescriptor) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"NVM descriptor not found in NVM!\",\n\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tlayout: resolvedLayout,\n\t\t\tlibrary: impl.library,\n\t\t\tmoduleDescriptors,\n\t\t\tnvmDescriptor,\n\t\t};\n\t}\n\n\tprivate async isLayoutValid(\n\t\tinfo: NVM500Info,\n\t\tprotocolVersions: string[],\n\t): Promise<boolean> {\n\t\t// Checking if an NVM is valid requires checking multiple bytes at different locations\n\t\tconst eeoffset_magic_entry = info.layout.get(\"EEOFFSET_MAGIC_far\");\n\t\tif (!eeoffset_magic_entry) return false;\n\t\tconst eeoffset_magic =\n\t\t\t(await this.readEntry(eeoffset_magic_entry))[0] as number;\n\n\t\tconst configuration_valid_0_entry = info.layout.get(\n\t\t\t\"NVM_CONFIGURATION_VALID_far\",\n\t\t);\n\t\tif (!configuration_valid_0_entry) return false;\n\t\tconst configuration_valid_0 =\n\t\t\t(await this.readEntry(configuration_valid_0_entry))[0] as number;\n\n\t\tconst configuration_valid_1_entry = info.layout.get(\n\t\t\t\"NVM_CONFIGURATION_REALLYVALID_far\",\n\t\t);\n\t\tif (!configuration_valid_1_entry) return false;\n\t\tconst configuration_valid_1 =\n\t\t\t(await this.readEntry(configuration_valid_1_entry))[0] as number;\n\n\t\tconst routecache_valid_entry = info.layout.get(\n\t\t\t\"EX_NVM_ROUTECACHE_MAGIC_far\",\n\t\t);\n\t\tif (!routecache_valid_entry) return false;\n\t\tconst routecache_valid =\n\t\t\t(await this.readEntry(routecache_valid_entry))[0] as number;\n\n\t\tconst endMarker_entry = info.layout.get(\"nvmModuleSizeEndMarker\");\n\t\tif (!endMarker_entry) return false;\n\t\tconst endMarker = (await this.readEntry(endMarker_entry))[0] as number;\n\n\t\treturn (\n\t\t\teeoffset_magic === MAGIC_VALUE\n\t\t\t&& configuration_valid_0 === CONFIGURATION_VALID_0\n\t\t\t&& configuration_valid_1 === CONFIGURATION_VALID_1\n\t\t\t&& routecache_valid === ROUTECACHE_VALID\n\t\t\t&& protocolVersions.includes(info.nvmDescriptor.protocolVersion)\n\t\t\t&& endMarker === 0\n\t\t);\n\t}\n\n\tasync has(property: NVMEntryName): Promise<boolean> {\n\t\tthis._info ??= await this.init();\n\t\treturn this._info.layout.has(property);\n\t}\n\n\tprivate async readSingleRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t): Promise<BytesView> {\n\t\tif (index >= entry.count) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Index out of range. Tried to read entry ${index} of ${entry.count}.`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\treturn nvmReadBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset + index * entry.size,\n\t\t\tentry.size,\n\t\t);\n\t}\n\n\tprivate async readRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t): Promise<BytesView[]> {\n\t\tconst ret: BytesView[] = [];\n\t\tconst nvmData = await nvmReadBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset,\n\t\t\tentry.count * entry.size,\n\t\t);\n\t\tfor (let i = 0; i < entry.count; i++) {\n\t\t\tret.push(\n\t\t\t\tnvmData.subarray(i * entry.size, (i + 1) * entry.size),\n\t\t\t);\n\t\t}\n\t\treturn ret;\n\t}\n\n\tprivate parseEntry(type: NVMEntryType, data: Bytes): NVMData {\n\t\tswitch (type) {\n\t\t\tcase NVMEntryType.Byte:\n\t\t\t\treturn data.readUInt8(0);\n\t\t\tcase NVMEntryType.Word:\n\t\t\tcase NVMEntryType.NVMModuleSize:\n\t\t\t\treturn data.readUInt16BE(0);\n\t\t\tcase NVMEntryType.DWord:\n\t\t\t\treturn data.readUInt32BE(0);\n\t\t\tcase NVMEntryType.NodeInfo:\n\t\t\t\tif (data.every((byte) => byte === 0)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn parseNVM500NodeInfo(data, 0);\n\t\t\tcase NVMEntryType.NodeMask:\n\t\t\t\treturn parseBitMask(data);\n\t\t\tcase NVMEntryType.SUCUpdateEntry:\n\t\t\t\tif (data.every((byte) => byte === 0)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn parseSUCUpdateEntry(data, 0);\n\t\t\tcase NVMEntryType.Route:\n\t\t\t\tif (data.every((byte) => byte === 0)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn parseRoute(data, 0);\n\t\t\tcase NVMEntryType.NVMModuleDescriptor: {\n\t\t\t\treturn parseNVMModuleDescriptor(data);\n\t\t\t}\n\t\t\tcase NVMEntryType.NVMDescriptor:\n\t\t\t\treturn parseNVMDescriptor(data);\n\t\t\tdefault:\n\t\t\t\t// This includes NVMEntryType.BUFFER\n\t\t\t\treturn data;\n\t\t}\n\t}\n\n\tprivate async readEntry(\n\t\tentry: ResolvedNVMEntry,\n\t): Promise<NVMData[]> {\n\t\tconst data: BytesView[] = await this.readRawEntry(entry);\n\t\treturn data.map((buffer) =>\n\t\t\tthis.parseEntry(entry.type, Bytes.view(buffer))\n\t\t);\n\t}\n\n\tprivate async readSingleEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t): Promise<NVMData> {\n\t\tconst data = await this.readSingleRawEntry(entry, index);\n\t\treturn this.parseEntry(entry.type, Bytes.view(data));\n\t}\n\n\tpublic async get(property: NVMEntryName): Promise<NVMData[] | undefined> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureReadable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return undefined;\n\n\t\treturn this.readEntry(entry);\n\t}\n\n\tpublic async getSingle(\n\t\tproperty: NVMEntryName,\n\t\tindex: number,\n\t): Promise<NVMData | undefined> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureReadable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return undefined;\n\n\t\treturn this.readSingleEntry(entry, index);\n\t}\n\n\tprivate encodeEntry(\n\t\ttype: NVMEntryType,\n\t\tdata: NVMData,\n\t\tentrySize?: number,\n\t): Bytes {\n\t\tconst size = entrySize ?? NVMEntrySizes[type];\n\n\t\tswitch (type) {\n\t\t\tcase NVMEntryType.Byte:\n\t\t\t\treturn Bytes.from([data as number]);\n\t\t\tcase NVMEntryType.Word:\n\t\t\tcase NVMEntryType.NVMModuleSize: {\n\t\t\t\tconst ret = new Bytes(2);\n\t\t\t\tret.writeUInt16BE(data as number, 0);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase NVMEntryType.DWord: {\n\t\t\t\tconst ret = new Bytes(4);\n\t\t\t\tret.writeUInt32BE(data as number, 0);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase NVMEntryType.NodeInfo:\n\t\t\t\treturn data\n\t\t\t\t\t? encodeNVM500NodeInfo(data as NVM500NodeInfo)\n\t\t\t\t\t: new Bytes(size).fill(0);\n\t\t\tcase NVMEntryType.NodeMask: {\n\t\t\t\tconst ret = new Bytes(size).fill(0);\n\t\t\t\tif (data) {\n\t\t\t\t\tret.set(encodeBitMask(data as number[], MAX_NODES, 1), 0);\n\t\t\t\t}\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase NVMEntryType.SUCUpdateEntry:\n\t\t\t\treturn encodeSUCUpdateEntry(data as SUCUpdateEntry);\n\t\t\tcase NVMEntryType.Route:\n\t\t\t\treturn encodeRoute(data as Route);\n\t\t\tcase NVMEntryType.NVMModuleDescriptor:\n\t\t\t\treturn encodeNVMModuleDescriptor(\n\t\t\t\t\tdata as NVMModuleDescriptor,\n\t\t\t\t);\n\t\t\tcase NVMEntryType.NVMDescriptor:\n\t\t\t\treturn encodeNVMDescriptor(data as NVMDescriptor);\n\t\t\tcase NVMEntryType.Buffer:\n\t\t\t\treturn data as Bytes;\n\t\t}\n\t}\n\n\tprivate async writeSingleRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t\tdata: BytesView,\n\t): Promise<void> {\n\t\tif (index >= entry.count) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Index out of range. Tried to write entry ${index} of ${entry.count}.`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\treturn nvmWriteBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset + index * entry.size,\n\t\t\tdata,\n\t\t);\n\t}\n\n\tprivate async writeRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tdata: BytesView[],\n\t): Promise<void> {\n\t\tawait nvmWriteBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset,\n\t\t\tBytes.concat(data),\n\t\t);\n\t}\n\n\tprivate async writeEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tdata: NVMData[],\n\t): Promise<void> {\n\t\tconst buffers = data.map((d) =>\n\t\t\tthis.encodeEntry(entry.type, d, entry.size)\n\t\t);\n\t\tawait this.writeRawEntry(entry, buffers);\n\t}\n\n\tprivate async writeSingleEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t\tdata: NVMData,\n\t): Promise<void> {\n\t\tconst buffer = this.encodeEntry(entry.type, data, entry.size);\n\t\tawait this.writeSingleRawEntry(entry, index, buffer);\n\t}\n\n\tpublic async set(property: NVMEntryName, value: NVMData[]): Promise<void> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureWritable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return;\n\n\t\tawait this.writeEntry(entry, value);\n\t}\n\n\tpublic async setSingle(\n\t\tproperty: NVMEntryName,\n\t\tindex: number,\n\t\tvalue: NVMData,\n\t): Promise<void> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureWritable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return undefined;\n\n\t\tawait this.writeSingleEntry(entry, index, value);\n\t}\n\n\tprivate async fill(key: NVMEntryName, value: number) {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureWritable();\n\n\t\tconst entry = this._info.layout.get(key);\n\t\t// Skip entries not present in this layout\n\t\tif (!entry) return;\n\n\t\tconst size = entry.size ?? NVMEntrySizes[entry.type];\n\n\t\tconst data: NVMData[] = [];\n\t\tfor (let i = 1; i <= entry.count; i++) {\n\t\t\tswitch (entry.type) {\n\t\t\t\tcase NVMEntryType.Byte:\n\t\t\t\tcase NVMEntryType.Word:\n\t\t\t\tcase NVMEntryType.DWord:\n\t\t\t\t\tdata.push(value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase NVMEntryType.Buffer:\n\t\t\t\t\tdata.push(new Uint8Array(size).fill(value));\n\t\t\t\t\tbreak;\n\t\t\t\tcase NVMEntryType.NodeMask:\n\t\t\t\t\tdata.push(new Array(size).fill(value));\n\t\t\t\t\tbreak;\n\t\t\t\tcase NVMEntryType.NodeInfo:\n\t\t\t\tcase NVMEntryType.Route:\n\t\t\t\t\tdata.push(undefined);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Cannot fill entry of type ${NVMEntryType[entry.type]}`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tawait this.writeEntry(entry, data);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tpublic async delete(_property: NVMEntryName): Promise<void> {\n\t\tthrow new Error(\n\t\t\t\"Deleting entries is not supported for 500 series NVMs\",\n\t\t);\n\t}\n\n\tpublic async erase(\n\t\toptions: NVM500EraseOptions,\n\t): Promise<void> {\n\t\t// Blank NVM with 0xff\n\t\tawait nvmWriteBuffer(\n\t\t\tthis._io,\n\t\t\t0,\n\t\t\tnew Uint8Array(options.nvmSize).fill(0xff),\n\t\t);\n\n\t\t// Compute module sizes\n\t\tconst layoutEntries = Array.from(options.layout.values());\n\t\tconst moduleSizeEntries = layoutEntries\n\t\t\t.filter((entry) => entry.type === NVMEntryType.NVMModuleSize);\n\t\tconst moduleDescriptorEntries = layoutEntries\n\t\t\t.filter((entry) => entry.type === NVMEntryType.NVMModuleDescriptor);\n\t\tconst moduleDescriptors = new Map<NVMEntryName, NVMModuleDescriptor>();\n\t\t// Each module starts with a size marker and ends with a descriptor\n\t\tfor (let i = 0; i < moduleSizeEntries.length; i++) {\n\t\t\tconst sizeEntry = moduleSizeEntries[i];\n\t\t\tconst descriptorEntry = moduleDescriptorEntries[i];\n\t\t\tconst size = descriptorEntry.offset\n\t\t\t\t+ descriptorEntry.size\n\t\t\t\t- sizeEntry.offset;\n\n\t\t\t// Write each module size to their NVMModuleSize marker\n\t\t\tawait this.writeEntry(sizeEntry, [size]);\n\n\t\t\t// Write each module size, type and version to the NVMModuleDescriptor at the end\n\t\t\tconst moduleType = descriptorEntry.name === \"nvmZWlibraryDescriptor\"\n\t\t\t\t? NVMModuleType.ZW_LIBRARY\n\t\t\t\t: descriptorEntry.name === \"nvmApplicationDescriptor\"\n\t\t\t\t? NVMModuleType.APPLICATION\n\t\t\t\t: descriptorEntry.name === \"nvmHostApplicationDescriptor\"\n\t\t\t\t? NVMModuleType.HOST_APPLICATION\n\t\t\t\t: descriptorEntry.name === \"nvmDescriptorDescriptor\"\n\t\t\t\t? NVMModuleType.NVM_DESCRIPTOR\n\t\t\t\t: 0;\n\n\t\t\tconst moduleDescriptor: NVMModuleDescriptor = {\n\t\t\t\tsize,\n\t\t\t\ttype: moduleType,\n\t\t\t\tversion: descriptorEntry.name === \"nvmZWlibraryDescriptor\"\n\t\t\t\t\t? options.nvmDescriptor.protocolVersion\n\t\t\t\t\t: options.nvmDescriptor.firmwareVersion,\n\t\t\t};\n\t\t\tmoduleDescriptors.set(descriptorEntry.name, moduleDescriptor);\n\t\t\tawait this.writeEntry(descriptorEntry, [moduleDescriptor]);\n\t\t}\n\n\t\t// Initialize this._info, so the following works\n\t\tthis._info = {\n\t\t\t...options,\n\t\t\tmoduleDescriptors,\n\t\t};\n\n\t\t// Write NVM size to nvmTotalEnd\n\t\t// the value points to the last byte, therefore subtract 1\n\t\tawait this.set(\"nvmTotalEnd\", [options.nvmSize - 1]);\n\n\t\t// Set some entries that are always identical\n\t\tawait this.set(\"NVM_CONFIGURATION_VALID_far\", [CONFIGURATION_VALID_0]);\n\t\tawait this.set(\"NVM_CONFIGURATION_REALLYVALID_far\", [\n\t\t\tCONFIGURATION_VALID_1,\n\t\t]);\n\t\tawait this.set(\"EEOFFSET_MAGIC_far\", [MAGIC_VALUE]);\n\t\tawait this.set(\"EX_NVM_ROUTECACHE_MAGIC_far\", [ROUTECACHE_VALID]);\n\t\tawait this.set(\"nvmModuleSizeEndMarker\", [0]);\n\n\t\t// Set NVM descriptor\n\t\tawait this.set(\"nvmDescriptor\", [options.nvmDescriptor]);\n\n\t\t// Set dummy entries we're never going to fill\n\t\tawait this.fill(\"NVM_INTERNAL_RESERVED_1_far\", 0);\n\t\tawait this.fill(\"NVM_INTERNAL_RESERVED_2_far\", 0xff);\n\t\tawait this.fill(\"NVM_INTERNAL_RESERVED_3_far\", 0);\n\t\tawait this.fill(\"NVM_RTC_TIMERS_far\", 0);\n\t\tawait this.fill(\"EX_NVM_SUC_ACTIVE_START_far\", 0);\n\t\tawait this.fill(\"EX_NVM_ZENSOR_TABLE_START_far\", 0);\n\t\tawait this.fill(\"NVM_SECURITY0_KEY_far\", 0);\n\n\t\t// And blank fields that are not supposed to be filled with 0xff\n\t\tawait this.fill(\"EX_NVM_SUC_CONTROLLER_LIST_START_far\", 0xfe);\n\t\tawait this.fill(\"EX_NVM_NODE_TABLE_START_far\", 0);\n\t\tawait this.fill(\"EX_NVM_ROUTING_TABLE_START_far\", 0);\n\t\t// For routes the value does not matter\n\t\tawait this.fill(\"EX_NVM_ROUTECACHE_START_far\", 0);\n\t\tawait this.fill(\"EX_NVM_ROUTECACHE_NLWR_SR_START_far\", 0);\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,kBAMO;AACP,oBAAsC;AACtC,yBAAgD;AAChD,wBAAoD;AACpD,4BAIO;AACP,mBAIO;AACP,0BAUO;AACP,mBAA4B;AAC5B,IAAAA,iBAaO;AAgBD,MAAO,OAAM;EA7DnB,OA6DmB;;;EAClB,YAAmB,IAAS;AAC3B,SAAK,MAAM;EACZ;EAEQ;EACA,UAAqB,6BAAU;EAE/B;EACR,IAAW,OAAI;AACd,WAAO,KAAK;EACb;EAEQ,MAAM,iBAAc;AAC3B,QACC,KAAK,YAAY,6BAAU,QACxB,KAAK,YAAY,6BAAU,WAC7B;AACD;IACD;AACA,QAAI,KAAK,YAAY,6BAAU,OAAO;AACrC,YAAM,KAAK,IAAI,MAAK;IACrB;AACA,SAAK,UAAU,MAAM,KAAK,IAAI,KAAK,6BAAU,IAAI;EAClD;EAEQ,MAAM,iBAAc;AAC3B,QACC,KAAK,YAAY,6BAAU,SACxB,KAAK,YAAY,6BAAU,WAC7B;AACD;IACD;AACA,QAAI,KAAK,YAAY,6BAAU,MAAM;AACpC,YAAM,KAAK,IAAI,MAAK;IACrB;AACA,SAAK,UAAU,MAAM,KAAK,IAAI,KAAK,6BAAU,KAAK;EACnD;EAEO,MAAM,OAAI;AAChB,UAAM,KAAK,eAAc;AAGzB,eAAW,QAAQ,0BAAa;AAC/B,UAAI;AACH,cAAM,OAAO,MAAM,KAAK,cAAc,IAAI;AAC1C,YAAI,MAAM,KAAK,cAAc,MAAM,KAAK,gBAAgB,GA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WAAW,OAAO,KAAK;EACnC;EAEO,MAAM,UACZ,UACA,OACA,OAAc;AAEd,SAAK,UAAU,MAAM,KAAK,KAAI;AAC9B,UAAM,KAAK,eAAc;AAEzB,UAAM,QAAQ,KAAK,MAAM,OAAO,IAAI,QAAQ;AAC5C,QAAI,CAAC;AAAO,aAAO;AAEnB,UAAM,KAAK,iBAAiB,OAAO,OAAO,KAAK;EAChD;EAEQ,MAAM,KAAK,KAAmB,OAAa;AAClD,SAAK,UAAU,MAAM,KAAK,KAAI;AAC9B,UAAM,KAAK,eAAc;AAEzB,UAAM,QAAQ,KAAK,MAAM,OAAO,IAAI,GAAG;AAEvC,QAAI,CAAC;AAAO;AAEZ,UAAM,OAAO,MAAM,QAAQ,6BAAc,MAAM,IAAI;AAEnD,UAAM,OAAkB,CAAA;AACxB,aAAS,IAAI,GAAG,KAAK,MAAM,OAAO,KAAK;AACtC,cAAQ,MAAM,MAAM;QACnB,KAAK,4BAAa;QAClB,KAAK,4BAAa;QAClB,KAAK,4BAAa;AACjB,eAAK,KAAK,KAAK;AACf;QACD,KAAK,4BAAa;AACjB,eAAK,KAAK,IAAI,WAAW,IAAI,EAAE,KAAK,KAAK,CAAC;AAC1C;QACD,KAAK,4BAAa;AACjB,eAAK,KAAK,
|
|
4
|
+
"sourcesContent": ["import {\n\tMAX_NODES,\n\tZWaveError,\n\tZWaveErrorCodes,\n\tencodeBitMask,\n\tparseBitMask,\n} from \"@zwave-js/core\";\nimport { Bytes, type BytesView } from \"@zwave-js/shared\";\nimport { type NVM, NVMAccess, type NVMIO } from \"./common/definitions.js\";\nimport { type Route, encodeRoute, parseRoute } from \"./common/routeCache.js\";\nimport {\n\ttype SUCUpdateEntry,\n\tencodeSUCUpdateEntry,\n\tparseSUCUpdateEntry,\n} from \"./common/sucUpdateEntry.js\";\nimport {\n\tnvmReadBuffer,\n\tnvmReadUInt16BE,\n\tnvmWriteBuffer,\n} from \"./common/utils.js\";\nimport {\n\ttype NVM500NodeInfo,\n\ttype NVMDescriptor,\n\ttype NVMModuleDescriptor,\n\tencodeNVM500NodeInfo,\n\tencodeNVMDescriptor,\n\tencodeNVMModuleDescriptor,\n\tparseNVM500NodeInfo,\n\tparseNVMDescriptor,\n\tparseNVMModuleDescriptor,\n} from \"./nvm500/EntryParsers.js\";\nimport { nvm500Impls } from \"./nvm500/impls/index.js\";\nimport {\n\tCONFIGURATION_VALID_0,\n\tCONFIGURATION_VALID_1,\n\tMAGIC_VALUE,\n\ttype NVM500Impl,\n\ttype NVMData,\n\ttype NVMEntryName,\n\tNVMEntrySizes,\n\tNVMEntryType,\n\tNVMModuleType,\n\tROUTECACHE_VALID,\n\ttype ResolvedNVMEntry,\n\ttype ResolvedNVMLayout,\n} from \"./nvm500/shared.js\";\n\nexport interface NVM500Info {\n\tlayout: ResolvedNVMLayout;\n\tlibrary: NVM500Impl[\"library\"];\n\tmoduleDescriptors: Map<NVMEntryName, NVMModuleDescriptor>;\n\tnvmDescriptor: NVMDescriptor;\n}\n\nexport type NVM500EraseOptions = {\n\tlayout: ResolvedNVMLayout;\n\tnvmSize: number;\n\tlibrary: NVM500Impl[\"library\"];\n\tnvmDescriptor: NVMDescriptor;\n};\n\nexport class NVM500 implements NVM<NVMEntryName, NVMData[]> {\n\tpublic constructor(io: NVMIO) {\n\t\tthis._io = io;\n\t}\n\n\tprivate _io: NVMIO;\n\tprivate _access: NVMAccess = NVMAccess.None;\n\n\tprivate _info: NVM500Info | undefined;\n\tpublic get info(): NVM500Info | undefined {\n\t\treturn this._info;\n\t}\n\n\tprivate async ensureReadable(): Promise<void> {\n\t\tif (\n\t\t\tthis._access === NVMAccess.Read\n\t\t\t|| this._access === NVMAccess.ReadWrite\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._access === NVMAccess.Write) {\n\t\t\tawait this._io.close();\n\t\t}\n\t\tthis._access = await this._io.open(NVMAccess.Read);\n\t}\n\n\tprivate async ensureWritable(): Promise<void> {\n\t\tif (\n\t\t\tthis._access === NVMAccess.Write\n\t\t\t|| this._access === NVMAccess.ReadWrite\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._access === NVMAccess.Read) {\n\t\t\tawait this._io.close();\n\t\t}\n\t\tthis._access = await this._io.open(NVMAccess.Write);\n\t}\n\n\tpublic async init(): Promise<NVM500Info> {\n\t\tawait this.ensureReadable();\n\n\t\t// Try the different known layouts to find one that works\n\t\tfor (const impl of nvm500Impls) {\n\t\t\ttry {\n\t\t\t\tconst info = await this.resolveLayout(impl);\n\t\t\t\tif (await this.isLayoutValid(info, impl.protocolVersions)) {\n\t\t\t\t\tthis._info = info;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (!this._info) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"Did not find a matching NVM 500 parser implementation! Make sure that the NVM data belongs to a controller with Z-Wave SDK 6.61 or higher.\",\n\t\t\t\tZWaveErrorCodes.NVM_NotSupported,\n\t\t\t);\n\t\t}\n\n\t\treturn this._info;\n\t}\n\n\tprivate async resolveLayout(impl: NVM500Impl): Promise<NVM500Info> {\n\t\tconst resolvedLayout = new Map<NVMEntryName, ResolvedNVMEntry>();\n\t\tlet nvmDescriptor: NVMDescriptor | undefined;\n\t\tconst moduleDescriptors = new Map<NVMEntryName, NVMModuleDescriptor>();\n\n\t\tlet offset = 0;\n\t\tlet moduleStart = -1;\n\t\tlet moduleSize = -1;\n\t\tconst nvmEnd = await nvmReadUInt16BE(this._io, 0);\n\n\t\tfor (const entry of impl.layout) {\n\t\t\tconst size = entry.size ?? NVMEntrySizes[entry.type];\n\n\t\t\tif (entry.type === NVMEntryType.NVMModuleSize) {\n\t\t\t\tif (moduleStart !== -1) {\n\t\t\t\t\t// All following NVM modules must start at the last module's end\n\t\t\t\t\toffset = moduleStart + moduleSize;\n\t\t\t\t}\n\n\t\t\t\tmoduleStart = offset;\n\t\t\t\tmoduleSize = await nvmReadUInt16BE(this._io, offset);\n\t\t\t} else if (entry.type === NVMEntryType.NVMModuleDescriptor) {\n\t\t\t\t// The module descriptor is always at the end of the module\n\t\t\t\toffset = moduleStart + moduleSize - size;\n\t\t\t}\n\n\t\t\tif (entry.offset != undefined && entry.offset !== offset) {\n\t\t\t\t// The entry has a defined offset but is at the wrong location\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`${entry.name} is at wrong location in NVM buffer!`,\n\t\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst resolvedEntry: ResolvedNVMEntry = {\n\t\t\t\t...entry,\n\t\t\t\toffset,\n\t\t\t\tsize,\n\t\t\t};\n\n\t\t\tif (entry.type === NVMEntryType.NVMDescriptor) {\n\t\t\t\tconst entryData = await this.readRawEntry(resolvedEntry);\n\t\t\t\t// NVMDescriptor is always a single entry\n\t\t\t\tnvmDescriptor = parseNVMDescriptor(entryData[0]);\n\t\t\t} else if (entry.type === NVMEntryType.NVMModuleDescriptor) {\n\t\t\t\tconst entryData = await this.readRawEntry(resolvedEntry);\n\t\t\t\t// NVMModuleDescriptor is always a single entry\n\t\t\t\tconst descriptor = parseNVMModuleDescriptor(\n\t\t\t\t\tentryData[0],\n\t\t\t\t);\n\t\t\t\tif (descriptor.size !== moduleSize) {\n\t\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t\t\"NVM module descriptor size does not match module size!\",\n\t\t\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tmoduleDescriptors.set(entry.name, descriptor);\n\t\t\t}\n\n\t\t\tresolvedLayout.set(entry.name, resolvedEntry);\n\n\t\t\t// Skip forward\n\t\t\toffset += size * entry.count;\n\t\t\tif (offset >= nvmEnd) break;\n\t\t}\n\n\t\tif (!nvmDescriptor) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t\"NVM descriptor not found in NVM!\",\n\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tlayout: resolvedLayout,\n\t\t\tlibrary: impl.library,\n\t\t\tmoduleDescriptors,\n\t\t\tnvmDescriptor,\n\t\t};\n\t}\n\n\tprivate async isLayoutValid(\n\t\tinfo: NVM500Info,\n\t\tprotocolVersions: string[],\n\t): Promise<boolean> {\n\t\t// Checking if an NVM is valid requires checking multiple bytes at different locations\n\t\tconst eeoffset_magic_entry = info.layout.get(\"EEOFFSET_MAGIC_far\");\n\t\tif (!eeoffset_magic_entry) return false;\n\t\tconst eeoffset_magic =\n\t\t\t(await this.readEntry(eeoffset_magic_entry))[0] as number;\n\n\t\tconst configuration_valid_0_entry = info.layout.get(\n\t\t\t\"NVM_CONFIGURATION_VALID_far\",\n\t\t);\n\t\tif (!configuration_valid_0_entry) return false;\n\t\tconst configuration_valid_0 =\n\t\t\t(await this.readEntry(configuration_valid_0_entry))[0] as number;\n\n\t\tconst configuration_valid_1_entry = info.layout.get(\n\t\t\t\"NVM_CONFIGURATION_REALLYVALID_far\",\n\t\t);\n\t\tif (!configuration_valid_1_entry) return false;\n\t\tconst configuration_valid_1 =\n\t\t\t(await this.readEntry(configuration_valid_1_entry))[0] as number;\n\n\t\tconst routecache_valid_entry = info.layout.get(\n\t\t\t\"EX_NVM_ROUTECACHE_MAGIC_far\",\n\t\t);\n\t\tif (!routecache_valid_entry) return false;\n\t\tconst routecache_valid =\n\t\t\t(await this.readEntry(routecache_valid_entry))[0] as number;\n\n\t\tconst endMarker_entry = info.layout.get(\"nvmModuleSizeEndMarker\");\n\t\tif (!endMarker_entry) return false;\n\t\tconst endMarker = (await this.readEntry(endMarker_entry))[0] as number;\n\n\t\treturn (\n\t\t\teeoffset_magic === MAGIC_VALUE\n\t\t\t&& configuration_valid_0 === CONFIGURATION_VALID_0\n\t\t\t&& configuration_valid_1 === CONFIGURATION_VALID_1\n\t\t\t&& routecache_valid === ROUTECACHE_VALID\n\t\t\t&& protocolVersions.includes(info.nvmDescriptor.protocolVersion)\n\t\t\t&& endMarker === 0\n\t\t);\n\t}\n\n\tasync has(property: NVMEntryName): Promise<boolean> {\n\t\tthis._info ??= await this.init();\n\t\treturn this._info.layout.has(property);\n\t}\n\n\tprivate async readSingleRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t): Promise<BytesView> {\n\t\tif (index >= entry.count) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Index out of range. Tried to read entry ${index} of ${entry.count}.`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\treturn nvmReadBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset + index * entry.size,\n\t\t\tentry.size,\n\t\t);\n\t}\n\n\tprivate async readRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t): Promise<BytesView[]> {\n\t\tconst ret: BytesView[] = [];\n\t\tconst nvmData = await nvmReadBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset,\n\t\t\tentry.count * entry.size,\n\t\t);\n\t\tfor (let i = 0; i < entry.count; i++) {\n\t\t\tret.push(\n\t\t\t\tnvmData.subarray(i * entry.size, (i + 1) * entry.size),\n\t\t\t);\n\t\t}\n\t\treturn ret;\n\t}\n\n\tprivate parseEntry(type: NVMEntryType, data: Bytes): NVMData {\n\t\tswitch (type) {\n\t\t\tcase NVMEntryType.Byte:\n\t\t\t\treturn data.readUInt8(0);\n\t\t\tcase NVMEntryType.Word:\n\t\t\tcase NVMEntryType.NVMModuleSize:\n\t\t\t\treturn data.readUInt16BE(0);\n\t\t\tcase NVMEntryType.DWord:\n\t\t\t\treturn data.readUInt32BE(0);\n\t\t\tcase NVMEntryType.NodeInfo:\n\t\t\t\tif (data.every((byte) => byte === 0)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn parseNVM500NodeInfo(data, 0);\n\t\t\tcase NVMEntryType.NodeMask:\n\t\t\t\treturn parseBitMask(data);\n\t\t\tcase NVMEntryType.SUCUpdateEntry:\n\t\t\t\tif (data.every((byte) => byte === 0)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn parseSUCUpdateEntry(data, 0);\n\t\t\tcase NVMEntryType.Route:\n\t\t\t\tif (data.every((byte) => byte === 0)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn parseRoute(data, 0);\n\t\t\tcase NVMEntryType.NVMModuleDescriptor: {\n\t\t\t\treturn parseNVMModuleDescriptor(data);\n\t\t\t}\n\t\t\tcase NVMEntryType.NVMDescriptor:\n\t\t\t\treturn parseNVMDescriptor(data);\n\t\t\tdefault:\n\t\t\t\t// This includes NVMEntryType.BUFFER\n\t\t\t\treturn data;\n\t\t}\n\t}\n\n\tprivate async readEntry(\n\t\tentry: ResolvedNVMEntry,\n\t): Promise<NVMData[]> {\n\t\tconst data: BytesView[] = await this.readRawEntry(entry);\n\t\treturn data.map((buffer) =>\n\t\t\tthis.parseEntry(entry.type, Bytes.view(buffer))\n\t\t);\n\t}\n\n\tprivate async readSingleEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t): Promise<NVMData> {\n\t\tconst data = await this.readSingleRawEntry(entry, index);\n\t\treturn this.parseEntry(entry.type, Bytes.view(data));\n\t}\n\n\tpublic async get(property: NVMEntryName): Promise<NVMData[] | undefined> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureReadable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return undefined;\n\n\t\treturn this.readEntry(entry);\n\t}\n\n\tpublic async getSingle(\n\t\tproperty: NVMEntryName,\n\t\tindex: number,\n\t): Promise<NVMData | undefined> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureReadable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return undefined;\n\n\t\treturn this.readSingleEntry(entry, index);\n\t}\n\n\tprivate encodeEntry(\n\t\ttype: NVMEntryType,\n\t\tdata: NVMData,\n\t\tentrySize?: number,\n\t): Bytes {\n\t\tconst size = entrySize ?? NVMEntrySizes[type];\n\n\t\tswitch (type) {\n\t\t\tcase NVMEntryType.Byte:\n\t\t\t\treturn Bytes.from([data as number]);\n\t\t\tcase NVMEntryType.Word:\n\t\t\tcase NVMEntryType.NVMModuleSize: {\n\t\t\t\tconst ret = new Bytes(2);\n\t\t\t\tret.writeUInt16BE(data as number, 0);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase NVMEntryType.DWord: {\n\t\t\t\tconst ret = new Bytes(4);\n\t\t\t\tret.writeUInt32BE(data as number, 0);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase NVMEntryType.NodeInfo:\n\t\t\t\treturn data\n\t\t\t\t\t? encodeNVM500NodeInfo(data as NVM500NodeInfo)\n\t\t\t\t\t: new Bytes(size).fill(0);\n\t\t\tcase NVMEntryType.NodeMask: {\n\t\t\t\tconst ret = new Bytes(size).fill(0);\n\t\t\t\tif (data) {\n\t\t\t\t\tret.set(encodeBitMask(data as number[], MAX_NODES, 1), 0);\n\t\t\t\t}\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase NVMEntryType.SUCUpdateEntry:\n\t\t\t\treturn encodeSUCUpdateEntry(data as SUCUpdateEntry);\n\t\t\tcase NVMEntryType.Route:\n\t\t\t\treturn encodeRoute(data as Route);\n\t\t\tcase NVMEntryType.NVMModuleDescriptor:\n\t\t\t\treturn encodeNVMModuleDescriptor(\n\t\t\t\t\tdata as NVMModuleDescriptor,\n\t\t\t\t);\n\t\t\tcase NVMEntryType.NVMDescriptor:\n\t\t\t\treturn encodeNVMDescriptor(data as NVMDescriptor);\n\t\t\tcase NVMEntryType.Buffer:\n\t\t\t\treturn data as Bytes;\n\t\t}\n\t}\n\n\tprivate async writeSingleRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t\tdata: BytesView,\n\t): Promise<void> {\n\t\tif (index >= entry.count) {\n\t\t\tthrow new ZWaveError(\n\t\t\t\t`Index out of range. Tried to write entry ${index} of ${entry.count}.`,\n\t\t\t\tZWaveErrorCodes.Argument_Invalid,\n\t\t\t);\n\t\t}\n\t\treturn nvmWriteBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset + index * entry.size,\n\t\t\tdata,\n\t\t);\n\t}\n\n\tprivate async writeRawEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tdata: BytesView[],\n\t): Promise<void> {\n\t\tawait nvmWriteBuffer(\n\t\t\tthis._io,\n\t\t\tentry.offset,\n\t\t\tBytes.concat(data),\n\t\t);\n\t}\n\n\tprivate async writeEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tdata: NVMData[],\n\t): Promise<void> {\n\t\tconst buffers = data.map((d) =>\n\t\t\tthis.encodeEntry(entry.type, d, entry.size)\n\t\t);\n\t\tawait this.writeRawEntry(entry, buffers);\n\t}\n\n\tprivate async writeSingleEntry(\n\t\tentry: ResolvedNVMEntry,\n\t\tindex: number,\n\t\tdata: NVMData,\n\t): Promise<void> {\n\t\tconst buffer = this.encodeEntry(entry.type, data, entry.size);\n\t\tawait this.writeSingleRawEntry(entry, index, buffer);\n\t}\n\n\tpublic async set(property: NVMEntryName, value: NVMData[]): Promise<void> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureWritable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return;\n\n\t\tawait this.writeEntry(entry, value);\n\t}\n\n\tpublic async setSingle(\n\t\tproperty: NVMEntryName,\n\t\tindex: number,\n\t\tvalue: NVMData,\n\t): Promise<void> {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureWritable();\n\n\t\tconst entry = this._info.layout.get(property);\n\t\tif (!entry) return undefined;\n\n\t\tawait this.writeSingleEntry(entry, index, value);\n\t}\n\n\tprivate async fill(key: NVMEntryName, value: number) {\n\t\tthis._info ??= await this.init();\n\t\tawait this.ensureWritable();\n\n\t\tconst entry = this._info.layout.get(key);\n\t\t// Skip entries not present in this layout\n\t\tif (!entry) return;\n\n\t\tconst size = entry.size ?? NVMEntrySizes[entry.type];\n\n\t\tconst data: NVMData[] = [];\n\t\tfor (let i = 1; i <= entry.count; i++) {\n\t\t\tswitch (entry.type) {\n\t\t\t\tcase NVMEntryType.Byte:\n\t\t\t\tcase NVMEntryType.Word:\n\t\t\t\tcase NVMEntryType.DWord:\n\t\t\t\t\tdata.push(value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase NVMEntryType.Buffer:\n\t\t\t\t\tdata.push(new Uint8Array(size).fill(value));\n\t\t\t\t\tbreak;\n\t\t\t\tcase NVMEntryType.NodeMask:\n\t\t\t\t\tdata.push(Array.from<number>({ length: size }).fill(value));\n\t\t\t\t\tbreak;\n\t\t\t\tcase NVMEntryType.NodeInfo:\n\t\t\t\tcase NVMEntryType.Route:\n\t\t\t\t\tdata.push(undefined);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Cannot fill entry of type ${NVMEntryType[entry.type]}`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tawait this.writeEntry(entry, data);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tpublic async delete(_property: NVMEntryName): Promise<void> {\n\t\tthrow new Error(\n\t\t\t\"Deleting entries is not supported for 500 series NVMs\",\n\t\t);\n\t}\n\n\tpublic async erase(\n\t\toptions: NVM500EraseOptions,\n\t): Promise<void> {\n\t\t// Blank NVM with 0xff\n\t\tawait nvmWriteBuffer(\n\t\t\tthis._io,\n\t\t\t0,\n\t\t\tnew Uint8Array(options.nvmSize).fill(0xff),\n\t\t);\n\n\t\t// Compute module sizes\n\t\tconst layoutEntries = Array.from(options.layout.values());\n\t\tconst moduleSizeEntries = layoutEntries\n\t\t\t.filter((entry) => entry.type === NVMEntryType.NVMModuleSize);\n\t\tconst moduleDescriptorEntries = layoutEntries\n\t\t\t.filter((entry) => entry.type === NVMEntryType.NVMModuleDescriptor);\n\t\tconst moduleDescriptors = new Map<NVMEntryName, NVMModuleDescriptor>();\n\t\t// Each module starts with a size marker and ends with a descriptor\n\t\tfor (let i = 0; i < moduleSizeEntries.length; i++) {\n\t\t\tconst sizeEntry = moduleSizeEntries[i];\n\t\t\tconst descriptorEntry = moduleDescriptorEntries[i];\n\t\t\tconst size = descriptorEntry.offset\n\t\t\t\t+ descriptorEntry.size\n\t\t\t\t- sizeEntry.offset;\n\n\t\t\t// Write each module size to their NVMModuleSize marker\n\t\t\tawait this.writeEntry(sizeEntry, [size]);\n\n\t\t\t// Write each module size, type and version to the NVMModuleDescriptor at the end\n\t\t\tconst moduleType = descriptorEntry.name === \"nvmZWlibraryDescriptor\"\n\t\t\t\t? NVMModuleType.ZW_LIBRARY\n\t\t\t\t: descriptorEntry.name === \"nvmApplicationDescriptor\"\n\t\t\t\t? NVMModuleType.APPLICATION\n\t\t\t\t: descriptorEntry.name === \"nvmHostApplicationDescriptor\"\n\t\t\t\t? NVMModuleType.HOST_APPLICATION\n\t\t\t\t: descriptorEntry.name === \"nvmDescriptorDescriptor\"\n\t\t\t\t? NVMModuleType.NVM_DESCRIPTOR\n\t\t\t\t: 0;\n\n\t\t\tconst moduleDescriptor: NVMModuleDescriptor = {\n\t\t\t\tsize,\n\t\t\t\ttype: moduleType,\n\t\t\t\tversion: descriptorEntry.name === \"nvmZWlibraryDescriptor\"\n\t\t\t\t\t? options.nvmDescriptor.protocolVersion\n\t\t\t\t\t: options.nvmDescriptor.firmwareVersion,\n\t\t\t};\n\t\t\tmoduleDescriptors.set(descriptorEntry.name, moduleDescriptor);\n\t\t\tawait this.writeEntry(descriptorEntry, [moduleDescriptor]);\n\t\t}\n\n\t\t// Initialize this._info, so the following works\n\t\tthis._info = {\n\t\t\t...options,\n\t\t\tmoduleDescriptors,\n\t\t};\n\n\t\t// Write NVM size to nvmTotalEnd\n\t\t// the value points to the last byte, therefore subtract 1\n\t\tawait this.set(\"nvmTotalEnd\", [options.nvmSize - 1]);\n\n\t\t// Set some entries that are always identical\n\t\tawait this.set(\"NVM_CONFIGURATION_VALID_far\", [CONFIGURATION_VALID_0]);\n\t\tawait this.set(\"NVM_CONFIGURATION_REALLYVALID_far\", [\n\t\t\tCONFIGURATION_VALID_1,\n\t\t]);\n\t\tawait this.set(\"EEOFFSET_MAGIC_far\", [MAGIC_VALUE]);\n\t\tawait this.set(\"EX_NVM_ROUTECACHE_MAGIC_far\", [ROUTECACHE_VALID]);\n\t\tawait this.set(\"nvmModuleSizeEndMarker\", [0]);\n\n\t\t// Set NVM descriptor\n\t\tawait this.set(\"nvmDescriptor\", [options.nvmDescriptor]);\n\n\t\t// Set dummy entries we're never going to fill\n\t\tawait this.fill(\"NVM_INTERNAL_RESERVED_1_far\", 0);\n\t\tawait this.fill(\"NVM_INTERNAL_RESERVED_2_far\", 0xff);\n\t\tawait this.fill(\"NVM_INTERNAL_RESERVED_3_far\", 0);\n\t\tawait this.fill(\"NVM_RTC_TIMERS_far\", 0);\n\t\tawait this.fill(\"EX_NVM_SUC_ACTIVE_START_far\", 0);\n\t\tawait this.fill(\"EX_NVM_ZENSOR_TABLE_START_far\", 0);\n\t\tawait this.fill(\"NVM_SECURITY0_KEY_far\", 0);\n\n\t\t// And blank fields that are not supposed to be filled with 0xff\n\t\tawait this.fill(\"EX_NVM_SUC_CONTROLLER_LIST_START_far\", 0xfe);\n\t\tawait this.fill(\"EX_NVM_NODE_TABLE_START_far\", 0);\n\t\tawait this.fill(\"EX_NVM_ROUTING_TABLE_START_far\", 0);\n\t\t// For routes the value does not matter\n\t\tawait this.fill(\"EX_NVM_ROUTECACHE_START_far\", 0);\n\t\tawait this.fill(\"EX_NVM_ROUTECACHE_NLWR_SR_START_far\", 0);\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,kBAMO;AACP,oBAAsC;AACtC,yBAAgD;AAChD,wBAAoD;AACpD,4BAIO;AACP,mBAIO;AACP,0BAUO;AACP,mBAA4B;AAC5B,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AAK,KAAK,uCAAuC,CAAC;EACzD;;",
|
|
6
6
|
"names": ["import_shared"]
|
|
7
7
|
}
|
|
@@ -129,7 +129,7 @@ let ApplicationCCsFile = (() => {
|
|
|
129
129
|
}
|
|
130
130
|
return super.serialize();
|
|
131
131
|
}
|
|
132
|
-
//
|
|
132
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
133
133
|
toJSON() {
|
|
134
134
|
return {
|
|
135
135
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/ApplicationCCsFile.ts"],
|
|
4
|
-
"sourcesContent": ["import { CommandClasses } from \"@zwave-js/core\";\nimport { 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 ApplicationCCsFileOptions extends NVMFileCreationOptions {\n\tincludedInsecurely: CommandClasses[];\n\tincludedSecurelyInsecureCCs: CommandClasses[];\n\tincludedSecurelySecureCCs: CommandClasses[];\n}\n\nconst MAX_CCs = 35;\n\nexport const ApplicationCCsFileID = 103;\n\n@nvmFileID(ApplicationCCsFileID)\n@nvmSection(\"application\")\nexport class ApplicationCCsFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ApplicationCCsFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tlet offset = 0;\n\t\t\tlet numCCs = this.payload[offset];\n\t\t\tthis.includedInsecurely = [\n\t\t\t\t...this.payload.subarray(offset + 1, offset + 1 + numCCs),\n\t\t\t];\n\t\t\toffset += 1 + MAX_CCs;\n\n\t\t\tnumCCs = this.payload[offset];\n\t\t\tthis.includedSecurelyInsecureCCs = [\n\t\t\t\t...this.payload.subarray(offset + 1, offset + 1 + numCCs),\n\t\t\t];\n\t\t\toffset += 1 + MAX_CCs;\n\t\t\tnumCCs = this.payload[offset];\n\t\t\tthis.includedSecurelySecureCCs = [\n\t\t\t\t...this.payload.subarray(offset + 1, offset + 1 + numCCs),\n\t\t\t];\n\t\t} else {\n\t\t\tthis.includedInsecurely = options.includedInsecurely;\n\t\t\tthis.includedSecurelyInsecureCCs =\n\t\t\t\toptions.includedSecurelyInsecureCCs;\n\t\t\tthis.includedSecurelySecureCCs = options.includedSecurelySecureCCs;\n\t\t}\n\t}\n\n\tpublic includedInsecurely: CommandClasses[];\n\tpublic includedSecurelyInsecureCCs: CommandClasses[];\n\tpublic includedSecurelySecureCCs: CommandClasses[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = new Bytes((1 + MAX_CCs) * 3);\n\t\tlet offset = 0;\n\t\tfor (\n\t\t\tconst array of [\n\t\t\t\tthis.includedInsecurely,\n\t\t\t\tthis.includedSecurelyInsecureCCs,\n\t\t\t\tthis.includedSecurelySecureCCs,\n\t\t\t]\n\t\t) {\n\t\t\tthis.payload[offset] = array.length;\n\t\t\tthis.payload.set(array, offset + 1);\n\t\t\toffset += 1 + MAX_CCs;\n\t\t}\n\t\treturn super.serialize();\n\t}\n\n\t//
|
|
4
|
+
"sourcesContent": ["import { CommandClasses } from \"@zwave-js/core\";\nimport { 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 ApplicationCCsFileOptions extends NVMFileCreationOptions {\n\tincludedInsecurely: CommandClasses[];\n\tincludedSecurelyInsecureCCs: CommandClasses[];\n\tincludedSecurelySecureCCs: CommandClasses[];\n}\n\nconst MAX_CCs = 35;\n\nexport const ApplicationCCsFileID = 103;\n\n@nvmFileID(ApplicationCCsFileID)\n@nvmSection(\"application\")\nexport class ApplicationCCsFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ApplicationCCsFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tlet offset = 0;\n\t\t\tlet numCCs = this.payload[offset];\n\t\t\tthis.includedInsecurely = [\n\t\t\t\t...this.payload.subarray(offset + 1, offset + 1 + numCCs),\n\t\t\t];\n\t\t\toffset += 1 + MAX_CCs;\n\n\t\t\tnumCCs = this.payload[offset];\n\t\t\tthis.includedSecurelyInsecureCCs = [\n\t\t\t\t...this.payload.subarray(offset + 1, offset + 1 + numCCs),\n\t\t\t];\n\t\t\toffset += 1 + MAX_CCs;\n\t\t\tnumCCs = this.payload[offset];\n\t\t\tthis.includedSecurelySecureCCs = [\n\t\t\t\t...this.payload.subarray(offset + 1, offset + 1 + numCCs),\n\t\t\t];\n\t\t} else {\n\t\t\tthis.includedInsecurely = options.includedInsecurely;\n\t\t\tthis.includedSecurelyInsecureCCs =\n\t\t\t\toptions.includedSecurelyInsecureCCs;\n\t\t\tthis.includedSecurelySecureCCs = options.includedSecurelySecureCCs;\n\t\t}\n\t}\n\n\tpublic includedInsecurely: CommandClasses[];\n\tpublic includedSecurelyInsecureCCs: CommandClasses[];\n\tpublic includedSecurelySecureCCs: CommandClasses[];\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = new Bytes((1 + MAX_CCs) * 3);\n\t\tlet offset = 0;\n\t\tfor (\n\t\t\tconst array of [\n\t\t\t\tthis.includedInsecurely,\n\t\t\t\tthis.includedSecurelyInsecureCCs,\n\t\t\t\tthis.includedSecurelySecureCCs,\n\t\t\t]\n\t\t) {\n\t\t\tthis.payload[offset] = array.length;\n\t\t\tthis.payload.set(array, offset + 1);\n\t\t\toffset += 1 + MAX_CCs;\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\"included insecurely\": this.includedInsecurely\n\t\t\t\t.map((cc) => CommandClasses[cc])\n\t\t\t\t.join(\", \"),\n\t\t\t\"included securely (insecure)\": this.includedSecurelyInsecureCCs\n\t\t\t\t.map((cc) => CommandClasses[cc])\n\t\t\t\t.join(\", \"),\n\t\t\t\"included securely (secure)\": this.includedSecurelySecureCCs\n\t\t\t\t.map((cc) => CommandClasses[cc])\n\t\t\t\t.join(\", \"),\n\t\t};\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAA+B;AAC/B,oBAAsB;AAEtB,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQP,MAAM,UAAU;AAET,MAAM,uBAAuB;IAIvB,sBAAkB,MAAA;8BAF9B,0BAAU,oBAAoB,OAC9B,2BAAW,aAAa,CAAC;;;;oBACc;0CAAA,YAAO;WAAA;;;;;;;;AAA/C,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,SAAkE;AAElE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,YAAI,SAAS;AACb,YAAI,SAAS,KAAK,QAAQ,MAAM;AAChC,aAAK,qBAAqB;UACzB,GAAG,KAAK,QAAQ,SAAS,SAAS,GAAG,SAAS,IAAI,MAAM;;AAEzD,kBAAU,IAAI;AAEd,iBAAS,KAAK,QAAQ,MAAM;AAC5B,aAAK,8BAA8B;UAClC,GAAG,KAAK,QAAQ,SAAS,SAAS,GAAG,SAAS,IAAI,MAAM;;AAEzD,kBAAU,IAAI;AACd,iBAAS,KAAK,QAAQ,MAAM;AAC5B,aAAK,4BAA4B;UAChC,GAAG,KAAK,QAAQ,SAAS,SAAS,GAAG,SAAS,IAAI,MAAM;;MAE1D,OAAO;AACN,aAAK,qBAAqB,QAAQ;AAClC,aAAK,8BACJ,QAAQ;AACT,aAAK,4BAA4B,QAAQ;MAC1C;IACD;IAEO;IACA;IACA;IAEA,YAAS;AACf,WAAK,UAAU,IAAI,qBAAO,IAAI,WAAW,CAAC;AAC1C,UAAI,SAAS;AACb,iBACO,SAAS;QACd,KAAK;QACL,KAAK;QACL,KAAK;SAEL;AACD,aAAK,QAAQ,MAAM,IAAI,MAAM;AAC7B,aAAK,QAAQ,IAAI,OAAO,SAAS,CAAC;AAClC,kBAAU,IAAI;MACf;AACA,aAAO,MAAM,UAAS;IACvB;;IAGO,SAAM;AACZ,aAAO;QACN,GAAG,MAAM,OAAM;QACf,uBAAuB,KAAK,mBAC1B,IAAI,CAAC,OAAO,2BAAe,EAAE,CAAC,EAC9B,KAAK,IAAI;QACX,gCAAgC,KAAK,4BACnC,IAAI,CAAC,OAAO,2BAAe,EAAE,CAAC,EAC9B,KAAK,IAAI;QACX,8BAA8B,KAAK,0BACjC,IAAI,CAAC,OAAO,2BAAe,EAAE,CAAC,EAC9B,KAAK,IAAI;;IAEb;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -169,7 +169,7 @@ let ApplicationRFConfigFile = (() => {
|
|
|
169
169
|
}
|
|
170
170
|
return super.serialize();
|
|
171
171
|
}
|
|
172
|
-
//
|
|
172
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
173
173
|
toJSON() {
|
|
174
174
|
const ret = {
|
|
175
175
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/ApplicationRFConfigFile.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tNodeIDType,\n\tRFRegion,\n\tZWaveError,\n\tZWaveErrorCodes,\n} from \"@zwave-js/core\";\nimport { type AllOrNone, Bytes, getEnumMemberName } from \"@zwave-js/shared\";\nimport semverGte from \"semver/functions/gte.js\";\nimport semverLt from \"semver/functions/lt.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 type ApplicationRFConfigFileOptions =\n\t& NVMFileCreationOptions\n\t& {\n\t\trfRegion: RFRegion;\n\t\ttxPower: number;\n\t\tmeasured0dBm: number;\n\t}\n\t& AllOrNone<{\n\t\tenablePTI?: number;\n\t\tmaxTXPower?: number;\n\t}>\n\t& {\n\t\tnodeIdType?: number;\n\t};\n\nexport const ApplicationRFConfigFileID = 104;\n\n@nvmFileID(ApplicationRFConfigFileID)\n@nvmSection(\"application\")\nexport class ApplicationRFConfigFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ApplicationRFConfigFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tif (this.payload.length === 3 || this.payload.length === 6) {\n\t\t\t\tthis.rfRegion = this.payload[0];\n\t\t\t\tthis.txPower = this.payload.readInt8(1) / 10;\n\t\t\t\tthis.measured0dBm = this.payload.readInt8(2) / 10;\n\t\t\t\tif (this.payload.length === 6) {\n\t\t\t\t\tthis.enablePTI = this.payload[3];\n\t\t\t\t\tthis.maxTXPower = this.payload.readInt16LE(4) / 10;\n\t\t\t\t}\n\t\t\t} else if (this.payload.length === 8) {\n\t\t\t\tthis.rfRegion = this.payload[0];\n\t\t\t\tthis.txPower = this.payload.readInt16LE(1) / 10;\n\t\t\t\tthis.measured0dBm = this.payload.readInt16LE(3) / 10;\n\t\t\t\tthis.enablePTI = this.payload[5];\n\t\t\t\tthis.maxTXPower = this.payload.readInt16LE(6) / 10;\n\t\t\t} else if (this.payload.length === 9) {\n\t\t\t\tthis.rfRegion = this.payload[0];\n\t\t\t\tthis.txPower = this.payload.readInt16LE(1) / 10;\n\t\t\t\tthis.measured0dBm = this.payload.readInt16LE(3) / 10;\n\t\t\t\tthis.enablePTI = this.payload[5];\n\t\t\t\tthis.maxTXPower = this.payload.readInt16LE(6) / 10;\n\t\t\t\tthis.nodeIdType = this.payload[8];\n\t\t\t} else {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`ApplicationRFConfigFile has unsupported length ${this.payload.length}`,\n\t\t\t\t\tZWaveErrorCodes.NVM_NotSupported,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.rfRegion = options.rfRegion;\n\t\t\tthis.txPower = options.txPower;\n\t\t\tthis.measured0dBm = options.measured0dBm;\n\t\t\tthis.enablePTI = options.enablePTI;\n\t\t\tthis.maxTXPower = options.maxTXPower;\n\t\t\tthis.nodeIdType = options.nodeIdType;\n\t\t}\n\t}\n\n\tpublic rfRegion: RFRegion;\n\tpublic txPower: number;\n\tpublic measured0dBm: number;\n\tpublic enablePTI?: number;\n\tpublic maxTXPower?: number;\n\tpublic nodeIdType?: NodeIDType;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (semverLt(this.fileVersion, \"7.18.1\")) {\n\t\t\tthis.payload = new Bytes(\n\t\t\t\tsemverGte(this.fileVersion, \"7.15.3\") ? 6 : 3,\n\t\t\t).fill(0);\n\t\t\tthis.payload[0] = this.rfRegion;\n\t\t\tthis.payload.writeIntLE(this.txPower * 10, 1, 1);\n\t\t\tthis.payload.writeIntLE(this.measured0dBm * 10, 2, 1);\n\t\t\tif (semverGte(this.fileVersion, \"7.15.3\")) {\n\t\t\t\tthis.payload[3] = this.enablePTI ?? 0;\n\t\t\t\tthis.payload.writeInt16LE((this.maxTXPower ?? 0) * 10, 4);\n\t\t\t}\n\t\t} else if (semverLt(this.fileVersion, \"7.21.0\")) {\n\t\t\tthis.payload = new Bytes(8).fill(0);\n\t\t\tthis.payload[0] = this.rfRegion;\n\t\t\tthis.payload.writeInt16LE(this.txPower * 10, 1);\n\t\t\tthis.payload.writeInt16LE(this.measured0dBm * 10, 3);\n\t\t\tthis.payload[5] = this.enablePTI ?? 0;\n\t\t\tthis.payload.writeInt16LE((this.maxTXPower ?? 0) * 10, 6);\n\t\t} else {\n\t\t\tthis.payload = new Bytes(9).fill(0);\n\t\t\tthis.payload[0] = this.rfRegion;\n\t\t\tthis.payload.writeInt16LE(this.txPower * 10, 1);\n\t\t\tthis.payload.writeInt16LE(this.measured0dBm * 10, 3);\n\t\t\tthis.payload[5] = this.enablePTI ?? 0;\n\t\t\tthis.payload.writeInt16LE((this.maxTXPower ?? 0) * 10, 6);\n\t\t\tthis.payload[8] = this.nodeIdType ?? NodeIDType.Short;\n\t\t}\n\t\treturn super.serialize();\n\t}\n\n\t//
|
|
4
|
+
"sourcesContent": ["import {\n\tNodeIDType,\n\tRFRegion,\n\tZWaveError,\n\tZWaveErrorCodes,\n} from \"@zwave-js/core\";\nimport { type AllOrNone, Bytes, getEnumMemberName } from \"@zwave-js/shared\";\nimport semverGte from \"semver/functions/gte.js\";\nimport semverLt from \"semver/functions/lt.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 type ApplicationRFConfigFileOptions =\n\t& NVMFileCreationOptions\n\t& {\n\t\trfRegion: RFRegion;\n\t\ttxPower: number;\n\t\tmeasured0dBm: number;\n\t}\n\t& AllOrNone<{\n\t\tenablePTI?: number;\n\t\tmaxTXPower?: number;\n\t}>\n\t& {\n\t\tnodeIdType?: number;\n\t};\n\nexport const ApplicationRFConfigFileID = 104;\n\n@nvmFileID(ApplicationRFConfigFileID)\n@nvmSection(\"application\")\nexport class ApplicationRFConfigFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ApplicationRFConfigFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tif (this.payload.length === 3 || this.payload.length === 6) {\n\t\t\t\tthis.rfRegion = this.payload[0];\n\t\t\t\tthis.txPower = this.payload.readInt8(1) / 10;\n\t\t\t\tthis.measured0dBm = this.payload.readInt8(2) / 10;\n\t\t\t\tif (this.payload.length === 6) {\n\t\t\t\t\tthis.enablePTI = this.payload[3];\n\t\t\t\t\tthis.maxTXPower = this.payload.readInt16LE(4) / 10;\n\t\t\t\t}\n\t\t\t} else if (this.payload.length === 8) {\n\t\t\t\tthis.rfRegion = this.payload[0];\n\t\t\t\tthis.txPower = this.payload.readInt16LE(1) / 10;\n\t\t\t\tthis.measured0dBm = this.payload.readInt16LE(3) / 10;\n\t\t\t\tthis.enablePTI = this.payload[5];\n\t\t\t\tthis.maxTXPower = this.payload.readInt16LE(6) / 10;\n\t\t\t} else if (this.payload.length === 9) {\n\t\t\t\tthis.rfRegion = this.payload[0];\n\t\t\t\tthis.txPower = this.payload.readInt16LE(1) / 10;\n\t\t\t\tthis.measured0dBm = this.payload.readInt16LE(3) / 10;\n\t\t\t\tthis.enablePTI = this.payload[5];\n\t\t\t\tthis.maxTXPower = this.payload.readInt16LE(6) / 10;\n\t\t\t\tthis.nodeIdType = this.payload[8];\n\t\t\t} else {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`ApplicationRFConfigFile has unsupported length ${this.payload.length}`,\n\t\t\t\t\tZWaveErrorCodes.NVM_NotSupported,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.rfRegion = options.rfRegion;\n\t\t\tthis.txPower = options.txPower;\n\t\t\tthis.measured0dBm = options.measured0dBm;\n\t\t\tthis.enablePTI = options.enablePTI;\n\t\t\tthis.maxTXPower = options.maxTXPower;\n\t\t\tthis.nodeIdType = options.nodeIdType;\n\t\t}\n\t}\n\n\tpublic rfRegion: RFRegion;\n\tpublic txPower: number;\n\tpublic measured0dBm: number;\n\tpublic enablePTI?: number;\n\tpublic maxTXPower?: number;\n\tpublic nodeIdType?: NodeIDType;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (semverLt(this.fileVersion, \"7.18.1\")) {\n\t\t\tthis.payload = new Bytes(\n\t\t\t\tsemverGte(this.fileVersion, \"7.15.3\") ? 6 : 3,\n\t\t\t).fill(0);\n\t\t\tthis.payload[0] = this.rfRegion;\n\t\t\tthis.payload.writeIntLE(this.txPower * 10, 1, 1);\n\t\t\tthis.payload.writeIntLE(this.measured0dBm * 10, 2, 1);\n\t\t\tif (semverGte(this.fileVersion, \"7.15.3\")) {\n\t\t\t\tthis.payload[3] = this.enablePTI ?? 0;\n\t\t\t\tthis.payload.writeInt16LE((this.maxTXPower ?? 0) * 10, 4);\n\t\t\t}\n\t\t} else if (semverLt(this.fileVersion, \"7.21.0\")) {\n\t\t\tthis.payload = new Bytes(8).fill(0);\n\t\t\tthis.payload[0] = this.rfRegion;\n\t\t\tthis.payload.writeInt16LE(this.txPower * 10, 1);\n\t\t\tthis.payload.writeInt16LE(this.measured0dBm * 10, 3);\n\t\t\tthis.payload[5] = this.enablePTI ?? 0;\n\t\t\tthis.payload.writeInt16LE((this.maxTXPower ?? 0) * 10, 6);\n\t\t} else {\n\t\t\tthis.payload = new Bytes(9).fill(0);\n\t\t\tthis.payload[0] = this.rfRegion;\n\t\t\tthis.payload.writeInt16LE(this.txPower * 10, 1);\n\t\t\tthis.payload.writeInt16LE(this.measured0dBm * 10, 3);\n\t\t\tthis.payload[5] = this.enablePTI ?? 0;\n\t\t\tthis.payload.writeInt16LE((this.maxTXPower ?? 0) * 10, 6);\n\t\t\tthis.payload[8] = this.nodeIdType ?? NodeIDType.Short;\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\tconst ret: Record<string, any> = {\n\t\t\t...super.toJSON(),\n\t\t\t\"RF Region\": getEnumMemberName(RFRegion, this.rfRegion),\n\t\t\t\"TX Power\": `${this.txPower.toFixed(1)} dBm`,\n\t\t\t\"Power @ 0dBm\": `${this.measured0dBm.toFixed(1)} dBm`,\n\t\t};\n\t\tif (this.enablePTI != undefined) {\n\t\t\tret[\"enable PTI\"] = this.enablePTI;\n\t\t}\n\t\tif (this.maxTXPower != undefined) {\n\t\t\tret[\"max TX power\"] = `${this.maxTXPower.toFixed(1)} dBm`;\n\t\t}\n\t\tif (this.nodeIdType != undefined) {\n\t\t\tret[\"node ID type\"] = getEnumMemberName(\n\t\t\t\tNodeIDType,\n\t\t\t\tthis.nodeIdType,\n\t\t\t);\n\t\t}\n\t\treturn ret;\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAKO;AACP,oBAAyD;AACzD,iBAAsB;AACtB,gBAAqB;AAErB,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,4BAA4B;IAI5B,2BAAuB,MAAA;8BAFnC,0BAAU,yBAAyB,OACnC,2BAAW,aAAa,CAAC;;;;oBACmB;+CAAA,YAAO;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;;IACZ,YACC,SAAuE;AAEvE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,YAAI,KAAK,QAAQ,WAAW,KAAK,KAAK,QAAQ,WAAW,GAAG;AAC3D,eAAK,WAAW,KAAK,QAAQ,CAAC;AAC9B,eAAK,UAAU,KAAK,QAAQ,SAAS,CAAC,IAAI;AAC1C,eAAK,eAAe,KAAK,QAAQ,SAAS,CAAC,IAAI;AAC/C,cAAI,KAAK,QAAQ,WAAW,GAAG;AAC9B,iBAAK,YAAY,K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AK,WAAW,QAAQ,CAAC,CAAC;MACpD;AACA,UAAI,KAAK,cAAc,QAAW;AACjC,YAAI,cAAc,QAAI,iCACrB,wBACA,KAAK,UAAU;MAEjB;AACA,aAAO;IACR;;;;",
|
|
6
6
|
"names": ["semverLt", "semverGte"]
|
|
7
7
|
}
|
|
@@ -112,7 +112,7 @@ let ApplicationTypeFile = (() => {
|
|
|
112
112
|
]);
|
|
113
113
|
return super.serialize();
|
|
114
114
|
}
|
|
115
|
-
//
|
|
115
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
116
116
|
toJSON() {
|
|
117
117
|
return {
|
|
118
118
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/ApplicationTypeFile.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 ApplicationTypeFileOptions extends NVMFileCreationOptions {\n\tisListening: boolean;\n\toptionalFunctionality: boolean;\n\tgenericDeviceClass: number;\n\tspecificDeviceClass: number;\n}\n\nexport const ApplicationTypeFileID = 102;\n\n@nvmFileID(ApplicationTypeFileID)\n@nvmSection(\"application\")\nexport class ApplicationTypeFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ApplicationTypeFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.isListening = !!(this.payload[0] & 0b1);\n\t\t\tthis.optionalFunctionality = !!(this.payload[0] & 0b10);\n\t\t\tthis.genericDeviceClass = this.payload[1];\n\t\t\tthis.specificDeviceClass = this.payload[2];\n\t\t} else {\n\t\t\tthis.isListening = options.isListening;\n\t\t\tthis.optionalFunctionality = options.optionalFunctionality;\n\t\t\tthis.genericDeviceClass = options.genericDeviceClass;\n\t\t\tthis.specificDeviceClass = options.specificDeviceClass;\n\t\t}\n\t}\n\n\tpublic isListening: boolean;\n\tpublic optionalFunctionality: boolean;\n\tpublic genericDeviceClass: number;\n\tpublic specificDeviceClass: number;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = Bytes.from([\n\t\t\t(this.isListening ? 0b1 : 0)\n\t\t\t| (this.optionalFunctionality ? 0b10 : 0),\n\t\t\tthis.genericDeviceClass,\n\t\t\tthis.specificDeviceClass,\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 ApplicationTypeFileOptions extends NVMFileCreationOptions {\n\tisListening: boolean;\n\toptionalFunctionality: boolean;\n\tgenericDeviceClass: number;\n\tspecificDeviceClass: number;\n}\n\nexport const ApplicationTypeFileID = 102;\n\n@nvmFileID(ApplicationTypeFileID)\n@nvmSection(\"application\")\nexport class ApplicationTypeFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ApplicationTypeFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.isListening = !!(this.payload[0] & 0b1);\n\t\t\tthis.optionalFunctionality = !!(this.payload[0] & 0b10);\n\t\t\tthis.genericDeviceClass = this.payload[1];\n\t\t\tthis.specificDeviceClass = this.payload[2];\n\t\t} else {\n\t\t\tthis.isListening = options.isListening;\n\t\t\tthis.optionalFunctionality = options.optionalFunctionality;\n\t\t\tthis.genericDeviceClass = options.genericDeviceClass;\n\t\t\tthis.specificDeviceClass = options.specificDeviceClass;\n\t\t}\n\t}\n\n\tpublic isListening: boolean;\n\tpublic optionalFunctionality: boolean;\n\tpublic genericDeviceClass: number;\n\tpublic specificDeviceClass: number;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tthis.payload = Bytes.from([\n\t\t\t(this.isListening ? 0b1 : 0)\n\t\t\t| (this.optionalFunctionality ? 0b10 : 0),\n\t\t\tthis.genericDeviceClass,\n\t\t\tthis.specificDeviceClass,\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\tlistening: this.isListening,\n\t\t\t\"opt. functionality\": this.optionalFunctionality,\n\t\t\tgenericDeviceClass: this.genericDeviceClass,\n\t\t\tspecificDeviceClass: this.specificDeviceClass,\n\t\t};\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAsB;AAEtB,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,wBAAwB;IAIxB,uBAAmB,MAAA;8BAF/B,0BAAU,qBAAqB,OAC/B,2BAAW,aAAa,CAAC;;;;oBACe;2CAAA,YAAO;WAAA;;;;;;;;AAAhD,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,SAAmE;AAEnE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,aAAK,cAAc,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI;AACxC,aAAK,wBAAwB,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI;AAClD,aAAK,qBAAqB,KAAK,QAAQ,CAAC;AACxC,aAAK,sBAAsB,KAAK,QAAQ,CAAC;MAC1C,OAAO;AACN,aAAK,cAAc,QAAQ;AAC3B,aAAK,wBAAwB,QAAQ;AACrC,aAAK,qBAAqB,QAAQ;AAClC,aAAK,sBAAsB,QAAQ;MACpC;IACD;IAEO;IACA;IACA;IACA;IAEA,YAAS;AACf,WAAK,UAAU,oBAAM,KAAK;SACxB,KAAK,cAAc,IAAM,MACvB,KAAK,wBAAwB,IAAO;QACvC,KAAK;QACL,KAAK;OACL;AACD,aAAO,MAAM,UAAS;IACvB;;IAGO,SAAM;AACZ,aAAO;QACN,GAAG,MAAM,OAAM;QACf,WAAW,KAAK;QAChB,sBAAsB,KAAK;QAC3B,oBAAoB,KAAK;QACzB,qBAAqB,KAAK;;IAE5B;;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -190,7 +190,7 @@ let ControllerInfoFile = (() => {
|
|
|
190
190
|
}
|
|
191
191
|
return super.serialize();
|
|
192
192
|
}
|
|
193
|
-
//
|
|
193
|
+
// oxlint-disable-next-line typescript/explicit-module-boundary-types
|
|
194
194
|
toJSON() {
|
|
195
195
|
return (0, import_core.stripUndefined)({
|
|
196
196
|
...super.toJSON(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/nvm3/files/ControllerInfoFile.ts"],
|
|
4
|
-
"sourcesContent": ["import { ZWaveError, ZWaveErrorCodes, stripUndefined } from \"@zwave-js/core\";\nimport { Bytes, type BytesView, buffer2hex } 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 type ControllerInfoFileOptions =\n\t& NVMFileCreationOptions\n\t& {\n\t\thomeId: BytesView;\n\t\tnodeId: number;\n\t\tlastNodeId: number;\n\t\tstaticControllerNodeId: number;\n\t\tsucLastIndex: number;\n\t\tcontrollerConfiguration: number;\n\t\tmaxNodeId: number;\n\t\treservedId: number;\n\t\tsystemState: number;\n\t}\n\t& (\n\t\t| {\n\t\t\tsucAwarenessPushNeeded: number;\n\t\t}\n\t\t| {\n\t\t\tlastNodeIdLR: number;\n\t\t\tmaxNodeIdLR: number;\n\t\t\treservedIdLR: number;\n\t\t\tprimaryLongRangeChannelId: number;\n\t\t\tdcdcConfig: number;\n\t\t}\n\t);\n\nexport const ControllerInfoFileID = 0x50004;\n\n@nvmFileID(ControllerInfoFileID)\n@nvmSection(\"protocol\")\nexport class ControllerInfoFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ControllerInfoFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.homeId = this.payload.subarray(0, 4);\n\t\t\tif (this.payload.length === 13) {\n\t\t\t\tthis.nodeId = this.payload[4];\n\t\t\t\tthis.lastNodeId = this.payload[5];\n\t\t\t\tthis.staticControllerNodeId = this.payload[6];\n\t\t\t\tthis.sucLastIndex = this.payload[7];\n\t\t\t\tthis.controllerConfiguration = this.payload[8];\n\t\t\t\tthis.sucAwarenessPushNeeded = this.payload[9];\n\t\t\t\tthis.maxNodeId = this.payload[10];\n\t\t\t\tthis.reservedId = this.payload[11];\n\t\t\t\tthis.systemState = this.payload[12];\n\t\t\t} else if (this.payload.length === 22) {\n\t\t\t\tthis.nodeId = this.payload.readUInt16LE(4);\n\t\t\t\tthis.staticControllerNodeId = this.payload.readUInt16LE(6);\n\t\t\t\tthis.lastNodeIdLR = this.payload.readUInt16LE(8);\n\t\t\t\tthis.lastNodeId = this.payload[10];\n\t\t\t\tthis.sucLastIndex = this.payload[11];\n\t\t\t\tthis.maxNodeIdLR = this.payload.readUInt16LE(12);\n\t\t\t\tthis.maxNodeId = this.payload[14];\n\t\t\t\tthis.controllerConfiguration = this.payload[15];\n\t\t\t\tthis.reservedIdLR = this.payload.readUInt16LE(16);\n\t\t\t\tthis.reservedId = this.payload[18];\n\t\t\t\tthis.systemState = this.payload[19];\n\t\t\t\tthis.primaryLongRangeChannelId = this.payload[20];\n\t\t\t\tthis.dcdcConfig = this.payload[21];\n\t\t\t} else {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`Unsupported payload length`,\n\t\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.homeId = Bytes.view(options.homeId);\n\t\t\tthis.nodeId = options.nodeId;\n\t\t\tthis.lastNodeId = options.lastNodeId;\n\t\t\tthis.staticControllerNodeId = options.staticControllerNodeId;\n\t\t\tthis.sucLastIndex = options.sucLastIndex;\n\t\t\tthis.controllerConfiguration = options.controllerConfiguration;\n\t\t\tthis.maxNodeId = options.maxNodeId;\n\t\t\tthis.reservedId = options.reservedId;\n\t\t\tthis.systemState = options.systemState;\n\t\t\tif (\"lastNodeIdLR\" in options) {\n\t\t\t\tthis.lastNodeIdLR = options.lastNodeIdLR;\n\t\t\t\tthis.maxNodeIdLR = options.maxNodeIdLR;\n\t\t\t\tthis.reservedIdLR = options.reservedIdLR;\n\t\t\t\tthis.primaryLongRangeChannelId =\n\t\t\t\t\toptions.primaryLongRangeChannelId;\n\t\t\t\tthis.dcdcConfig = options.dcdcConfig;\n\t\t\t} else {\n\t\t\t\tthis.sucAwarenessPushNeeded = options.sucAwarenessPushNeeded;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic homeId: BytesView;\n\tpublic nodeId: number;\n\tpublic lastNodeId: number;\n\tpublic staticControllerNodeId: number;\n\tpublic sucLastIndex: number;\n\tpublic controllerConfiguration: number; // TODO: Figure out what this is\n\tpublic sucAwarenessPushNeeded?: number;\n\tpublic maxNodeId: number;\n\tpublic reservedId: number;\n\tpublic systemState: number;\n\tpublic lastNodeIdLR?: number;\n\tpublic maxNodeIdLR?: number;\n\tpublic reservedIdLR?: number;\n\tpublic primaryLongRangeChannelId?: number;\n\tpublic dcdcConfig?: number;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (this.lastNodeIdLR != undefined) {\n\t\t\tthis.payload = new Bytes(22);\n\t\t\tthis.payload.set(this.homeId, 0);\n\t\t\tthis.payload.writeUInt16LE(this.nodeId, 4);\n\t\t\tthis.payload.writeUInt16LE(this.staticControllerNodeId, 6);\n\t\t\tthis.payload.writeUInt16LE(this.lastNodeIdLR, 8);\n\t\t\tthis.payload[10] = this.lastNodeId;\n\t\t\tthis.payload[11] = this.sucLastIndex;\n\t\t\tthis.payload.writeUInt16LE(this.maxNodeIdLR!, 12);\n\t\t\tthis.payload[14] = this.maxNodeId;\n\t\t\tthis.payload[15] = this.controllerConfiguration;\n\t\t\tthis.payload.writeUInt16LE(this.reservedIdLR!, 16);\n\t\t\tthis.payload[18] = this.reservedId;\n\t\t\tthis.payload[19] = this.systemState;\n\t\t\tthis.payload[20] = this.primaryLongRangeChannelId!;\n\t\t\tthis.payload[21] = this.dcdcConfig!;\n\t\t} else {\n\t\t\t// V0\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.homeId,\n\t\t\t\tBytes.from([\n\t\t\t\t\tthis.nodeId,\n\t\t\t\t\tthis.lastNodeId,\n\t\t\t\t\tthis.staticControllerNodeId,\n\t\t\t\t\tthis.sucLastIndex,\n\t\t\t\t\tthis.controllerConfiguration,\n\t\t\t\t\tthis.sucAwarenessPushNeeded ?? 0,\n\t\t\t\t\tthis.maxNodeId,\n\t\t\t\t\tthis.reservedId,\n\t\t\t\t\tthis.systemState,\n\t\t\t\t]),\n\t\t\t]);\n\t\t}\n\t\treturn super.serialize();\n\t}\n\n\t//
|
|
4
|
+
"sourcesContent": ["import { ZWaveError, ZWaveErrorCodes, stripUndefined } from \"@zwave-js/core\";\nimport { Bytes, type BytesView, buffer2hex } 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 type ControllerInfoFileOptions =\n\t& NVMFileCreationOptions\n\t& {\n\t\thomeId: BytesView;\n\t\tnodeId: number;\n\t\tlastNodeId: number;\n\t\tstaticControllerNodeId: number;\n\t\tsucLastIndex: number;\n\t\tcontrollerConfiguration: number;\n\t\tmaxNodeId: number;\n\t\treservedId: number;\n\t\tsystemState: number;\n\t}\n\t& (\n\t\t| {\n\t\t\tsucAwarenessPushNeeded: number;\n\t\t}\n\t\t| {\n\t\t\tlastNodeIdLR: number;\n\t\t\tmaxNodeIdLR: number;\n\t\t\treservedIdLR: number;\n\t\t\tprimaryLongRangeChannelId: number;\n\t\t\tdcdcConfig: number;\n\t\t}\n\t);\n\nexport const ControllerInfoFileID = 0x50004;\n\n@nvmFileID(ControllerInfoFileID)\n@nvmSection(\"protocol\")\nexport class ControllerInfoFile extends NVMFile {\n\tpublic constructor(\n\t\toptions: NVMFileDeserializationOptions | ControllerInfoFileOptions,\n\t) {\n\t\tsuper(options);\n\t\tif (gotDeserializationOptions(options)) {\n\t\t\tthis.homeId = this.payload.subarray(0, 4);\n\t\t\tif (this.payload.length === 13) {\n\t\t\t\tthis.nodeId = this.payload[4];\n\t\t\t\tthis.lastNodeId = this.payload[5];\n\t\t\t\tthis.staticControllerNodeId = this.payload[6];\n\t\t\t\tthis.sucLastIndex = this.payload[7];\n\t\t\t\tthis.controllerConfiguration = this.payload[8];\n\t\t\t\tthis.sucAwarenessPushNeeded = this.payload[9];\n\t\t\t\tthis.maxNodeId = this.payload[10];\n\t\t\t\tthis.reservedId = this.payload[11];\n\t\t\t\tthis.systemState = this.payload[12];\n\t\t\t} else if (this.payload.length === 22) {\n\t\t\t\tthis.nodeId = this.payload.readUInt16LE(4);\n\t\t\t\tthis.staticControllerNodeId = this.payload.readUInt16LE(6);\n\t\t\t\tthis.lastNodeIdLR = this.payload.readUInt16LE(8);\n\t\t\t\tthis.lastNodeId = this.payload[10];\n\t\t\t\tthis.sucLastIndex = this.payload[11];\n\t\t\t\tthis.maxNodeIdLR = this.payload.readUInt16LE(12);\n\t\t\t\tthis.maxNodeId = this.payload[14];\n\t\t\t\tthis.controllerConfiguration = this.payload[15];\n\t\t\t\tthis.reservedIdLR = this.payload.readUInt16LE(16);\n\t\t\t\tthis.reservedId = this.payload[18];\n\t\t\t\tthis.systemState = this.payload[19];\n\t\t\t\tthis.primaryLongRangeChannelId = this.payload[20];\n\t\t\t\tthis.dcdcConfig = this.payload[21];\n\t\t\t} else {\n\t\t\t\tthrow new ZWaveError(\n\t\t\t\t\t`Unsupported payload length`,\n\t\t\t\t\tZWaveErrorCodes.NVM_InvalidFormat,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.homeId = Bytes.view(options.homeId);\n\t\t\tthis.nodeId = options.nodeId;\n\t\t\tthis.lastNodeId = options.lastNodeId;\n\t\t\tthis.staticControllerNodeId = options.staticControllerNodeId;\n\t\t\tthis.sucLastIndex = options.sucLastIndex;\n\t\t\tthis.controllerConfiguration = options.controllerConfiguration;\n\t\t\tthis.maxNodeId = options.maxNodeId;\n\t\t\tthis.reservedId = options.reservedId;\n\t\t\tthis.systemState = options.systemState;\n\t\t\tif (\"lastNodeIdLR\" in options) {\n\t\t\t\tthis.lastNodeIdLR = options.lastNodeIdLR;\n\t\t\t\tthis.maxNodeIdLR = options.maxNodeIdLR;\n\t\t\t\tthis.reservedIdLR = options.reservedIdLR;\n\t\t\t\tthis.primaryLongRangeChannelId =\n\t\t\t\t\toptions.primaryLongRangeChannelId;\n\t\t\t\tthis.dcdcConfig = options.dcdcConfig;\n\t\t\t} else {\n\t\t\t\tthis.sucAwarenessPushNeeded = options.sucAwarenessPushNeeded;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic homeId: BytesView;\n\tpublic nodeId: number;\n\tpublic lastNodeId: number;\n\tpublic staticControllerNodeId: number;\n\tpublic sucLastIndex: number;\n\tpublic controllerConfiguration: number; // TODO: Figure out what this is\n\tpublic sucAwarenessPushNeeded?: number;\n\tpublic maxNodeId: number;\n\tpublic reservedId: number;\n\tpublic systemState: number;\n\tpublic lastNodeIdLR?: number;\n\tpublic maxNodeIdLR?: number;\n\tpublic reservedIdLR?: number;\n\tpublic primaryLongRangeChannelId?: number;\n\tpublic dcdcConfig?: number;\n\n\tpublic serialize(): NVM3Object & { data: Bytes } {\n\t\tif (this.lastNodeIdLR != undefined) {\n\t\t\tthis.payload = new Bytes(22);\n\t\t\tthis.payload.set(this.homeId, 0);\n\t\t\tthis.payload.writeUInt16LE(this.nodeId, 4);\n\t\t\tthis.payload.writeUInt16LE(this.staticControllerNodeId, 6);\n\t\t\tthis.payload.writeUInt16LE(this.lastNodeIdLR, 8);\n\t\t\tthis.payload[10] = this.lastNodeId;\n\t\t\tthis.payload[11] = this.sucLastIndex;\n\t\t\tthis.payload.writeUInt16LE(this.maxNodeIdLR!, 12);\n\t\t\tthis.payload[14] = this.maxNodeId;\n\t\t\tthis.payload[15] = this.controllerConfiguration;\n\t\t\tthis.payload.writeUInt16LE(this.reservedIdLR!, 16);\n\t\t\tthis.payload[18] = this.reservedId;\n\t\t\tthis.payload[19] = this.systemState;\n\t\t\tthis.payload[20] = this.primaryLongRangeChannelId!;\n\t\t\tthis.payload[21] = this.dcdcConfig!;\n\t\t} else {\n\t\t\t// V0\n\t\t\tthis.payload = Bytes.concat([\n\t\t\t\tthis.homeId,\n\t\t\t\tBytes.from([\n\t\t\t\t\tthis.nodeId,\n\t\t\t\t\tthis.lastNodeId,\n\t\t\t\t\tthis.staticControllerNodeId,\n\t\t\t\t\tthis.sucLastIndex,\n\t\t\t\t\tthis.controllerConfiguration,\n\t\t\t\t\tthis.sucAwarenessPushNeeded ?? 0,\n\t\t\t\t\tthis.maxNodeId,\n\t\t\t\t\tthis.reservedId,\n\t\t\t\t\tthis.systemState,\n\t\t\t\t]),\n\t\t\t]);\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 stripUndefined({\n\t\t\t...super.toJSON(),\n\t\t\thomeId: buffer2hex(this.homeId),\n\t\t\tnodeId: this.nodeId,\n\t\t\tlastNodeId: this.lastNodeId,\n\t\t\tstaticControllerNodeId: this.staticControllerNodeId,\n\t\t\tsucLastIndex: this.sucLastIndex,\n\t\t\tcontrollerConfiguration: this.controllerConfiguration,\n\t\t\tsucAwarenessPushNeeded: this.sucAwarenessPushNeeded,\n\t\t\tmaxNodeId: this.maxNodeId,\n\t\t\treservedId: this.reservedId,\n\t\t\tsystemState: this.systemState,\n\t\t\tlastNodeIdLR: this.lastNodeIdLR,\n\t\t\tmaxNodeIdLR: this.maxNodeIdLR,\n\t\t\treservedIdLR: this.reservedIdLR,\n\t\t\tprimaryLongRangeChannelId: this.primaryLongRangeChannelId,\n\t\t\tdcdcConfig: this.dcdcConfig,\n\t\t});\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAA4D;AAC5D,oBAAkD;AAElD,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,uBAAuB;IAIvB,sBAAkB,MAAA;8BAF9B,0BAAU,oBAAoB,OAC9B,2BAAW,UAAU,CAAC;;;;oBACiB;0CAAA,YAAO;WAAA;;;;;;;;AAA/C,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,SAAkE;AAElE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,aAAK,SAAS,KAAK,QAAQ,SAAS,GAAG,CAAC;AACxC,YAAI,KAAK,QAAQ,WAAW,IAAI;AAC/B,eAAK,SAAS,KAAK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MAAM;QAC9B,QAAQ,KAAK;QACb,YAAY,KAAK;QACjB,wBAAwB,KAAK;QAC7B,cAAc,KAAK;QACnB,yBAAyB,KAAK;QAC9B,wBAAwB,KAAK;QAC7B,WAAW,KAAK;QAChB,YAAY,KAAK;QACjB,aAAa,KAAK;QAClB,cAAc,KAAK;QACnB,aAAa,KAAK;QAClB,cAAc,KAAK;QACnB,2BAA2B,KAAK;QAChC,YAAY,KAAK;OACjB;IACF;;;;",
|
|
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, 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// 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"],
|
|
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/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
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAYO;AACP,oBAA4C;AAE5C,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,wBAAwB;AAC9B,MAAM,2BAA2B;AACxC,MAAM,gBAAgB,IAAI,IAAI;AAC9B,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,gBAAgB,IAAI,WAAW,aAAa,EAAE,KAAK,mBAAmB;AAY5E,SAAS,cACR,QACA,QACA,QAAc;AAEd,QAAM,EAAE,wBAAwB,GAAG,aAAY,QAAK,mCACnD,QACA,MAAM;AAEP,QAAM,qBAAqB,OAAO,SAAS,CAAC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,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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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,0BAA0B;AAMhC,MAAM,yBAAyB;AAChC,SAAU,2BAA2B,QAAc;AACxD,SAAO,yBAAyB,SAAS;AAC1C;AAFgB;IASH,oBAAgB,MAAA;8BAL5B,0BACA,CAAC,OACA,MAAM,0BAA0B,KAAK,yBAAyB,qBAAS,OAExE,2BAAW,UAAU,CAAC;;;;oBACe;wCAAA,YAAO;WAAA;;;;;;;;AAA7C,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,SAAgE;AAEhE,YAAM,OAAO;AACb,cAAI,0CAA0B,OAAO,GAAG;AACvC,cAAM,SAAS,KAAK,SAAS,yBAAyB;AACtD,cAAM,UAAM,8BAAW,KAAK,SA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AAM,WAAO,8BACZ,KAAK,SACL,SAAS,4BAAgB,CAAC;AAG3B,eAAK,YAAY,KAAK,EAAE,QAAQ,KAAK,KAAI,CAAE;QAC5C;MACD,OAAO;AACN,aAAK,cAAc,QAAQ;MAC5B;IACD;IAEO;IAEA,YAAS;AAEf,WAAK,YAAY,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;AACnD,YAAM,YAAY,KAAK,YAAY,CAAC,EAAE;AACtC,WAAK,SAAS,2BAA2B,SAAS;AAElD,WAAK,UAAU,IAAI,oBAAM,0BAA0B,iCAAe,EAChE,KAAK,uCAAqB;AAE5B,YAAM,gBACL,KAAK,OAAO,YAAY,KAAK,uBAAuB,IACjD,0BACD;AAEH,iBAAW,cAAc,KAAK,aAAa;AAC1C,cAAM,UAAU,WAAW,SAAS,iBACjC;AACH,cAAM,SAAS,oBAAM,OAAO;cAC3B,+BAAY,WAAW,GAAG;cAC1B,+BAAY,WAAW,IAAI;SAC3B;AACD,aAAK,QAAQ,IAAI,QAAQ,MAAM;MAChC;AAEA,aAAO,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;AACvD,4BAIO;AAEP,qBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,0BAA0B;AAMhC,MAAM,2BAA2B;IAI3B,0BAAsB,MAAA;8BAFlC,0BAAU,wBAAwB,OAClC,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,+BAAiB,SAAS;AACrD,gBAAM,SAAS,QAAQ;AACvB,gBAAM,kBAAc,2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;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(),
|