Support Foundation Command for use in zigbee-shepherd converter https://github.com/zigbeer/zcl-packet/wiki/6.-Appendix#FoundCmdTbl

This commit is contained in:
Viet Dzung
2018-09-11 13:59:49 +07:00
parent f463ca68a5
commit 236afaacaf
+17 -5
View File
@@ -191,15 +191,27 @@ class Zigbee {
}
logger.info(`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep}`);
device.functional(cid, cmd, zclData, (error) => {
if(zclData['foudation']!==true){
device.functional(cid, cmd, zclData, (error) => {
if (error) {
logger.error(
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep} ` +
`failed with error ${error}`);
}
callback(error);
});
}else{ // use foundation command
device.foundation(cid, cmd, [{ attrId: zclData['attrId'], dataType:zclData['dataType'], attrData:zclData['attrData'] }, ], function (error, rsp) {
if (error){
logger.error(
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep} ` +
`failed with error ${error}`);
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep} ` +
`failed with error ${error}, respond ${rsp}`);
}
callback(error);
});
}
callback(error);
});
}
read(deviceID, cid, attr, ep, callback) {