From 4fa233f70b7650f6584ddbf901b13b53c7e1091b Mon Sep 17 00:00:00 2001
From: Song Guo <songguo@google.com>
Date: Thu, 5 May 2022 11:08:04 +0800
Subject: [PATCH] Use RESPONSE_REF for responseCode

---
 package.json                                    |  2 +-
 src-electron/db/query-endpoint.js               | 10 ++++++++++
 src-electron/generator/helper-endpointconfig.js |  4 ++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/package.json b/package.json
index d27dd3a8..1c7b279b 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "type": "commonjs",
   "name": "zap",
-  "version": "2022.4.28",
+  "version": "2022.5.5",
   "description": "Configuration tool for the Zigbee Cluster Library",
   "productName": "zap",
   "cordovaId": "",
diff --git a/src-electron/db/query-endpoint.js b/src-electron/db/query-endpoint.js
index 38b264a8..13993842 100644
--- a/src-electron/db/query-endpoint.js
+++ b/src-electron/db/query-endpoint.js
@@ -214,6 +214,9 @@ SELECT
   C.IS_OPTIONAL,
   C.MUST_USE_TIMED_INVOKE,
   C.RESPONSE_NAME,
+  RC.MANUFACTURER_CODE as RESPONSE_MANUFACTURER_CODE,
+  RC.CODE AS RESPONSE_CODE,
+  C.RESPONSE_REF,
   EC.INCOMING,
   EC.OUTGOING
 FROM
@@ -222,6 +225,10 @@ LEFT JOIN
   ENDPOINT_TYPE_COMMAND AS EC
 ON
   C.COMMAND_ID = EC.COMMAND_REF
+LEFT JOIN
+  COMMAND AS RC
+ON
+  RC.COMMAND_ID = C.RESPONSE_REF
 WHERE
   C.CLUSTER_REF = ?
   AND EC.ENDPOINT_TYPE_REF = ?
@@ -242,6 +249,9 @@ ORDER BY C.CODE
       isIncoming: row['INCOMING'],
       isOutgoing: row['OUTGOING'],
       responseName: row['RESPONSE_NAME'],
+      responseManufacturerCode: row['RESPONSE_MANUFACTURER_CODE'],
+      responseCode: row['RESPONSE_CODE'],
+      responseRef: row['RESPONSE_REF'],
       hexCode: '0x' + bin.int8ToHex(row['CODE']),
     }
   })
diff --git a/src-electron/generator/helper-endpointconfig.js b/src-electron/generator/helper-endpointconfig.js
index e15477bb..ac668455 100644
--- a/src-electron/generator/helper-endpointconfig.js
+++ b/src-electron/generator/helper-endpointconfig.js
@@ -789,6 +789,10 @@ async function collectAttributes(endpointTypes, options) {
           name: cmd.name,
           comment: cluster.comment,
           responseName: cmd.responseName,
+          responseId:
+            cmd.responseRef !== null
+              ? asMEI(cmd.responseManufacturerCode, cmd.responseCode)
+              : null,
         }
         commandList.push(command)
         cluster.commands.push(command)
-- 
GitLab