Skip to content

Commit

Permalink
fix: Add IEEE -> NWK Addr translation on RX for Conbee 3 (#1114)
Browse files Browse the repository at this point in the history
* add IEEE -> NWK Addr translation on RX for conbee 3

* Update deconzAdapter.ts

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
schrluka and Koenkk authored Jul 15, 2024
1 parent 194102d commit 14b7b53
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/adapter/deconz/adapter/deconzAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {WaitForDataRequest, ApsDataRequest, ReceivedDataResponse, gpDataInd} fro
import * as Models from '../../../models';
import {logger} from '../../../utils/logger';
import {BroadcastAddress} from '../../../zspec/enums';
import Device from '../../../controller/model/device';

const NS = 'zh:deconz';
var frameParser = require('../driver/frameParser');
Expand Down Expand Up @@ -1256,7 +1257,25 @@ class DeconzAdapter extends Adapter {
const payBuf = resp != null ? Buffer.from(resp.asduPayload) : null;

if (resp != null) {
srcAddr = resp.srcAddr16 != null ? resp.srcAddr16 : resp.srcAddr64;
if (resp.srcAddr16 != null) {
srcAddr = resp.srcAddr16;
} else {
// For some devices srcAddr64 is reported by ConBee 3, even if the frame contains both
// srcAddr16 and srcAddr64. This happens even if the request was sent to a short address.
// At least some parts, e.g. the while loop below, only work with srcAddr16 (i.e. the network
// address) being set. So we try to look up the network address in the list of know devices.
if (resp.srcAddr64 != null) {
logger.debug(`Try to find network address of ${resp.srcAddr64}`, NS);
// Note: Device expects addresses with a 0x prefix...
let device = Device.byIeeeAddr('0x' + resp.srcAddr64, false);
if (device != undefined) {
srcAddr = device.networkAddress;
}
}
// apperantly some functions furhter up in the protocol stack expect this to be set.
// so let's make sure they get the network address
resp.srcAddr16 = srcAddr;
}
if (resp.profileId != 0x00) {
header = Zcl.Header.fromBuffer(payBuf);
}
Expand Down

0 comments on commit 14b7b53

Please sign in to comment.