Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZNP Adapter Manager/Backup Refactor #303

Merged
merged 115 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
ee98388
added mz/fs for promise-based fs access
castorw Jan 30, 2021
c985f74
wip: znp adapter manager
castorw Jan 31, 2021
8f60cc9
added mz/fs for promise-based fs access
castorw Jan 30, 2021
0022f03
wip: znp adapter manager
castorw Jan 31, 2021
41bc771
Merge branch 'znp-provisioning-refactor' of github.com:castorw/zigbee…
castorw Jan 31, 2021
97ee02c
fixed nib coordinator address byte order
castorw Jan 31, 2021
82788d5
added toJSON method to structs
castorw Jan 31, 2021
c124abf
fixed unified backup nwkUpdateId and securityLevel handling
castorw Jan 31, 2021
8ef17cd
various enhancements to restore and commissioning
castorw Jan 31, 2021
cd226f5
wip: added aps_use_ext_panid
castorw Jan 31, 2021
86be10f
added epid to state comparisons
castorw Jan 31, 2021
f4c9988
removed struct inline factory function
castorw Jan 31, 2021
f18d78e
unified backup enhancements, struct buffer fixes
castorw Feb 1, 2021
198c640
added APP_CNF::setNwkFrameCounter definition
castorw Feb 1, 2021
15620d5
fixed nv multi-chunk reads and writes
castorw Feb 3, 2021
aae1644
wip: more structs and complex backup
castorw Feb 5, 2021
744dfe5
added request retries to nv driver
castorw Feb 6, 2021
87f1596
wip: working backup/restore with aps security
castorw Feb 7, 2021
f9da95b
added mz/fs for promise-based fs access
castorw Jan 30, 2021
2f34326
wip: znp adapter manager
castorw Jan 31, 2021
5e54756
fixed nib coordinator address byte order
castorw Jan 31, 2021
af04d7e
added toJSON method to structs
castorw Jan 31, 2021
97858ca
fixed unified backup nwkUpdateId and securityLevel handling
castorw Jan 31, 2021
c0eaad2
various enhancements to restore and commissioning
castorw Jan 31, 2021
d828cd5
wip: added aps_use_ext_panid
castorw Jan 31, 2021
62bd263
added epid to state comparisons
castorw Jan 31, 2021
d47cd81
removed struct inline factory function
castorw Jan 31, 2021
cc41a6d
unified backup enhancements, struct buffer fixes
castorw Feb 1, 2021
c3f0718
added APP_CNF::setNwkFrameCounter definition
castorw Feb 1, 2021
ae6f7a5
fixed nv multi-chunk reads and writes
castorw Feb 3, 2021
eb661a2
wip: more structs and complex backup
castorw Feb 5, 2021
be8c8dd
added request retries to nv driver
castorw Feb 6, 2021
4b4fc6c
wip: working backup/restore with aps security
castorw Feb 7, 2021
09d1a08
Merge branch 'znp-provisioning-refactor' of github.com:castorw/zigbee…
castorw Feb 7, 2021
79b0f68
updated version info in unified backup format
castorw Feb 7, 2021
02d4847
removed unused nv types
castorw Feb 7, 2021
8ce94cf
updated backup format
castorw Feb 8, 2021
de0f211
models and utils reorganized, backup typings
castorw Feb 8, 2021
bd357e2
fix: we dont want aps security yet
castorw Feb 8, 2021
4f53f74
forced ieee address as epid when not configured
castorw Feb 8, 2021
b3f91e7
default epid handling fix
castorw Feb 8, 2021
bcbc0c3
added code comments
castorw Feb 8, 2021
3b1ff10
added config/backup inconsistency warning
castorw Feb 8, 2021
02c058b
z-stack 1.2 compat
castorw Feb 10, 2021
114c2d3
wip: tests
castorw Mar 3, 2021
0758b4f
wip: tests
castorw Mar 4, 2021
f6e62a8
wip: tests - recovered original adapter tests
castorw Mar 14, 2021
d4e0694
wip: tests
castorw Mar 20, 2021
0e1978f
wip: tests
castorw Mar 22, 2021
e8c830e
updated tests
castorw Apr 4, 2021
a67cb65
added mz/fs for promise-based fs access
castorw Jan 30, 2021
1b5371a
wip: znp adapter manager
castorw Jan 31, 2021
4605ade
fixed nib coordinator address byte order
castorw Jan 31, 2021
199b483
added toJSON method to structs
castorw Jan 31, 2021
75bef8f
fixed unified backup nwkUpdateId and securityLevel handling
castorw Jan 31, 2021
165c4f0
various enhancements to restore and commissioning
castorw Jan 31, 2021
a018acd
wip: added aps_use_ext_panid
castorw Jan 31, 2021
fac1ef3
added epid to state comparisons
castorw Jan 31, 2021
4789d3d
removed struct inline factory function
castorw Jan 31, 2021
1f85619
unified backup enhancements, struct buffer fixes
castorw Feb 1, 2021
4659867
added APP_CNF::setNwkFrameCounter definition
castorw Feb 1, 2021
02a0e31
fixed nv multi-chunk reads and writes
castorw Feb 3, 2021
edc8e43
wip: more structs and complex backup
castorw Feb 5, 2021
130e7f8
added request retries to nv driver
castorw Feb 6, 2021
b2fd60a
wip: working backup/restore with aps security
castorw Feb 7, 2021
bbdb429
wip: znp adapter manager
castorw Jan 31, 2021
7e63125
fixed nib coordinator address byte order
castorw Jan 31, 2021
5b38987
added toJSON method to structs
castorw Jan 31, 2021
d1d7d8b
various enhancements to restore and commissioning
castorw Jan 31, 2021
38310d8
wip: added aps_use_ext_panid
castorw Jan 31, 2021
a3b7c23
added epid to state comparisons
castorw Jan 31, 2021
6cce12f
removed struct inline factory function
castorw Jan 31, 2021
0fe0414
unified backup enhancements, struct buffer fixes
castorw Feb 1, 2021
05530c4
wip: more structs and complex backup
castorw Feb 5, 2021
bce1127
wip: working backup/restore with aps security
castorw Feb 7, 2021
afe28e5
updated version info in unified backup format
castorw Feb 7, 2021
349fa08
removed unused nv types
castorw Feb 7, 2021
a6da8a5
updated backup format
castorw Feb 8, 2021
6220572
models and utils reorganized, backup typings
castorw Feb 8, 2021
b47f9e3
fix: we dont want aps security yet
castorw Feb 8, 2021
5f1e231
forced ieee address as epid when not configured
castorw Feb 8, 2021
77d5077
default epid handling fix
castorw Feb 8, 2021
564d92c
added code comments
castorw Feb 8, 2021
3c7c43e
added config/backup inconsistency warning
castorw Feb 8, 2021
c5929fe
z-stack 1.2 compat
castorw Feb 10, 2021
395684f
wip: tests
castorw Mar 3, 2021
bc3b243
wip: tests
castorw Mar 4, 2021
1a894e6
wip: tests - recovered original adapter tests
castorw Mar 14, 2021
0cc9551
wip: tests
castorw Mar 20, 2021
5236b81
wip: tests
castorw Mar 22, 2021
2e91c3d
updated tests
castorw Apr 4, 2021
93640e1
adapted ezsp + fixed tests
castorw Apr 4, 2021
3155fc8
Merge branch 'znp-provisioning-refactor' of github.com:castorw/zigbee…
castorw Apr 4, 2021
086ee4f
linting fix
castorw Apr 4, 2021
1a1a992
Merge remote-tracking branch 'koen/master' into znp-provisioning-refa…
Koenkk Apr 6, 2021
e572c0e
fixed scoping of hasConfigured param in comments
castorw Apr 6, 2021
3dff82d
added missing alignment init to nv writeTable fn
castorw Apr 7, 2021
21b30e6
enhanced adapter settle and reset debug logging
castorw Apr 7, 2021
170b7d2
changed startup option value to 0x00
castorw Apr 7, 2021
0c33ce6
fixed channel range, enhanced provisional logging
castorw Apr 10, 2021
3fb5660
Only backup on reset or when backup doesn't exist
Koenkk Apr 11, 2021
4e816a9
fixed restore with default EPID configuration
castorw Apr 11, 2021
b1da609
always restore coordinator ieee address
castorw Apr 11, 2021
743c95e
added adapter clearing before restore
castorw Apr 11, 2021
21d0ed8
adepter clear on every commissioning
castorw Apr 11, 2021
e57a0b7
updated backup fetch debug logging
castorw Apr 11, 2021
ce62d4b
minor config-backup match code reorganisation
castorw Apr 11, 2021
6515f7d
added epid matching strategy exception for 1.2
castorw Apr 11, 2021
c3fa70c
minor endpoint registration debug tweak
castorw Apr 11, 2021
94d2aab
config-adapter mismatch fail, lenient default epid
castorw Apr 21, 2021
dc9eba3
accept reversed epid and only warn
castorw May 12, 2021
fa81502
resume network with reversed epid
castorw May 13, 2021
d62950f
Merge remote-tracking branch 'koen/master' into znp-provisioning-refa…
Koenkk May 13, 2021
f54945c
ignore reversed epid in backup
castorw May 13, 2021
089fefb
accept reversed epid, now for real
castorw May 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@
"javascript",
"typescript",
],
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.preferences.importModuleSpecifier": "relative",
"eslint.format.enable": true,
"typescript.preferences.importModuleSpecifier": "relative",
"[typescript]": {
"editor.codeActionsOnSave": {
"source.organizeImports": false
}
},
}
40 changes: 40 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"fast-deep-equal": "^3.1.3",
"mixin-deep": "^2.0.1",
"@serialport/bindings": "9.0.4",
"mz": "^2.7.0",
"serialport": "9.0.6",
"slip": "^1.0.2"
},
Expand All @@ -45,6 +46,7 @@
"@types/debounce": "^1.2.0",
"@types/debug": "*",
"@types/jest": "*",
"@types/mz": "^2.7.3",
"@types/nedb": "*",
"@types/node": "*",
"@types/serialport": "*",
Expand Down
11 changes: 8 additions & 3 deletions src/adapter/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {ZclDataPayload} from './events';
import events from 'events';
import {ZclFrame, FrameType, Direction} from '../zcl';
import Debug from "debug";
import {LoggerStub} from "../controller/logger-stub";
import * as Models from "../models";

