diff --git a/src/adapter/adapter.ts b/src/adapter/adapter.ts index 255344499d..e0ea311631 100644 --- a/src/adapter/adapter.ts +++ b/src/adapter/adapter.ts @@ -15,6 +15,7 @@ interface AdapterEventMap { zdoResponse: [clusterId: Zdo.ClusterId, response: ZdoTypes.GenericZdoResponse]; disconnected: []; deviceLeave: [payload: AdapterEvents.DeviceLeavePayload]; + sourceRoute: [payload: any]; } abstract class Adapter extends events.EventEmitter { diff --git a/src/adapter/z-stack/adapter/zStackAdapter.ts b/src/adapter/z-stack/adapter/zStackAdapter.ts index f174ce2882..d01d4593f6 100644 --- a/src/adapter/z-stack/adapter/zStackAdapter.ts +++ b/src/adapter/z-stack/adapter/zStackAdapter.ts @@ -795,6 +795,8 @@ class ZStackAdapter extends Adapter { }; this.emit('deviceJoined', payload); + } else if (object.command.name === 'srcRtgInd') { + this.emit('sourceRoute', object.payload); } else if (object.command.name === 'endDeviceAnnceInd') { // TODO: better way??? /* istanbul ignore else */ diff --git a/src/controller/controller.ts b/src/controller/controller.ts index 1e8c0b4617..407710c6b8 100644 --- a/src/controller/controller.ts +++ b/src/controller/controller.ts @@ -62,6 +62,7 @@ export interface ControllerEventMap { deviceLeave: [data: Events.DeviceLeavePayload]; permitJoinChanged: [data: Events.PermitJoinChangedPayload]; lastSeenChanged: [data: Events.LastSeenChangedPayload]; + sourceRoute: [data: Events.SrcRouteIndPayload]; } /** @@ -165,6 +166,7 @@ class Controller extends events.EventEmitter { this.adapter.on('zdoResponse', this.onZdoResponse.bind(this)); this.adapter.on('disconnected', this.onAdapterDisconnected.bind(this)); this.adapter.on('deviceLeave', this.onDeviceLeave.bind(this)); + this.adapter.on('sourceRoute', this.onSourceRoute.bind(this)); if (startResult === 'reset') { /* istanbul ignore else */ @@ -958,6 +960,10 @@ class Controller extends events.EventEmitter { await device.onZclData(payload, frame, endpoint); } } + + private onSourceRoute(data: Events.SrcRouteIndPayload): void { + this.emit('sourceRoute', data); + } } export default Controller; diff --git a/src/controller/events.ts b/src/controller/events.ts index 94404a52a8..96a6dddffd 100644 --- a/src/controller/events.ts +++ b/src/controller/events.ts @@ -50,6 +50,12 @@ interface MessagePayload { }; } +interface SrcRouteIndPayload { + dstaddr: number; + relaycount: number; + relaylist: number[]; +} + export { MessagePayload, MessagePayloadType, @@ -60,4 +66,5 @@ export { PermitJoinChangedPayload, DeviceNetworkAddressChangedPayload, LastSeenChangedPayload, + SrcRouteIndPayload, };