@zwave-js/nvmedit 13.3.0 → 13.5.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.
Files changed (235) hide show
  1. package/build/cli.js +6 -6
  2. package/build/cli.js.map +1 -1
  3. package/build/convert.d.ts +15 -14
  4. package/build/convert.d.ts.map +1 -1
  5. package/build/convert.js +647 -389
  6. package/build/convert.js.map +1 -1
  7. package/build/index.d.ts +12 -4
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +20 -2
  10. package/build/index.js.map +1 -1
  11. package/build/index_safe.d.ts +7 -4
  12. package/build/index_safe.d.ts.map +1 -1
  13. package/build/index_safe.js +4 -2
  14. package/build/index_safe.js.map +1 -1
  15. package/build/lib/NVM3.d.ts +53 -0
  16. package/build/lib/NVM3.d.ts.map +1 -0
  17. package/build/lib/NVM3.js +650 -0
  18. package/build/lib/NVM3.js.map +1 -0
  19. package/build/lib/NVM500.d.ts +46 -0
  20. package/build/lib/NVM500.d.ts.map +1 -0
  21. package/build/lib/NVM500.js +413 -0
  22. package/build/lib/NVM500.js.map +1 -0
  23. package/build/lib/common/definitions.d.ts +138 -0
  24. package/build/lib/common/definitions.d.ts.map +1 -0
  25. package/build/lib/common/definitions.js +11 -0
  26. package/build/lib/common/definitions.js.map +1 -0
  27. package/build/lib/common/routeCache.d.ts +18 -0
  28. package/build/lib/common/routeCache.d.ts.map +1 -0
  29. package/build/lib/common/routeCache.js +56 -0
  30. package/build/lib/common/routeCache.js.map +1 -0
  31. package/build/lib/common/sucUpdateEntry.d.ts +10 -0
  32. package/build/lib/common/sucUpdateEntry.d.ts.map +1 -0
  33. package/build/lib/common/sucUpdateEntry.js +35 -0
  34. package/build/lib/common/sucUpdateEntry.js.map +1 -0
  35. package/build/lib/common/utils.d.ts +9 -0
  36. package/build/lib/common/utils.d.ts.map +1 -0
  37. package/build/lib/common/utils.js +52 -0
  38. package/build/lib/common/utils.js.map +1 -0
  39. package/build/lib/io/BufferedNVMReader.d.ts +21 -0
  40. package/build/lib/io/BufferedNVMReader.d.ts.map +1 -0
  41. package/build/lib/io/BufferedNVMReader.js +79 -0
  42. package/build/lib/io/BufferedNVMReader.js.map +1 -0
  43. package/build/lib/io/NVMFileIO.d.ts +24 -0
  44. package/build/lib/io/NVMFileIO.d.ts.map +1 -0
  45. package/build/lib/io/NVMFileIO.js +86 -0
  46. package/build/lib/io/NVMFileIO.js.map +1 -0
  47. package/build/lib/io/NVMMemoryIO.d.ts +20 -0
  48. package/build/lib/io/NVMMemoryIO.d.ts.map +1 -0
  49. package/build/lib/io/NVMMemoryIO.js +48 -0
  50. package/build/lib/io/NVMMemoryIO.js.map +1 -0
  51. package/build/lib/nvm3/adapter.d.ts +33 -0
  52. package/build/lib/nvm3/adapter.d.ts.map +1 -0
  53. package/build/lib/nvm3/adapter.js +904 -0
  54. package/build/lib/nvm3/adapter.js.map +1 -0
  55. package/build/lib/nvm3/consts.d.ts.map +1 -0
  56. package/build/lib/nvm3/consts.js.map +1 -0
  57. package/build/{files → lib/nvm3/files}/ApplicationCCsFile.d.ts +5 -3
  58. package/build/lib/nvm3/files/ApplicationCCsFile.d.ts.map +1 -0
  59. package/build/{files → lib/nvm3/files}/ApplicationCCsFile.js +4 -3
  60. package/build/lib/nvm3/files/ApplicationCCsFile.js.map +1 -0
  61. package/build/{files → lib/nvm3/files}/ApplicationDataFile.d.ts +4 -4
  62. package/build/lib/nvm3/files/ApplicationDataFile.d.ts.map +1 -0
  63. package/build/{files → lib/nvm3/files}/ApplicationDataFile.js +7 -6
  64. package/build/lib/nvm3/files/ApplicationDataFile.js.map +1 -0
  65. package/build/{files → lib/nvm3/files}/ApplicationNameFile.d.ts +5 -3
  66. package/build/lib/nvm3/files/ApplicationNameFile.d.ts.map +1 -0
  67. package/build/{files → lib/nvm3/files}/ApplicationNameFile.js +4 -3
  68. package/build/lib/nvm3/files/ApplicationNameFile.js.map +1 -0
  69. package/build/{files → lib/nvm3/files}/ApplicationRFConfigFile.d.ts +5 -3
  70. package/build/lib/nvm3/files/ApplicationRFConfigFile.d.ts.map +1 -0
  71. package/build/{files → lib/nvm3/files}/ApplicationRFConfigFile.js +4 -3
  72. package/build/lib/nvm3/files/ApplicationRFConfigFile.js.map +1 -0
  73. package/build/{files → lib/nvm3/files}/ApplicationTypeFile.d.ts +5 -3
  74. package/build/lib/nvm3/files/ApplicationTypeFile.d.ts.map +1 -0
  75. package/build/{files → lib/nvm3/files}/ApplicationTypeFile.js +4 -3
  76. package/build/lib/nvm3/files/ApplicationTypeFile.js.map +1 -0
  77. package/build/{files → lib/nvm3/files}/ControllerInfoFile.d.ts +5 -3
  78. package/build/lib/nvm3/files/ControllerInfoFile.d.ts.map +1 -0
  79. package/build/{files → lib/nvm3/files}/ControllerInfoFile.js +4 -3
  80. package/build/lib/nvm3/files/ControllerInfoFile.js.map +1 -0
  81. package/build/{files → lib/nvm3/files}/NVMFile.d.ts +18 -7
  82. package/build/lib/nvm3/files/NVMFile.d.ts.map +1 -0
  83. package/build/{files → lib/nvm3/files}/NVMFile.js +45 -31
  84. package/build/lib/nvm3/files/NVMFile.js.map +1 -0
  85. package/build/{files → lib/nvm3/files}/NodeInfoFiles.d.ts +10 -4
  86. package/build/lib/nvm3/files/NodeInfoFiles.d.ts.map +1 -0
  87. package/build/{files → lib/nvm3/files}/NodeInfoFiles.js +6 -3
  88. package/build/lib/nvm3/files/NodeInfoFiles.js.map +1 -0
  89. package/build/{files → lib/nvm3/files}/ProtocolNodeMaskFiles.d.ts +22 -15
  90. package/build/lib/nvm3/files/ProtocolNodeMaskFiles.d.ts.map +1 -0
  91. package/build/{files → lib/nvm3/files}/ProtocolNodeMaskFiles.js +50 -30
  92. package/build/lib/nvm3/files/ProtocolNodeMaskFiles.js.map +1 -0
  93. package/build/{files → lib/nvm3/files}/RouteCacheFiles.d.ts +8 -17
  94. package/build/lib/nvm3/files/RouteCacheFiles.d.ts.map +1 -0
  95. package/build/{files → lib/nvm3/files}/RouteCacheFiles.js +16 -64
  96. package/build/lib/nvm3/files/RouteCacheFiles.js.map +1 -0
  97. package/build/{files → lib/nvm3/files}/SUCUpdateEntriesFile.d.ts +10 -13
  98. package/build/lib/nvm3/files/SUCUpdateEntriesFile.d.ts.map +1 -0
  99. package/build/{files → lib/nvm3/files}/SUCUpdateEntriesFile.js +15 -42
  100. package/build/lib/nvm3/files/SUCUpdateEntriesFile.js.map +1 -0
  101. package/build/{files → lib/nvm3/files}/VersionFiles.d.ts +7 -5
  102. package/build/lib/nvm3/files/VersionFiles.d.ts.map +1 -0
  103. package/build/{files → lib/nvm3/files}/VersionFiles.js +10 -7
  104. package/build/lib/nvm3/files/VersionFiles.js.map +1 -0
  105. package/build/{files → lib/nvm3/files}/index.d.ts +1 -0
  106. package/build/lib/nvm3/files/index.d.ts.map +1 -0
  107. package/build/{files → lib/nvm3/files}/index.js +1 -0
  108. package/build/lib/nvm3/files/index.js.map +1 -0
  109. package/build/lib/nvm3/object.d.ts +29 -0
  110. package/build/lib/nvm3/object.d.ts.map +1 -0
  111. package/build/lib/nvm3/object.js +118 -0
  112. package/build/lib/nvm3/object.js.map +1 -0
  113. package/build/{nvm3 → lib/nvm3}/page.d.ts +1 -5
  114. package/build/lib/nvm3/page.d.ts.map +1 -0
  115. package/build/lib/nvm3/page.js +37 -0
  116. package/build/lib/nvm3/page.js.map +1 -0
  117. package/build/{nvm3 → lib/nvm3}/utils.d.ts +2 -4
  118. package/build/lib/nvm3/utils.d.ts.map +1 -0
  119. package/build/lib/nvm3/utils.js +143 -0
  120. package/build/lib/nvm3/utils.js.map +1 -0
  121. package/build/lib/nvm500/EntryParsers.d.ts.map +1 -0
  122. package/build/lib/nvm500/EntryParsers.js.map +1 -0
  123. package/build/lib/nvm500/adapter.d.ts +22 -0
  124. package/build/lib/nvm500/adapter.d.ts.map +1 -0
  125. package/build/lib/nvm500/adapter.js +371 -0
  126. package/build/lib/nvm500/adapter.js.map +1 -0
  127. package/build/lib/nvm500/impls/Bridge_6_6x.d.ts +3 -0
  128. package/build/lib/nvm500/impls/Bridge_6_6x.d.ts.map +1 -0
  129. package/build/{nvm500/parsers → lib/nvm500/impls}/Bridge_6_6x.js +1 -1
  130. package/build/lib/nvm500/impls/Bridge_6_6x.js.map +1 -0
  131. package/build/lib/nvm500/impls/Bridge_6_7x.d.ts +3 -0
  132. package/build/lib/nvm500/impls/Bridge_6_7x.d.ts.map +1 -0
  133. package/build/{nvm500/parsers → lib/nvm500/impls}/Bridge_6_7x.js +1 -1
  134. package/build/lib/nvm500/impls/Bridge_6_7x.js.map +1 -0
  135. package/build/lib/nvm500/impls/Bridge_6_8x.d.ts +3 -0
  136. package/build/lib/nvm500/impls/Bridge_6_8x.d.ts.map +1 -0
  137. package/build/{nvm500/parsers → lib/nvm500/impls}/Bridge_6_8x.js +1 -1
  138. package/build/lib/nvm500/impls/Bridge_6_8x.js.map +1 -0
  139. package/build/lib/nvm500/impls/Static_6_6x.d.ts +3 -0
  140. package/build/lib/nvm500/impls/Static_6_6x.d.ts.map +1 -0
  141. package/build/{nvm500/parsers → lib/nvm500/impls}/Static_6_6x.js +1 -1
  142. package/build/lib/nvm500/impls/Static_6_6x.js.map +1 -0
  143. package/build/lib/nvm500/impls/Static_6_7x.d.ts +3 -0
  144. package/build/lib/nvm500/impls/Static_6_7x.d.ts.map +1 -0
  145. package/build/{nvm500/parsers → lib/nvm500/impls}/Static_6_7x.js +1 -1
  146. package/build/lib/nvm500/impls/Static_6_7x.js.map +1 -0
  147. package/build/lib/nvm500/impls/Static_6_8x.d.ts +3 -0
  148. package/build/lib/nvm500/impls/Static_6_8x.d.ts.map +1 -0
  149. package/build/{nvm500/parsers → lib/nvm500/impls}/Static_6_8x.js +1 -1
  150. package/build/lib/nvm500/impls/Static_6_8x.js.map +1 -0
  151. package/build/lib/nvm500/impls/index.d.ts +2 -0
  152. package/build/lib/nvm500/impls/index.d.ts.map +1 -0
  153. package/build/lib/nvm500/impls/index.js +18 -0
  154. package/build/lib/nvm500/impls/index.js.map +1 -0
  155. package/build/{nvm500 → lib/nvm500}/shared.d.ts +19 -2
  156. package/build/lib/nvm500/shared.d.ts.map +1 -0
  157. package/build/{nvm500 → lib/nvm500}/shared.js +19 -1
  158. package/build/lib/nvm500/shared.js.map +1 -0
  159. package/build/nvm500/NVMParser.d.ts +5 -36
  160. package/build/nvm500/NVMParser.d.ts.map +1 -1
  161. package/build/nvm500/NVMParser.js +0 -524
  162. package/build/nvm500/NVMParser.js.map +1 -1
  163. package/package.json +6 -6
  164. package/build/files/ApplicationCCsFile.d.ts.map +0 -1
  165. package/build/files/ApplicationCCsFile.js.map +0 -1
  166. package/build/files/ApplicationDataFile.d.ts.map +0 -1
  167. package/build/files/ApplicationDataFile.js.map +0 -1
  168. package/build/files/ApplicationNameFile.d.ts.map +0 -1
  169. package/build/files/ApplicationNameFile.js.map +0 -1
  170. package/build/files/ApplicationRFConfigFile.d.ts.map +0 -1
  171. package/build/files/ApplicationRFConfigFile.js.map +0 -1
  172. package/build/files/ApplicationTypeFile.d.ts.map +0 -1
  173. package/build/files/ApplicationTypeFile.js.map +0 -1
  174. package/build/files/ControllerInfoFile.d.ts.map +0 -1
  175. package/build/files/ControllerInfoFile.js.map +0 -1
  176. package/build/files/NVMFile.d.ts.map +0 -1
  177. package/build/files/NVMFile.js.map +0 -1
  178. package/build/files/NodeInfoFiles.d.ts.map +0 -1
  179. package/build/files/NodeInfoFiles.js.map +0 -1
  180. package/build/files/ProtocolNodeMaskFiles.d.ts.map +0 -1
  181. package/build/files/ProtocolNodeMaskFiles.js.map +0 -1
  182. package/build/files/RouteCacheFiles.d.ts.map +0 -1
  183. package/build/files/RouteCacheFiles.js.map +0 -1
  184. package/build/files/SUCUpdateEntriesFile.d.ts.map +0 -1
  185. package/build/files/SUCUpdateEntriesFile.js.map +0 -1
  186. package/build/files/VersionFiles.d.ts.map +0 -1
  187. package/build/files/VersionFiles.js.map +0 -1
  188. package/build/files/index.d.ts.map +0 -1
  189. package/build/files/index.js.map +0 -1
  190. package/build/nvm3/consts.d.ts.map +0 -1
  191. package/build/nvm3/consts.js.map +0 -1
  192. package/build/nvm3/nvm.d.ts +0 -31
  193. package/build/nvm3/nvm.d.ts.map +0 -1
  194. package/build/nvm3/nvm.js +0 -184
  195. package/build/nvm3/nvm.js.map +0 -1
  196. package/build/nvm3/object.d.ts +0 -25
  197. package/build/nvm3/object.d.ts.map +0 -1
  198. package/build/nvm3/object.js +0 -197
  199. package/build/nvm3/object.js.map +0 -1
  200. package/build/nvm3/page.d.ts.map +0 -1
  201. package/build/nvm3/page.js +0 -129
  202. package/build/nvm3/page.js.map +0 -1
  203. package/build/nvm3/utils.d.ts.map +0 -1
  204. package/build/nvm3/utils.js +0 -103
  205. package/build/nvm3/utils.js.map +0 -1
  206. package/build/nvm500/EntryParsers.d.ts.map +0 -1
  207. package/build/nvm500/EntryParsers.js.map +0 -1
  208. package/build/nvm500/parsers/Bridge_6_6x.d.ts +0 -3
  209. package/build/nvm500/parsers/Bridge_6_6x.d.ts.map +0 -1
  210. package/build/nvm500/parsers/Bridge_6_6x.js.map +0 -1
  211. package/build/nvm500/parsers/Bridge_6_7x.d.ts +0 -3
  212. package/build/nvm500/parsers/Bridge_6_7x.d.ts.map +0 -1
  213. package/build/nvm500/parsers/Bridge_6_7x.js.map +0 -1
  214. package/build/nvm500/parsers/Bridge_6_8x.d.ts +0 -3
  215. package/build/nvm500/parsers/Bridge_6_8x.d.ts.map +0 -1
  216. package/build/nvm500/parsers/Bridge_6_8x.js.map +0 -1
  217. package/build/nvm500/parsers/Static_6_6x.d.ts +0 -3
  218. package/build/nvm500/parsers/Static_6_6x.d.ts.map +0 -1
  219. package/build/nvm500/parsers/Static_6_6x.js.map +0 -1
  220. package/build/nvm500/parsers/Static_6_7x.d.ts +0 -3
  221. package/build/nvm500/parsers/Static_6_7x.d.ts.map +0 -1
  222. package/build/nvm500/parsers/Static_6_7x.js.map +0 -1
  223. package/build/nvm500/parsers/Static_6_8x.d.ts +0 -3
  224. package/build/nvm500/parsers/Static_6_8x.d.ts.map +0 -1
  225. package/build/nvm500/parsers/Static_6_8x.js.map +0 -1
  226. package/build/nvm500/shared.d.ts.map +0 -1
  227. package/build/nvm500/shared.js.map +0 -1
  228. package/build/shared.d.ts +0 -2
  229. package/build/shared.d.ts.map +0 -1
  230. package/build/shared.js +0 -3
  231. package/build/shared.js.map +0 -1
  232. /package/build/{nvm3 → lib/nvm3}/consts.d.ts +0 -0
  233. /package/build/{nvm3 → lib/nvm3}/consts.js +0 -0
  234. /package/build/{nvm500 → lib/nvm500}/EntryParsers.d.ts +0 -0
  235. /package/build/{nvm500 → lib/nvm500}/EntryParsers.js +0 -0