const debug = Debug("zigbee-herdsman:adapter");

Expand All @@ -12,16 +14,18 @@ abstract class Adapter extends events.EventEmitter {
protected adapterOptions: TsType.AdapterOptions;
protected serialPortOptions: TsType.SerialPortOptions;
protected backupPath: string;
protected logger?: LoggerStub;

protected constructor(
networkOptions: TsType.NetworkOptions, serialPortOptions: TsType.SerialPortOptions, backupPath: string,
adapterOptions: TsType.AdapterOptions)
adapterOptions: TsType.AdapterOptions, logger?: LoggerStub)
{
super();
this.networkOptions = networkOptions;
this.adapterOptions = adapterOptions;
this.serialPortOptions = serialPortOptions;
this.backupPath = backupPath;
this.logger = logger;
}

/**
Expand All @@ -33,6 +37,7 @@ abstract class Adapter extends events.EventEmitter {
serialPortOptions: TsType.SerialPortOptions,
backupPath: string,
adapterOptions: TsType.AdapterOptions,
logger?: LoggerStub,
): Promise<Adapter> {
const {ZStackAdapter} = await import('./z-stack/adapter');
const {DeconzAdapter} = await import('./deconz/adapter');
Expand Down Expand Up @@ -90,7 +95,7 @@ abstract class Adapter extends events.EventEmitter {
}
}

return new adapter(networkOptions, serialPortOptions, backupPath, adapterOptions);
return new adapter(networkOptions, serialPortOptions, backupPath, adapterOptions, logger);
}

public abstract start(): Promise<TsType.StartResult>;
Expand All @@ -109,7 +114,7 @@ abstract class Adapter extends events.EventEmitter {

public abstract supportsBackup(): Promise<boolean>;

public abstract backup(): Promise<TsType.Backup>;
public abstract backup(): Promise<Models.Backup>;

public abstract getNetworkParameters(): Promise<TsType.NetworkParameters>;

Expand Down
10 changes: 6 additions & 4 deletions src/adapter/deconz/adapter/deconzAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import processFrame from '../driver/frameParser';
import {Queue, Waitress, Wait} from '../../../utils';
import PARAM from '../driver/constants';
import { Command, WaitForDataRequest, ApsDataRequest, ReceivedDataResponse, DataStateResponse, gpDataInd } from '../driver/constants';
import {LoggerStub} from "../../../controller/logger-stub";
import * as Models from "../../../models";

var frameParser = require('../driver/frameParser');

Expand All @@ -41,9 +43,9 @@ class DeconzAdapter extends Adapter {
private waitress: Waitress<Events.ZclDataPayload, WaitressMatcher>;

public constructor(networkOptions: NetworkOptions,
serialPortOptions: SerialPortOptions, backupPath: string, adapterOptions: AdapterOptions) {
serialPortOptions: SerialPortOptions, backupPath: string, adapterOptions: AdapterOptions, logger?: LoggerStub) {

super(networkOptions, serialPortOptions, backupPath, adapterOptions);
super(networkOptions, serialPortOptions, backupPath, adapterOptions, logger);

const concurrent = this.adapterOptions && this.adapterOptions.concurrent ?
this.adapterOptions.concurrent : 2;
Expand Down Expand Up @@ -853,8 +855,8 @@ class DeconzAdapter extends Adapter {
return false;
}

public async backup(): Promise<BackupType> {
return Promise.reject();
public async backup(): Promise<Models.Backup> {
throw new Error("This adapter does not support backup");
}

public async getNetworkParameters(): Promise<NetworkParameters> {
Expand Down
6 changes: 3 additions & 3 deletions src/adapter/ezsp/adapter/ezspAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {EmberZDOCmd, EmberApsOption, uint16_t, EmberEUI64, EmberStatus} from '..
import {ZclFrame, FrameType, Direction, Foundation} from '../../../zcl';
import * as Events from '../../events';
import {Waitress, Wait} from '../../../utils';
import * as Models from "../../../models";


interface WaitressMatcher {
Expand Down Expand Up @@ -453,9 +454,8 @@ class EZSPAdapter extends Adapter {
return false;
}

public async backup(): Promise<BackupType> {
// todo
return Promise.reject();
public async backup(): Promise<Models.Backup> {
throw new Error("This adapter does not support backup");
}

public async restoreChannelInterPAN(): Promise<void> {
Expand Down
Loading