From f8ab917688857c9893a319a788ca0eb5e33c433d Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 9 Aug 2020 10:44:32 +0200 Subject: [PATCH] Update LQI on ZDO messages --- tasmota/xdrv_23_zigbee_2_devices.ino | 2 ++ tasmota/xdrv_23_zigbee_8_parsers.ino | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_23_zigbee_2_devices.ino b/tasmota/xdrv_23_zigbee_2_devices.ino index d87fe4005..d6c4dce05 100644 --- a/tasmota/xdrv_23_zigbee_2_devices.ino +++ b/tasmota/xdrv_23_zigbee_2_devices.ino @@ -647,12 +647,14 @@ void Z_Devices::setReachable(uint16_t shortaddr, bool reachable) { } void Z_Devices::setLQI(uint16_t shortaddr, uint8_t lqi) { + if (shortaddr == localShortAddr) { return; } Z_Device & device = getShortAddr(shortaddr); if (&device == nullptr) { return; } // don't crash if not found device.linkquality = lqi; } uint8_t Z_Devices::getLQI(uint16_t shortaddr) const { + if (shortaddr == localShortAddr) { return 0xFF; } int32_t found = findShortAddr(shortaddr); if (found >= 0) { const Z_Device & device = devicesAt(found); diff --git a/tasmota/xdrv_23_zigbee_8_parsers.ino b/tasmota/xdrv_23_zigbee_8_parsers.ino index f195fc7ac..abcbf9675 100644 --- a/tasmota/xdrv_23_zigbee_8_parsers.ino +++ b/tasmota/xdrv_23_zigbee_8_parsers.ino @@ -1152,7 +1152,6 @@ int32_t EZ_IncomingMessage(int32_t res, const class SBuffer &buf) { bool securityuse = (apsoptions & EMBER_APS_OPTION_ENCRYPTION) ? true : false; uint16_t groupid = buf.get16(11); uint8_t seqnumber = buf.get8(13); - // uint8_t linkquality = buf.get8(14); int8_t linkrssi = buf.get8(15); uint8_t linkquality = ZNP_RSSI2Lqi(linkrssi); // don't take EZSP LQI but calculate our own based on ZNP uint16_t srcaddr = buf.get16(16); @@ -1163,6 +1162,8 @@ int32_t EZ_IncomingMessage(int32_t res, const class SBuffer &buf) { if ((0x0000 == profileid) && (0x00 == srcendpoint)) { // ZDO request + // Report LQI + zigbee_devices.setLQI(srcaddr, linkquality); // Since ZDO messages start with a sequence number, we skip it // but we add the source address in the last 2 bytes SBuffer zdo_buf(buf.get8(20) - 1 + 2);