@@ -0,0 +1,904 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NVM3Adapter = void 0;
4
+ const core_1 = require("@zwave-js/core");
5
+ const shared_1 = require("@zwave-js/shared");
6
+ const helpers_1 = require("alcalzone-shared/helpers");
7
+ const consts_1 = require("../../consts");
8
+ const files_1 = require("./files");
9
+ const DEFAULT_FILE_VERSION = "7.0.0";
10
+ class NVM3Adapter {
11
+ constructor(nvm) {
12
+ this._nvm = nvm;
13
+ }
14
+ _nvm;
15
+ _initialized = false;
16
+ _protocolInfo;
17
+ _applicationInfo;
18
+ /** A list of pending changes that haven't been written to the NVM yet. `null` indicates a deleted entry. */
19
+ _pendingChanges = new Map();
20
+ getFileVersion(fileId) {
21
+ if (fileId === files_1.ProtocolVersionFileID
22
+ || fileId === files_1.ApplicationVersionFileID
23
+ || fileId === files_1.ApplicationVersionFile800ID) {
24
+ return DEFAULT_FILE_VERSION;
25
+ }
26
+ const section = (0, files_1.getNVMSectionByFileID)(fileId);
27
+ if (section === "application") {
28
+ return this._applicationInfo?.version ?? DEFAULT_FILE_VERSION;
29
+ }
30
+ else if (section === "protocol") {
31
+ return this._protocolInfo?.version ?? DEFAULT_FILE_VERSION;
32
+ }
33
+ return DEFAULT_FILE_VERSION;
34
+ }
35
+ async init() {
36
+ if (!this._protocolInfo) {
37
+ const protocolVersionFile = await this._getFile(files_1.ProtocolVersionFileID, true);
38
+ if (protocolVersionFile) {
39
+ const version = `${protocolVersionFile.major}.${protocolVersionFile.minor}.${protocolVersionFile.patch}`;
40
+ this._protocolInfo = {
41
+ version,
42
+ format: protocolVersionFile.format,
43
+ };
44
+ }
45
+ }
46
+ if (!this._applicationInfo) {
47
+ const applicationVersionFile700 = await this._getFile(files_1.ApplicationVersionFileID, true);
48
+ const applicationVersionFile800 = await this._getFile(files_1.ApplicationVersionFile800ID, true);
49
+ const applicationVersionFile = applicationVersionFile700
50
+ ?? applicationVersionFile800;
51
+ if (applicationVersionFile) {
52
+ const version = `${applicationVersionFile.major}.${applicationVersionFile.minor}.${applicationVersionFile.patch}`;
53
+ this._applicationInfo = {
54
+ version,
55
+ format: applicationVersionFile.format,
56
+ };
57
+ }
58
+ }
59
+ this._initialized = true;
60
+ }
61
+ /** Adds a complete file to the list of pending changes */
62
+ setFile(file) {
63
+ const { key, data } = file.serialize();
64
+ this._pendingChanges.set(key, data);
65
+ }
66
+ async hasFile(fileId) {
67
+ if (!this._initialized)
68
+ await this.init();
69
+ if (this._pendingChanges.has(fileId)) {
70
+ return this._pendingChanges.get(fileId) !== null;
71
+ }
72
+ else {
73
+ return this._nvm.has(fileId);
74
+ }
75
+ }
76
+ async _getFile(fileId, skipInit = false) {
77
+ if (!skipInit && !this._initialized)
78
+ await this.init();
79
+ // Prefer pending changes over the actual NVM, so changes can be composed
80
+ let data;
81
+ if (this._pendingChanges.has(fileId)) {
82
+ data = this._pendingChanges.get(fileId);
83
+ }
84
+ else {
85
+ data = await this._nvm.get(fileId);
86
+ }
87
+ if (!data)
88
+ return;
89
+ const fileVersion = this.getFileVersion(fileId);
90
+ return files_1.NVMFile.from(fileId, data, fileVersion);
91
+ }
92
+ async _expectFile(fileId, skipInit = false) {
93
+ const file = await this._getFile(fileId, skipInit);
94
+ if (!file) {
95
+ throw new core_1.ZWaveError(`NVM file ${(0, shared_1.num2hex)(fileId)} not found`, core_1.ZWaveErrorCodes.NVM_ObjectNotFound);
96
+ }
97
+ return file;
98
+ }
99
+ getFile(fileId, required) {
100
+ if (required) {
101
+ return this._expectFile(fileId);
102
+ }
103
+ else {
104
+ return this._getFile(fileId);
105
+ }
106
+ }
107
+ get(property, required) {
108
+ if (property.domain === "controller") {
109
+ return this.getControllerNVMProperty(property, !!required);
110
+ }
111
+ else if (property.domain === "lrnode") {
112
+ return this.getLRNodeNVMProperty(property, !!required);
113
+ }
114
+ else {
115
+ return this.getNodeNVMProperty(property, !!required);
116
+ }
117
+ }
118
+ async getControllerNVMProperty(property, required) {
119
+ const getFile = (fileId) => {
120
+ if (required) {
121
+ return this._expectFile(fileId);
122
+ }
123
+ else {
124
+ return this._getFile(fileId);
125
+ }
126
+ };
127
+ switch (property.type) {
128
+ case "protocolVersion": {
129
+ const file = await getFile(files_1.ProtocolVersionFileID);
130
+ if (!file)
131
+ return;
132
+ return `${file.major}.${file.minor}.${file.patch}`;
133
+ }
134
+ case "protocolFileFormat": {
135
+ const file = await getFile(files_1.ProtocolVersionFileID);
136
+ return file?.format;
137
+ }
138
+ case "applicationVersion":
139
+ case "applicationFileFormat": {
140
+ const file700 = await this._getFile(files_1.ApplicationVersionFileID);
141
+ const file800 = await this._getFile(files_1.ApplicationVersionFile800ID);
142
+ const file = file700 ?? file800;
143
+ if (!file) {
144
+ if (required) {
145
+ throw new core_1.ZWaveError("ApplicationVersionFile not found!", core_1.ZWaveErrorCodes.NVM_ObjectNotFound);
146
+ }
147
+ else {
148
+ return;
149
+ }
150
+ }
151
+ if (property.type === "applicationVersion") {
152
+ return `${file.major}.${file.minor}.${file.patch}`;
153
+ }
154
+ else if (property.type === "applicationFileFormat") {
155
+ return file?.format;
156
+ }
157
+ }
158
+ case "applicationData": {
159
+ const file = await getFile(files_1.ApplicationDataFileID);
160
+ return file?.applicationData;
161
+ }
162
+ case "applicationName": {
163
+ const file = await getFile(files_1.ApplicationNameFileID);
164
+ return file?.name;
165
+ }
166
+ case "homeId":
167
+ case "nodeId":
168
+ case "lastNodeId":
169
+ case "staticControllerNodeId":
170
+ case "sucLastIndex":
171
+ case "controllerConfiguration":
172
+ case "sucAwarenessPushNeeded":
173
+ case "maxNodeId":
174
+ case "reservedId":
175
+ case "systemState":
176
+ case "lastNodeIdLR":
177
+ case "maxNodeIdLR":
178
+ case "reservedIdLR":
179
+ case "primaryLongRangeChannelId":
180
+ case "dcdcConfig": {
181
+ const file = await getFile(files_1.ControllerInfoFileID);
182
+ return file?.[property.type];
183
+ }
184
+ case "includedInsecurely":
185
+ case "includedSecurelyInsecureCCs":
186
+ case "includedSecurelySecureCCs": {
187
+ const file = await getFile(files_1.ApplicationCCsFileID);
188
+ return file?.[property.type];
189
+ }
190
+ case "rfRegion":
191
+ case "txPower":
192
+ case "measured0dBm":
193
+ case "enablePTI":
194
+ case "maxTXPower":
195
+ case "nodeIdType": {
196
+ const file = await getFile(files_1.ApplicationRFConfigFileID);
197
+ return file?.[property.type];
198
+ }
199
+ case "isListening":
200
+ case "optionalFunctionality":
201
+ case "genericDeviceClass":
202
+ case "specificDeviceClass": {
203
+ const file = await getFile(files_1.ApplicationTypeFileID);
204
+ return file?.[property.type];
205
+ }
206
+ case "preferredRepeaters": {
207
+ const file = await getFile(files_1.ProtocolPreferredRepeatersFileID);
208
+ return file?.nodeIds;
209
+ }
210
+ case "appRouteLock": {
211
+ const file = await getFile(files_1.ProtocolAppRouteLockNodeMaskFileID);
212
+ return file?.nodeIds;
213
+ }
214
+ case "routeSlaveSUC": {
215
+ const file = await getFile(files_1.ProtocolRouteSlaveSUCNodeMaskFileID);
216
+ return file?.nodeIds;
217
+ }
218
+ case "sucPendingUpdate": {
219
+ const file = await getFile(files_1.ProtocolSUCPendingUpdateNodeMaskFileID);
220
+ return file?.nodeIds;
221
+ }
222
+ case "pendingDiscovery": {
223
+ const file = await getFile(files_1.ProtocolPendingDiscoveryNodeMaskFileID);
224
+ return file?.nodeIds;
225
+ }
226
+ case "nodeIds": {
227
+ const file = await getFile(files_1.ProtocolNodeListFileID);
228
+ return file?.nodeIds;
229
+ }
230
+ case "lrNodeIds": {
231
+ const file = await getFile(files_1.ProtocolLRNodeListFileID);
232
+ return file?.nodeIds;
233
+ }
234
+ case "virtualNodeIds": {
235
+ const file = await getFile(files_1.ProtocolVirtualNodeMaskFileID);
236
+ return file?.nodeIds;
237
+ }
238
+ case "sucUpdateEntries": {
239
+ if (this._protocolInfo.format < 5) {
240
+ const file = await getFile(files_1.SUCUpdateEntriesFileIDV0);
241
+ return file?.updateEntries;
242
+ }
243
+ else {
244
+ // V5 has split the entries into multiple files
245
+ const updateEntries = [];
246
+ for (let index = 0; index < consts_1.SUC_MAX_UPDATES; index += files_1.SUC_UPDATES_PER_FILE_V5) {
247
+ // None of the files are required
248
+ const file = await this._getFile((0, files_1.sucUpdateIndexToSUCUpdateEntriesFileIDV5)(index));
249
+ if (!file)
250
+ break;
251
+ updateEntries.push(...file.updateEntries);
252
+ }
253
+ return updateEntries;
254
+ }
255
+ }
256
+ case "learnedHomeId":
257
+ case "commandClasses":
258
+ case "watchdogStarted":
259
+ case "powerLevelNormal":
260
+ case "powerLevelLow":
261
+ case "powerMode":
262
+ case "powerModeExtintEnable":
263
+ case "powerModeWutTimeout":
264
+ // 500 series only, not supported on 700+
265
+ return;
266
+ default:
267
+ (0, helpers_1.assertNever)(property.type);
268
+ }
269
+ }
270
+ async getNodeNVMProperty(property, required) {
271
+ const getFile = (fileId) => {
272
+ if (required) {
273
+ return this._expectFile(fileId);
274
+ }
275
+ else {
276
+ return this._getFile(fileId);
277
+ }
278
+ };
279
+ switch (property.type) {
280
+ case "info": {
281
+ if (this._protocolInfo.format < 1) {
282
+ const file = await getFile((0, files_1.nodeIdToNodeInfoFileIDV0)(property.nodeId));
283
+ return file?.nodeInfo;
284
+ }
285
+ else {
286
+ const file = await getFile((0, files_1.nodeIdToNodeInfoFileIDV1)(property.nodeId));
287
+ return file?.nodeInfos.find((info) => info.nodeId === property.nodeId);
288
+ }
289
+ }
290
+ case "routes": {
291
+ // The existence of routes is stored separately
292
+ const nodeMaskFile = await this.getFile(files_1.ProtocolRouteCacheExistsNodeMaskFileID);
293
+ // If the node is not marked as having routes, don't try to read them
294
+ if (!nodeMaskFile)
295
+ return;
296
+ if (!nodeMaskFile.nodeIdSet.has(property.nodeId))
297
+ return;
298
+ let routeCache;
299
+ if (this._protocolInfo.format < 1) {
300
+ const file = await getFile((0, files_1.nodeIdToRouteCacheFileIDV0)(property.nodeId));
301
+ routeCache = file?.routeCache;
302
+ }
303
+ else {
304
+ const file = await getFile((0, files_1.nodeIdToRouteCacheFileIDV1)(property.nodeId));
305
+ routeCache = file?.routeCaches.find((route) => route.nodeId === property.nodeId);
306
+ }
307
+ if (!routeCache)
308
+ return;
309
+ return {
310
+ lwr: routeCache.lwr,
311
+ nlwr: routeCache.nlwr,
312
+ };
313
+ }
314
+ default:
315
+ (0, helpers_1.assertNever)(property.type);
316
+ }
317
+ }
318
+ async getLRNodeNVMProperty(property, required) {
319
+ const getFile = (fileId) => {
320
+ if (required) {
321
+ return this._expectFile(fileId);
322
+ }
323
+ else {
324
+ return this._getFile(fileId);
325
+ }
326
+ };
327
+ switch (property.type) {
328
+ case "info": {
329
+ const file = await getFile((0, files_1.nodeIdToLRNodeInfoFileIDV5)(property.nodeId));
330
+ return file?.nodeInfos.find((info) => info.nodeId === property.nodeId);
331
+ }
332
+ default:
333
+ (0, helpers_1.assertNever)(property.type);
334
+ }
335
+ }
336
+ async set(property, value) {
337
+ if (!this._initialized)
338
+ await this.init();
339
+ if (property.domain === "controller") {
340
+ return this.setControllerNVMProperty(property, value);
341
+ }
342
+ else if (property.domain === "lrnode") {
343
+ return this.setLRNodeNVMProperty(property, value);
344
+ }
345
+ else {
346
+ return this.setNodeNVMProperty(property, value);
347
+ }
348
+ }
349
+ async setControllerNVMProperty(property, value) {
350
+ function failFileMissing() {
351
+ throw new core_1.ZWaveError("Cannot set property in NVM for non-existing file", core_1.ZWaveErrorCodes.NVM_ObjectNotFound);
352
+ }
353
+ const expectFile = async (fileId) => {
354
+ const file = await this._getFile(fileId);
355
+ if (!file)
356
+ failFileMissing();
357
+ return file;
358
+ };
359
+ const changedFiles = [];
360
+ const deletedFiles = [];
361
+ switch (property.type) {
362
+ case "protocolVersion": {
363
+ const file = await expectFile(files_1.ProtocolVersionFileID);
364
+ const [major, minor, patch] = value.split(".")
365
+ .map((part) => parseInt(part, 10));
366
+ file.major = major;
367
+ file.minor = minor;
368
+ file.patch = patch;
369
+ changedFiles.push(file);
370
+ break;
371
+ }
372
+ case "protocolFileFormat": {
373
+ const file = await expectFile(files_1.ProtocolVersionFileID);
374
+ file.format = value;
375
+ changedFiles.push(file);
376
+ break;
377
+ }
378
+ case "applicationVersion": {
379
+ const file700 = await this._getFile(files_1.ApplicationVersionFileID);
380
+ const file800 = await this._getFile(files_1.ApplicationVersionFile800ID);
381
+ const file = file700 ?? file800;
382
+ if (!file) {
383
+ throw new core_1.ZWaveError("ApplicationVersionFile not found!", core_1.ZWaveErrorCodes.NVM_ObjectNotFound);
384
+ }
385
+ const [major, minor, patch] = value.split(".")
386
+ .map((part) => parseInt(part, 10));
387
+ file.major = major;
388
+ file.minor = minor;
389
+ file.patch = patch;
390
+ changedFiles.push(file);
391
+ break;
392
+ }
393
+ case "applicationFileFormat": {
394
+ const file = await expectFile(files_1.ApplicationVersionFileID);
395
+ file.format = value;
396
+ changedFiles.push(file);
397
+ break;
398
+ }
399
+ case "applicationData": {
400
+ const file = new files_1.ApplicationDataFile({
401
+ applicationData: value,
402
+ fileVersion: this.getFileVersion(files_1.ApplicationDataFileID),
403
+ });
404
+ file.applicationData = value;
405
+ changedFiles.push(file);
406
+ break;
407
+ }
408
+ case "applicationName": {
409
+ const file = new files_1.ApplicationNameFile({
410
+ name: value,
411
+ fileVersion: this.getFileVersion(files_1.ApplicationNameFileID),
412
+ });
413
+ changedFiles.push(file);
414
+ break;
415
+ }
416
+ case "homeId":
417
+ case "nodeId":
418
+ case "lastNodeId":
419
+ case "staticControllerNodeId":
420
+ case "sucLastIndex":
421
+ case "controllerConfiguration":
422
+ case "sucAwarenessPushNeeded":
423
+ case "maxNodeId":
424
+ case "reservedId":
425
+ case "systemState":
426
+ case "lastNodeIdLR":
427
+ case "maxNodeIdLR":
428
+ case "reservedIdLR":
429
+ case "primaryLongRangeChannelId":
430
+ case "dcdcConfig": {
431
+ const file = await expectFile(files_1.ControllerInfoFileID);
432
+ file[property.type] = value;
433
+ changedFiles.push(file);
434
+ break;
435
+ }
436
+ case "includedInsecurely":
437
+ case "includedSecurelyInsecureCCs":
438
+ case "includedSecurelySecureCCs": {
439
+ const file = await expectFile(files_1.ApplicationCCsFileID);
440
+ file[property.type] = value;
441
+ changedFiles.push(file);
442
+ break;
443
+ }
444
+ case "rfRegion":
445
+ case "txPower":
446
+ case "measured0dBm":
447
+ case "enablePTI":
448
+ case "maxTXPower":
449
+ case "nodeIdType": {
450
+ const file = await expectFile(files_1.ApplicationRFConfigFileID);
451
+ file[property.type] = value;
452
+ changedFiles.push(file);
453
+ break;
454
+ }
455
+ case "isListening":
456
+ case "optionalFunctionality":
457
+ case "genericDeviceClass":
458
+ case "specificDeviceClass": {
459
+ const file = await expectFile(files_1.ApplicationTypeFileID);
460
+ file[property.type] = value;
461
+ changedFiles.push(file);
462
+ break;
463
+ }
464
+ case "nodeIds": {
465
+ const file = await this._getFile(files_1.ProtocolNodeListFileID) ?? new files_1.ProtocolNodeListFile({
466
+ nodeIds: [],
467
+ fileVersion: this.getFileVersion(files_1.ProtocolNodeListFileID),
468
+ });
469
+ file.nodeIds = value;
470
+ changedFiles.push(file);
471
+ break;
472
+ }
473
+ case "lrNodeIds": {
474
+ const file = await this._getFile(files_1.ProtocolLRNodeListFileID) ?? new files_1.ProtocolLRNodeListFile({
475
+ nodeIds: [],
476
+ fileVersion: this.getFileVersion(files_1.ProtocolLRNodeListFileID),
477
+ });
478
+ file.nodeIds = value;
479
+ changedFiles.push(file);
480
+ break;
481
+ }
482
+ case "virtualNodeIds": {
483
+ const file = await this._getFile(files_1.ProtocolVirtualNodeMaskFileID) ?? new files_1.ProtocolVirtualNodeMaskFile({
484
+ nodeIds: [],
485
+ fileVersion: this.getFileVersion(files_1.ProtocolVirtualNodeMaskFileID),
486
+ });
487
+ file.nodeIds = value;
488
+ changedFiles.push(file);
489
+ break;
490
+ }
491
+ case "preferredRepeaters": {
492
+ const file = new files_1.ProtocolPreferredRepeatersFile({
493
+ nodeIds: value,
494
+ fileVersion: this.getFileVersion(files_1.ProtocolPreferredRepeatersFileID),
495
+ });
496
+ changedFiles.push(file);
497
+ break;
498
+ }
499
+ case "appRouteLock": {
500
+ const file = new files_1.ProtocolAppRouteLockNodeMaskFile({
501
+ nodeIds: value,
502
+ fileVersion: this.getFileVersion(files_1.ProtocolAppRouteLockNodeMaskFileID),
503
+ });
504
+ changedFiles.push(file);
505
+ break;
506
+ }
507
+ case "routeSlaveSUC": {
508
+ const file = new files_1.ProtocolRouteSlaveSUCNodeMaskFile({
509
+ nodeIds: value,
510
+ fileVersion: this.getFileVersion(files_1.ProtocolRouteSlaveSUCNodeMaskFileID),
511
+ });
512
+ changedFiles.push(file);
513
+ break;
514
+ }
515
+ case "sucPendingUpdate": {
516
+ const file = new files_1.ProtocolSUCPendingUpdateNodeMaskFile({
517
+ nodeIds: value,
518
+ fileVersion: this.getFileVersion(files_1.ProtocolSUCPendingUpdateNodeMaskFileID),
519
+ });
520
+ changedFiles.push(file);
521
+ break;
522
+ }
523
+ case "pendingDiscovery": {
524
+ const file = new files_1.ProtocolPendingDiscoveryNodeMaskFile({
525
+ nodeIds: value,
526
+ fileVersion: this.getFileVersion(files_1.ProtocolPendingDiscoveryNodeMaskFileID),
527
+ });
528
+ changedFiles.push(file);
529
+ break;
530
+ }
531
+ case "sucUpdateEntries": {
532
+ if (this._protocolInfo.format < 5) {
533
+ const file = new files_1.SUCUpdateEntriesFileV0({
534
+ updateEntries: value,
535
+ fileVersion: this.getFileVersion(files_1.SUCUpdateEntriesFileIDV0),
536
+ });
537
+ changedFiles.push(file);
538
+ break;
539
+ }
540
+ else {
541
+ // V5 has split the entries into multiple files
542
+ for (let index = 0; index < consts_1.SUC_MAX_UPDATES; index += files_1.SUC_UPDATES_PER_FILE_V5) {
543
+ const fileId = (0, files_1.sucUpdateIndexToSUCUpdateEntriesFileIDV5)(index);
544
+ const fileExists = await this.hasFile(fileId);
545
+ const fileVersion = this.getFileVersion(fileId);
546
+ const slice = value.slice(index, index + files_1.SUC_UPDATES_PER_FILE_V5);
547
+ if (slice.length > 0) {
548
+ const file = new files_1.SUCUpdateEntriesFileV5({
549
+ updateEntries: slice,
550
+ fileId,
551
+ fileVersion,
552
+ });
553
+ changedFiles.push(file);
554
+ }
555
+ else if (fileExists) {
556
+ deletedFiles.push(fileId);
557
+ }
558
+ }
559
+ }
560
+ break;
561
+ }
562
+ case "learnedHomeId":
563
+ case "commandClasses":
564
+ case "watchdogStarted":
565
+ case "powerLevelNormal":
566
+ case "powerLevelLow":
567
+ case "powerMode":
568
+ case "powerModeExtintEnable":
569
+ case "powerModeWutTimeout":
570
+ // 500 series only, not supported on 700+
571
+ return;
572
+ default:
573
+ (0, helpers_1.assertNever)(property.type);
574
+ }
575
+ for (const file of changedFiles) {
576
+ const { key, data } = file.serialize();
577
+ this._pendingChanges.set(key, data);
578
+ }
579
+ for (const file of deletedFiles) {
580
+ this._pendingChanges.set(file, null);
581
+ }
582
+ }
583
+ async setLRNodeNVMProperty(property, value) {
584
+ const changedFiles = [];
585
+ const deletedFiles = [];
586
+ switch (property.type) {
587
+ case "info": {
588
+ const fileId = (0, files_1.nodeIdToLRNodeInfoFileIDV5)(property.nodeId);
589
+ let file = await this._getFile(fileId);
590
+ if (value) {
591
+ // Info added or modified
592
+ file ??= new files_1.LRNodeInfoFileV5({
593
+ nodeInfos: [],
594
+ fileVersion: this.getFileVersion(fileId),
595
+ });
596
+ const existingIndex = file.nodeInfos.findIndex((info) => info.nodeId === property.nodeId);
597
+ if (existingIndex !== -1) {
598
+ file.nodeInfos[existingIndex] = value;
599
+ }
600
+ else {
601
+ file.nodeInfos.push(value);
602
+ }
603
+ changedFiles.push(file);
604
+ }
605
+ else if (file) {
606
+ // info deleted
607
+ const existingIndex = file.nodeInfos.findIndex((info) => info.nodeId === property.nodeId);
608
+ if (existingIndex !== -1) {
609
+ file.nodeInfos.splice(existingIndex, 1);
610
+ if (file.nodeInfos.length === 0) {
611
+ deletedFiles.push(fileId);
612
+ }
613
+ else {
614
+ changedFiles.push(file);
615
+ }
616
+ }
617
+ }
618
+ break;
619
+ }
620
+ default:
621
+ (0, helpers_1.assertNever)(property.type);
622
+ }
623
+ for (const file of changedFiles) {
624
+ const { key, data } = file.serialize();
625
+ this._pendingChanges.set(key, data);
626
+ }
627
+ for (const file of deletedFiles) {
628
+ this._pendingChanges.set(file, null);
629
+ }
630
+ }
631
+ async setNodeNVMProperty(property, value) {
632
+ const changedFiles = [];
633
+ const deletedFiles = [];
634
+ switch (property.type) {
635
+ case "info": {
636
+ if (this._protocolInfo.format < 1) {
637
+ // V0, single node info per file
638
+ const fileId = (0, files_1.nodeIdToNodeInfoFileIDV0)(property.nodeId);
639
+ let file = await this._getFile(fileId);
640
+ if (value) {
641
+ // Info added or modified
642
+ file ??= new files_1.NodeInfoFileV0({
643
+ nodeInfo: undefined,
644
+ fileVersion: this.getFileVersion(fileId),
645
+ });
646
+ file.nodeInfo = value;
647
+ changedFiles.push(file);
648
+ }
649
+ else {
650
+ // info deleted
651
+ deletedFiles.push(fileId);
652
+ }
653
+ }
654
+ else {
655
+ // V1+, multiple node infos per file
656
+ const fileId = (0, files_1.nodeIdToNodeInfoFileIDV1)(property.nodeId);
657
+ let file = await this._getFile(fileId);
658
+ if (value) {
659
+ // Info added or modified
660
+ file ??= new files_1.NodeInfoFileV1({
661
+ nodeInfos: [],
662
+ fileVersion: this.getFileVersion(fileId),
663
+ });
664
+ const existingIndex = file.nodeInfos.findIndex((info) => info.nodeId === property.nodeId);
665
+ if (existingIndex !== -1) {
666
+ file.nodeInfos[existingIndex] = value;
667
+ }
668
+ else {
669
+ file.nodeInfos.push(value);
670
+ }
671
+ changedFiles.push(file);
672
+ }
673
+ else if (file) {
674
+ // info deleted
675
+ const existingIndex = file.nodeInfos.findIndex((info) => info.nodeId === property.nodeId);
676
+ if (existingIndex !== -1) {
677
+ file.nodeInfos.splice(existingIndex, 1);
678
+ if (file.nodeInfos.length === 0) {
679
+ deletedFiles.push(fileId);
680
+ }
681
+ else {
682
+ changedFiles.push(file);
683
+ }
684
+ }
685
+ }
686
+ }
687
+ break;
688
+ }
689
+ case "routes": {
690
+ if (this._protocolInfo.format < 1) {
691
+ // V0, single route per file
692
+ const fileId = (0, files_1.nodeIdToRouteCacheFileIDV0)(property.nodeId);
693
+ let file = await this._getFile(fileId);
694
+ if (value) {
695
+ // Route added or modified
696
+ file ??= new files_1.RouteCacheFileV0({
697
+ routeCache: undefined,
698
+ fileVersion: this.getFileVersion(fileId),
699
+ });
700
+ file.routeCache = {
701
+ nodeId: property.nodeId,
702
+ lwr: value.lwr,
703
+ nlwr: value.nlwr,
704
+ };
705
+ changedFiles.push(file);
706
+ }
707
+ else if (file) {
708
+ // Route deleted
709
+ deletedFiles.push(fileId);
710
+ }
711
+ }
712
+ else {
713
+ // V1+, multiple routes per file
714
+ const fileId = (0, files_1.nodeIdToRouteCacheFileIDV1)(property.nodeId);
715
+ const file = await this._getFile(fileId) ?? new files_1.RouteCacheFileV1({
716
+ routeCaches: [],
717
+ fileVersion: this.getFileVersion(fileId),
718
+ });
719
+ const existingIndex = file.routeCaches.findIndex((route) => route.nodeId === property.nodeId);
720
+ const newRoute = {
721
+ nodeId: property.nodeId,
722
+ lwr: value.lwr,
723
+ nlwr: value.nlwr,
724
+ };
725
+ if (existingIndex !== -1) {
726
+ file.routeCaches[existingIndex] = newRoute;
727
+ }
728
+ else {
729
+ file.routeCaches.push(newRoute);
730
+ }
731
+ changedFiles.push(file);
732
+ }
733
+ // The existence of routes is stored separately
734
+ const nodeMaskFile = await this._getFile(files_1.ProtocolRouteCacheExistsNodeMaskFileID)
735
+ ?? new files_1.ProtocolRouteCacheExistsNodeMaskFile({
736
+ nodeIds: [],
737
+ fileVersion: this.getFileVersion(files_1.ProtocolRouteCacheExistsNodeMaskFileID),
738
+ });
739
+ if (!value && nodeMaskFile.nodeIdSet.has(property.nodeId)) {
740
+ nodeMaskFile.nodeIdSet.delete(property.nodeId);
741
+ changedFiles.push(nodeMaskFile);
742
+ }
743
+ else if (value && !nodeMaskFile.nodeIdSet.has(property.nodeId)) {
744
+ nodeMaskFile.nodeIdSet.add(property.nodeId);
745
+ changedFiles.push(nodeMaskFile);
746
+ }
747
+ break;
748
+ }
749
+ default:
750
+ (0, helpers_1.assertNever)(property.type);
751
+ }
752
+ for (const file of changedFiles) {
753
+ const { key, data } = file.serialize();
754
+ this._pendingChanges.set(key, data);
755
+ }
756
+ for (const file of deletedFiles) {
757
+ this._pendingChanges.set(file, null);
758
+ }
759
+ }
760
+ async delete(property) {
761
+ if (property.domain === "controller") {
762
+ switch (property.type) {
763
+ case "protocolVersion":
764
+ case "protocolFileFormat": {
765
+ this._pendingChanges.set(files_1.ProtocolVersionFileID, null);
766
+ return;
767
+ }
768
+ case "applicationVersion":
769
+ case "applicationFileFormat": {
770
+ if (await this.hasFile(files_1.ApplicationVersionFileID)) {
771
+ this._pendingChanges.set(files_1.ApplicationVersionFileID, null);
772
+ }
773
+ if (await this.hasFile(files_1.ApplicationVersionFile800ID)) {
774
+ this._pendingChanges.set(files_1.ApplicationVersionFile800ID, null);
775
+ }
776
+ return;
777
+ }
778
+ case "applicationData": {
779
+ this._pendingChanges.set(files_1.ApplicationDataFileID, null);
780
+ return;
781
+ }
782
+ case "applicationName": {
783
+ this._pendingChanges.set(files_1.ApplicationNameFileID, null);
784
+ return;
785
+ }
786
+ case "homeId":
787
+ case "nodeId":
788
+ case "lastNodeId":
789
+ case "staticControllerNodeId":
790
+ case "sucLastIndex":
791
+ case "controllerConfiguration":
792
+ case "sucAwarenessPushNeeded":
793
+ case "maxNodeId":
794
+ case "reservedId":
795
+ case "systemState":
796
+ case "lastNodeIdLR":
797
+ case "maxNodeIdLR":
798
+ case "reservedIdLR":
799
+ case "primaryLongRangeChannelId":
800
+ case "dcdcConfig": {
801
+ this._pendingChanges.set(files_1.ControllerInfoFileID, null);
802
+ return;
803
+ }
804
+ case "includedInsecurely":
805
+ case "includedSecurelyInsecureCCs":
806
+ case "includedSecurelySecureCCs": {
807
+ this._pendingChanges.set(files_1.ApplicationCCsFileID, null);
808
+ return;
809
+ }
810
+ case "rfRegion":
811
+ case "txPower":
812
+ case "measured0dBm":
813
+ case "enablePTI":
814
+ case "maxTXPower":
815
+ case "nodeIdType": {
816
+ this._pendingChanges.set(files_1.ApplicationRFConfigFileID, null);
817
+ return;
818
+ }
819
+ case "isListening":
820
+ case "optionalFunctionality":
821
+ case "genericDeviceClass":
822
+ case "specificDeviceClass": {
823
+ this._pendingChanges.set(files_1.ApplicationTypeFileID, null);
824
+ return;
825
+ }
826
+ case "nodeIds": {
827
+ this._pendingChanges.set(files_1.ProtocolNodeListFileID, null);
828
+ return;
829
+ }
830
+ case "lrNodeIds": {
831
+ this._pendingChanges.set(files_1.ProtocolLRNodeListFileID, null);
832
+ return;
833
+ }
834
+ case "virtualNodeIds": {
835
+ this._pendingChanges.set(files_1.ProtocolVirtualNodeMaskFileID, null);
836
+ return;
837
+ }
838
+ case "preferredRepeaters": {
839
+ this._pendingChanges.set(files_1.ProtocolPreferredRepeatersFileID, null);
840
+ return;
841
+ }
842
+ case "appRouteLock": {
843
+ this._pendingChanges.set(files_1.ProtocolAppRouteLockNodeMaskFileID, null);
844
+ return;
845
+ }
846
+ case "routeSlaveSUC": {
847
+ this._pendingChanges.set(files_1.ProtocolRouteSlaveSUCNodeMaskFileID, null);
848
+ return;
849
+ }
850
+ case "sucPendingUpdate": {
851
+ this._pendingChanges.set(files_1.ProtocolSUCPendingUpdateNodeMaskFileID, null);
852
+ return;
853
+ }
854
+ case "pendingDiscovery": {
855
+ this._pendingChanges.set(files_1.ProtocolPendingDiscoveryNodeMaskFileID, null);
856
+ return;
857
+ }
858
+ case "sucUpdateEntries": {
859
+ if (this._protocolInfo.format < 5) {
860
+ this._pendingChanges.set(files_1.SUCUpdateEntriesFileIDV0, null);
861
+ }
862
+ else {
863
+ for (let id = files_1.SUCUpdateEntriesFileV5IDBase; id <= files_1.SUCUpdateEntriesFileV5IDMax; id++) {
864
+ if (await this.hasFile(id)) {
865
+ this._pendingChanges.set(id, null);
866
+ }
867
+ }
868
+ }
869
+ return;
870
+ }
871
+ case "learnedHomeId":
872
+ case "commandClasses":
873
+ case "watchdogStarted":
874
+ case "powerLevelNormal":
875
+ case "powerLevelLow":
876
+ case "powerMode":
877
+ case "powerModeExtintEnable":
878
+ case "powerModeWutTimeout":
879
+ // 500 series only, not supported on 700+
880
+ return;
881
+ default:
882
+ (0, helpers_1.assertNever)(property);
883
+ }
884
+ }
885
+ else if (property.domain === "lrnode") {
886
+ // Node properties are handled by set(..., undefined) because
887
+ // it requires both modifying and deleting files
888
+ return this.setLRNodeNVMProperty(property, undefined);
889
+ }
890
+ else if (property.domain === "node") {
891
+ // Node properties are handled by set(..., undefined) because
892
+ // it requires both modifying and deleting files
893
+ return this.setNodeNVMProperty(property, undefined);
894
+ }
895
+ }
896
+ hasPendingChanges() {
897
+ return this._pendingChanges.size > 0;
898
+ }
899
+ async commit() {
900
+ await this._nvm.setMany([...this._pendingChanges]);
901
+ }
902
+ }
903
+ exports.NVM3Adapter = NVM3Adapter;
904
+ //# sourceMappingURL=adapter.js.map