From f115220e6042aebd2e3a14bdfe8d25e1d2668ded Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Wed, 25 May 2022 19:18:39 +0200 Subject: [PATCH] Zigbee display version of MCU software in UI --- tasmota/xdrv_23_zigbee_1_headers.ino | 6 ++++++ tasmota/xdrv_23_zigbee_8_parsers.ino | 26 +++++++++++++++----------- tasmota/xdrv_23_zigbee_A_impl.ino | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/tasmota/xdrv_23_zigbee_1_headers.ino b/tasmota/xdrv_23_zigbee_1_headers.ino index 685f00ebd..a28afeae1 100644 --- a/tasmota/xdrv_23_zigbee_1_headers.ino +++ b/tasmota/xdrv_23_zigbee_1_headers.ino @@ -97,6 +97,12 @@ public: ZB_RecvMsgFunc recv_func = nullptr; // function to call when message is expected ZB_RecvMsgFunc recv_unexpected = nullptr; // function called when unexpected message is received + // version + uint8_t major_rel = 0; + uint8_t minor_rel = 0; + uint8_t maint_rel = 0; + uint32_t revision = 0; + // Energy scan int8_t energy[USE_ZIGBEE_CHANNEL_COUNT]; diff --git a/tasmota/xdrv_23_zigbee_8_parsers.ino b/tasmota/xdrv_23_zigbee_8_parsers.ino index 277dea88d..a798a8164 100644 --- a/tasmota/xdrv_23_zigbee_8_parsers.ino +++ b/tasmota/xdrv_23_zigbee_8_parsers.ino @@ -447,20 +447,21 @@ int32_t ZNP_ReceiveCheckVersion(int32_t res, SBuffer &buf) { // MinorRel = 6 // MaintRel = 3 // Revision = 20190425 d (0x013414D9) - uint8_t major_rel = buf.get8(4); - uint8_t minor_rel = buf.get8(5); - uint8_t maint_rel = buf.get8(6); - uint32_t revision = buf.get32(7); + zigbee.major_rel = buf.get8(4); + zigbee.minor_rel = buf.get8(5); + zigbee.maint_rel = buf.get8(6); + zigbee.revision = buf.get32(7); Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" "\"Status\":%d,\"MajorRel\":%d,\"MinorRel\":%d" ",\"MaintRel\":%d,\"Revision\":%d}}"), - ZIGBEE_STATUS_CC_VERSION, major_rel, minor_rel, - maint_rel, revision); + ZIGBEE_STATUS_CC_VERSION, + zigbee.major_rel, zigbee.minor_rel, + zigbee.maint_rel, zigbee.revision); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE)); - if ((0x02 == major_rel) && ((0x06 == minor_rel) || (0x07 == minor_rel))) { + if ((0x02 == zigbee.major_rel) && ((0x06 == zigbee.minor_rel) || (0x07 == zigbee.minor_rel))) { return 0; // version 2.6.x and 2.7.x are ok } else { return ZIGBEE_LABEL_UNSUPPORTED_VERSION; // abort @@ -474,14 +475,17 @@ int32_t EZ_ReceiveCheckVersion(int32_t res, SBuffer &buf) { uint8_t stack_type = buf.get8(3); zigbee.ezsp_version = buf.get16(4); + zigbee.major_rel = (zigbee.ezsp_version & 0xF000) >> 12; + zigbee.minor_rel = (zigbee.ezsp_version & 0x0F00) >> 8; + zigbee.maint_rel = (zigbee.ezsp_version & 0x00F0) >> 4; + zigbee.revision = zigbee.ezsp_version & 0x000F; + Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" "\"Status\":%d,\"Version\":\"%d.%d.%d.%d\",\"Protocol\":%d" ",\"Stack\":%d}}"), ZIGBEE_STATUS_EZ_VERSION, - (zigbee.ezsp_version & 0xF000) >> 12, - (zigbee.ezsp_version & 0x0F00) >> 8, - (zigbee.ezsp_version & 0x00F0) >> 4, - zigbee.ezsp_version & 0x000F, + zigbee.major_rel, zigbee.minor_rel, + zigbee.maint_rel, zigbee.revision, protocol_version, stack_type ); diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 26d634b8b..f182316ea 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -1931,6 +1931,19 @@ uint32_t convert_seconds_to_dhm(uint32_t seconds, char *unit, uint8_t *color){ return 0; } +const char HTTP_ZB_VERSION[] PROGMEM = + "
" + "Zigbee: " +#if defined(USE_ZIGBEE_EZSP) + "EZSP" +#elif defined(USE_ZIGBEE_ZNP) + "ZNP" +#else + "unknown" +#endif + " v%d.%d.%d.%d" + "
"; + const char HTTP_BTN_ZB_BUTTONS[] PROGMEM = "" "

" @@ -2114,6 +2127,12 @@ void ZigbeeShow(bool json) WSContentSend_P(msg[ZB_WEB_PERMITJOIN_ACTIVE], PSTR(D_ZIGBEE_PERMITJOIN_ACTIVE)); } + // show Zigbee MCU version + if (!zigbee.init_phase) { + WSContentSend_P(HTTP_ZB_VERSION, + zigbee.major_rel, zigbee.minor_rel, + zigbee.maint_rel, zigbee.revision); + } #endif } }