()
| 9 | } |
| 10 | |
| 11 | async start() { |
| 12 | await this.znp.open(); |
| 13 | const attempts = 3; |
| 14 | for (let i = 0; i < attempts; i++) { |
| 15 | try { |
| 16 | await this.znp.request(Subsystem.SYS, "ping", {capabilities: 1}); |
| 17 | break; |
| 18 | } catch (e) { |
| 19 | if (attempts - 1 === i) { |
| 20 | throw new Error(`Failed to connect to the adapter (${e})`); |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | // Old firmware did not support version, assume it's Z-Stack 1.2 for now. |
| 25 | try { |
| 26 | this.version = (await this.znp.request(Subsystem.SYS, "version", {})).payload; |
| 27 | } catch { |
| 28 | console.log("Failed to get zStack version, assuming 1.2"); |
| 29 | this.version = {transportrev: 2, product: 0, majorrel: 2, minorrel: 0, maintrel: 0, revision: ""}; |
| 30 | } |
| 31 | |
| 32 | console.log(`Detected znp version '${ZnpVersion[this.version.product]}' (${JSON.stringify(this.version)})`); |
| 33 | |
| 34 | await this.clearAllNvMemItems(); |
| 35 | |
| 36 | process.exit(0); |
| 37 | } |
| 38 | |
| 39 | async clearAllNvMemItems() { |
| 40 | let maxNvMemId; |
no test coverage detected