Koenkk / zigbee-herdsman

A Node.js Zigbee library
MIT License
482 stars 300 forks source link

fix: Use BuffaloZdo in ZStackAdapter #1133

Closed Koenkk closed 2 months ago

Koenkk commented 4 months ago

I checked a bit how we can use BuffaloZdo in the zstack adapter, this PR contains a poc.

@Nerivec could you check https://github.com/Koenkk/zigbee-herdsman/pull/1133/commits/8f3d6b6090deead7c07d72a225fa3f8129c4d052 ?

Nerivec commented 2 months ago
    public readIeeeAddr(): EUI64 {
        return `0x${Buffer.from(this.readBuffer(8)).reverse().toString('hex')}`;
    }

in src/buffalo/buffalo.ts, should fix some of the issues. Should be less dangerous overall (no reversal in underlaying buffer), cleaner and much faster as a bonus (x2-3, despite the added Buffer alloc). Note: same pattern is used in buffaloZiGate.ts and should be changed too (just for perf.).

    public readIeeeAddrBE(): EUI64 {
        return `0x${this.readBuffer(8).toString('hex')}`;
    }