diff --git a/core/class/AbeilleCmdProcess.class.php b/core/class/AbeilleCmdProcess.class.php index 0400729853..f6cbc78574 100755 --- a/core/class/AbeilleCmdProcess.class.php +++ b/core/class/AbeilleCmdProcess.class.php @@ -5081,7 +5081,7 @@ function processCmd($Command) { $tData = $Command['data']; // Supposed to be 00 (NOT connected), 01 (connected) or 02 (timeout) $tLen = sprintf("%04X", strlen($tData) / 2); - cmdLog('debug', ' internetStatus: tSqn='.$tSqn.', tLen='.$tLen.', tData='.$tData); + cmdLog2('debug', $addr, ' internetStatus: tSqn='.$tSqn.', tLen='.$tLen.', tData='.$tData); $data2 = $zclHeader.$tSqn.$tLen.$tData; } else { // ZCL header @@ -5097,16 +5097,16 @@ function processCmd($Command) { $dpData = $dp['data']; $dpLen = strlen($dpData) / 2; if (($dpType == "02") && ($dpLen > 4)) { - cmdLog('error', ' Wrong dpData size (max=4B for type 02)'); + cmdLog2('error', $addr, ' Wrong dpData size (max=4B for type 02)'); return; } - $tuyaSqn = isset($Command['tuyaSqn']) ? $Command['tuyaSqn'] : tuyaGenSqn(); // Tuya transaction ID + $tSqn = isset($Command['tuyaSqn']) ? $Command['tuyaSqn'] : tuyaGenSqn(); // Tuya transaction ID $dpId = $dp['id']; $dpLen = sprintf("%04X", $dpLen); - cmdLog('debug', ' '.$Command['cmd'].': tuyaSqn='.$tuyaSqn.', dpId='.$dpId.', dpType='.$dpType.', dpData='.$dpData); - $data2 = $fcf.$sqn.$cmdId.$tuyaSqn.$dpId.$dpType.$dpLen.$dpData; + cmdLog2('debug', $addr, ' '.$Command['cmd'].': tSqn='.$tSqn.', dpId='.$dpId.', dpType='.$dpType.', dpData='.$dpData); + $data2 = $fcf.$sqn.$cmdId.$tSqn.$dpId.$dpType.$dpLen.$dpData; } $dataLen2 = sprintf("%02X", strlen($data2) / 2); $data1 = $addrMode.$addr.$srcEp.$dstEp.$clustId.$profId.$secMode.$radius.$dataLen2; @@ -5133,7 +5133,7 @@ function processCmd($Command) { } else if (method_exists($this, $fctName)) { $this->$fctName($dest, $addr, $ep, $cmd, $message); } else { - cmdLog('error', " Commande privée: Fonction '${fctName}' inconnue"); + cmdLog2('error', $addr, " Commande privée: Fonction '${fctName}' inconnue"); } return; } // End 'cmd-Private' diff --git a/core/class/AbeilleParser.class.php b/core/class/AbeilleParser.class.php index 76c86de281..8311bf623d 100755 --- a/core/class/AbeilleParser.class.php +++ b/core/class/AbeilleParser.class.php @@ -4321,7 +4321,7 @@ function decode8002($dest, $payload, $lqi) { if ($this->isDuplicated($dest, $srcAddr, $fcf, $sqn)) return; - $attrReportN = tuyaDecodeEF00Cmd($dest, $srcAddr, $srcEp, $cmd, $msg, $toMon); + $attrReportN = tuyaDecodeEF00Cmd($dest, $srcAddr, $srcEp, $cmd, $msg); } // End $clustId == "EF00" else { @@ -4365,9 +4365,9 @@ function decode8002($dest, $payload, $lqi) { } if (isset($supportType)) { if ($supportType == 'tuya') - $attrReportN = tuyaDecodeEF00Cmd($dest, $srcAddr, $srcEp, $cmd, $pl, $toMon); + $attrReportN = tuyaDecodeEF00Cmd($dest, $srcAddr, $srcEp, $cmd, $pl); else if ($supportType == 'tuya-zosung') - $attrReportN = tuyaDecodeZosungCmd($dest, $srcAddr, $srcEp, $cmd, $pl, $toMon); + $attrReportN = tuyaDecodeZosungCmd($dest, $srcAddr, $srcEp, $cmd, $pl); else parserLog("error", " Cluster specific command ".$clustId."-".$cmd.": unsupported type ".$supportType); } else { @@ -4419,11 +4419,15 @@ function decode8002($dest, $payload, $lqi) { $this->whoTalked[] = $dest.'/'.$srcAddr; - // Monitor if requested + // Monitor if requested (OBSOLETE way !! Use parserLog2() instead) if (isset($GLOBALS["dbgMonitorAddr"]) && !strcasecmp($GLOBALS["dbgMonitorAddr"], $srcAddr)) { foreach ($toMon as $monMsg) monMsgFromZigate($monMsg); // Send message to monitor } + // Flush monitoring messages (if any) from parserLog2() + foreach ($GLOBALS['toMon'] as $monMsg) + monMsgFromZigate($monMsg); // Send message to monitor + $GLOBALS['toMon'] = []; // Clear monitoring queue } // End decode8002() /* 8009/Network State Reponse */ diff --git a/core/php/AbeilleCmd-Tuya.php b/core/php/AbeilleCmd-Tuya.php index 847621f745..7dc0cc7a76 100644 --- a/core/php/AbeilleCmd-Tuya.php +++ b/core/php/AbeilleCmd-Tuya.php @@ -115,7 +115,7 @@ function tuyaCmd2Dp($abCmd) { return $dp; } - // Returns Tuya specific transaction ID (4 bytes) + // Returns Tuya specific transaction ID (2 bytes) function tuyaGenSqn() { global $tuyaTransId; $tuyaTransId++; @@ -144,7 +144,7 @@ function tuyaZosungCrc($message) { // Use cases: ED00 cluster support (Moes universal remote) function tuyaZosung($net, $addr, $ep, $cmd, $data) { - cmdLog('debug', " tuyaZosung(net=${net}, addr=${addr}, ep=${ep}, cmd=${cmd})"); + cmdLog2('debug', $addr, " tuyaZosung(net=${net}, addr=${addr}, ep=${ep}, cmd=${cmd})"); if ($cmd == '00') { // Send IR code $irMsg = array( @@ -172,13 +172,14 @@ function tuyaZosung($net, $addr, $ep, $cmd, $data) { // {name: 'unk3', type: DataType.uint8}, // {name: 'cmd', type: DataType.uint8}, // {name: 'unk4', type: DataType.uint16}, - $seq = '0012'; // TODO + $seq = tuyaGenSqn(); $length = sprintf("%08X", strlen($irMsgJson)); $unk1 = '00000000'; $unk2 = 'e004'; $unk3 = '01'; $cmd = '02'; $unk4 = '0000'; + cmdLog2('debug', $addr, " Cmd ED00-00: Seq=${seq}, Len=${length}"); $seq = AbeilleTools::reverseHex($seq); $len = AbeilleTools::reverseHex($length); @@ -200,14 +201,14 @@ function tuyaZosung($net, $addr, $ep, $cmd, $data) { $params = json_decode($data, true); $seq = $params['seq']; $pos = $params['pos']; - cmdLog('debug', " Cmd 03: Seq=${seq}, Pos=${pos}"); + cmdLog2('debug', $addr, " Cmd ED00-03: Seq=${seq}, Pos=${pos}"); $message = $GLOBALS['zosung_msg']['message']; $msgPart = substr($message, $pos); if ((strlen($msgPart) / 2) > 0x38) $msgPart = substr($msgPart, 0, 0x37 * 2); // Truncate to maxLen $msgPartCrc = tuyaZosungCrc($msgPart); - cmdLog('debug', " MsgPart=${msgPart}, MsgPartCrc=${msgPartCrc}"); + cmdLog2('debug', $addr, " MsgPart=${msgPart}, MsgPartCrc=${msgPartCrc}"); // Cmd 03 reminder // {name: 'zero', type: DataType.uint8}, diff --git a/core/php/AbeilleCmd.php b/core/php/AbeilleCmd.php index 64f1569923..300fc1a90b 100644 --- a/core/php/AbeilleCmd.php +++ b/core/php/AbeilleCmd.php @@ -24,10 +24,20 @@ include_once __DIR__.'/AbeilleCmd-Tuya.php'; include_once __DIR__.'/AbeilleZigateConst.php'; - function cmdLog($loglevel = 'NONE', $message = "", $isEnable = 1) { + // Log if proper log level + function cmdLog($level, $message = "", $isEnable = 1) { if ($isEnable == 0) return; - logMessage($loglevel, $message); + logMessage($level, $message); + } + + // Log if proper log level + // & monitor if proper address + function cmdLog2($level, $addr, $message) { + logMessage($level, $message); + + if (isset($GLOBALS["dbgMonitorAddr"]) && ($GLOBALS["dbgMonitorAddr"] != "") && ($addr == $GLOBALS["dbgMonitorAddr"])) + monMsgToZigate($addr, $message); } /* Get device infos. diff --git a/core/php/AbeilleParser-Tuya.php b/core/php/AbeilleParser-Tuya.php index c78774275e..7709661612 100644 --- a/core/php/AbeilleParser-Tuya.php +++ b/core/php/AbeilleParser-Tuya.php @@ -78,12 +78,10 @@ function tuyaGetDp($msg) { // Receive a datapoint, map it to a specific function an decode it. // Mapping is defined "per device" directly in its model (tuyaEF00/fromDevice). - function tuyaDecodeDp($ep, $dp, $mapping, &$toMon) { + function tuyaDecodeDp($addr, $ep, $dp, $mapping) { $dpId = $dp['id']; if (!isset($mapping[$dpId])) { - $m = " ".$dp['m'].": Unrecognized DP !"; - parserLog("debug", $m, "8002"); - $toMon[] = $m; + parserLog2("debug", $addr, " ".$dp['m'].": Unrecognized DP !", "8002"); return false; } @@ -139,7 +137,7 @@ function tuyaDecodeDp($ep, $dp, $mapping, &$toMon) { else $mode = "?"; $logMsg = " ".$dp['m']." => Mode = ".$dp['data']."/".$mode; - parserLog("debug", $logMsg, "8002"); + parserLog2("debug", $addr, $logMsg, "8002"); $attributeN = array( 'name' => $ep.'-mode', 'value' => $mode, @@ -150,7 +148,7 @@ function tuyaDecodeDp($ep, $dp, $mapping, &$toMon) { case "rcvValve-Status": $val = hexdec($dp['data']) % 2; $st = ($val == 1) ? "ON" : "OFF"; - parserLog("debug", " ".$dp['m']." => On/Off=".$val."/".$st, "8002"); + parserLog2("debug", $addr, " ".$dp['m']." => On/Off=".$val."/".$st, "8002"); $attributeN = array( 'name' => '0006-'.$ep.'-0000', 'value' => $val, @@ -202,14 +200,13 @@ function tuyaDecodeDp($ep, $dp, $mapping, &$toMon) { break; default: - parserLog("error", " Unknown Tuya function '".$func."' for dpId=".$dpId); + parserLog2("error", $addr, " Unknown Tuya function '".$func."' for dpId=".$dpId); $attributeN = false; break; } if (isset($logMsg)) { - parserLog("debug", $logMsg, "8002"); - $toMon[] = $logMsg; + parserLog2("debug", $addr, $logMsg, "8002"); } return $attributeN; } @@ -248,7 +245,7 @@ function tuyaDecodeEF00Cmd24($ep, $msg) { // self.log.logging("Tuya", "Debug", "send_timesynchronisation - %s/%s " % (NwkId, srcEp)) } - function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg, &$toMon) { + function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg) { $tCmds = array( "00" => array("name" => "TY_DATA_REQUEST", "desc" => "Gateway-side data request"), "01" => array("name" => "TY_DATA_RESPONE", "desc" => "Reply to MCU-side data request"), @@ -270,7 +267,7 @@ function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg, &$toMon) { if (($cmdId == "01") || ($cmdId == "02")) { // parserLog('debug', 'eq='.json_encode($eq)); if (!isset($eq['tuyaEF00']) || !isset($eq['tuyaEF00']['fromDevice'])) { - parserLog('debug', " No defined Tuya mapping => ignoring (msg=".$msg.")"); + parserLog2('debug', $addr, " No defined Tuya mapping => ignoring (msg=".$msg.")"); return []; } $mapping = $eq['tuyaEF00']['fromDevice']; @@ -278,11 +275,11 @@ function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg, &$toMon) { $tSqn = substr($msg, 0, 4); // uint16 $msg = substr($msg, 4); // Skip tSqn - parserLog("debug", " Tuya EF00 specific cmd ".$cmdId." (tSQN=".$tSqn.")", "8002"); + parserLog2("debug", $addr, " Tuya EF00 specific cmd ".$cmdId." (tSQN=".$tSqn.")", "8002"); while (strlen($msg) != 0) { $dp = tuyaGetDp($msg); - $a = tuyaDecodeDp($ep, $dp, $mapping, $toMon); + $a = tuyaDecodeDp($addr, $ep, $dp, $mapping); if ($a !== false) $attributesN[] = $a; else { // Unknown DP @@ -295,12 +292,12 @@ function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg, &$toMon) { $msg = substr($msg, $s); } } else if ($cmdId == "06") { // TY_DATA_SEARCH - parserLog('debug', " TY_DATA_SEARCH: ".$msg); + parserLog2('debug', $addr, " TY_DATA_SEARCH: ".$msg); $tSeq = substr($msg, 0, 4); $msg = substr($msg, 4); // Skip tSqn $dp = tuyaGetDp($msg); $mapping = $eq['tuyaEF00']['fromDevice']; - $a = tuyaDecodeDp($ep, $dp, $mapping, $toMon); + $a = tuyaDecodeDp($addr, $ep, $dp, $mapping); if ($a !== false) $attributesN[] = $a; // $tSeq = substr($msg, 0, 4); @@ -311,9 +308,9 @@ function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg, &$toMon) { // $m = "Seq=${tSeq}, Dp=${tDpId}, Type=${tDataType}, Len=${tLen}, ValueHex=".$tData; // parserLog('debug', " TY_DATA_SEARCH: ".$m); } else if ($cmdId == "11") { // TUYA_MCU_VERSION_RSP - parserLog('debug', " TUYA_MCU_VERSION_RSP: ".$msg); + parserLog2('debug', $addr, " TUYA_MCU_VERSION_RSP: ".$msg); } else if ($cmdId == "25") { // TUYA_INTERNET_STATUS - parserLog('debug', " Internet access status request => Answering 'connected'"); + parserLog2('debug', $addr, " Internet access status request => Answering 'connected'"); $tSqn = substr($msg, 0, 4); // uint16 $manufCode = isset($eq['manufCode']) ? '&manufCode='.$eq['manufCode'] : ''; msgToCmd(PRIO_NORM, "Cmd".$net."/".$addr."/cmd-tuyaEF00", "ep=".$ep."&cmd=internetStatus".$manufCode."&tuyaSqn=".$tSqn."&data=01"); @@ -322,7 +319,7 @@ function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg, &$toMon) { $cmdName = $tCmds[$cmdId]['name']; else $cmdName = $cmdId."/?"; - parserLog("debug", " Unsupported Tuya cmd ".$cmdName." => ignored", "8002"); + parserLog2("debug", $addr, " Unsupported Tuya cmd ".$cmdName." => ignored", "8002"); } // TODO: How to store unknown DP in discovery.json ? @@ -331,8 +328,23 @@ function tuyaDecodeEF00Cmd($net, $addr, $ep, $cmdId, $msg, &$toMon) { return $attributesN; } + // Compute CRC for given message + // Use cases: ED00 cluster support (Moes universal remote) + function tuyaZosungCrc($message) { + $crc = 0; + $len = strlen($message) / 2; + for($i = 0; $i < $len; $i++) { + $c = substr($message, $i * 2, 2); + // cmdLog('debug', " c=${c}, crc=".dechex($crc)); + $crc += hexdec($c); + $crc %= 0x100; + } + // cmdLog('debug', " crc=".dechex($crc)); + return sprintf("%02X", $crc); + } + // Use cases: E004+ED00 clusters support (Moes universal remote) - function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { + function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl) { $attrReportN = []; // Assuming cluster ED00 if ($cmdId == "00") { @@ -354,7 +366,7 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { $seqR = AbeilleTools::reverseHex($seq); $lenR = AbeilleTools::reverseHex($len); - parserLog("debug", " Tuya-Zosung cmd ED00-00: Seq=${seqR}, Len=${lenR}, Cmd=${cmd}"); + parserLog2("debug", $addr, " Tuya-Zosung cmd ED00-00: Seq=${seqR}, Len=${lenR}, Cmd=${cmd} => Replying with ED00-01 & 02."); $data = '00'.$seq.$len.$unk1.$unk2.$unk3.$cmd.$unk4; msgToCmd(PRIO_NORM, "Cmd".$net."/".$addr."/cmd-Generic", "ep=".$ep."&clustId=ED00&cmd=01&data=${data}"); @@ -373,11 +385,31 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { $GLOBALS['zosung'] = []; $GLOBALS['zosung'][$seqR] = array( - 'expSize' => $lenR, // Expected size - 'data' => [] + 'expected' => hexdec($lenR), // Expected size + 'received' => 0, // Received size + 'data' => '' ); } else if ($cmdId == "01") { - parserLog("debug", " Tuya-Zosung cmd ED00-01"); + // Cmd 01 reminder + // {name: 'zero', type: DataType.uint8}, + // {name: 'seq', type: DataType.uint16}, + // {name: 'length', type: DataType.uint32}, + // {name: 'unk1', type: DataType.uint32}, + // {name: 'unk2', type: DataType.uint16}, + // {name: 'unk3', type: DataType.uint8}, + // {name: 'cmd', type: DataType.uint8}, + // {name: 'unk4', type: DataType.uint16}, + $seq = substr($pl, 2, 4); + $len = substr($pl, 6, 8); + $unk1 = substr($pl, 14, 8); + $unk2 = substr($pl, 22, 4); + $unk3 = substr($pl, 26, 2); + $cmd = substr($pl, 28, 2); + $unk4 = substr($pl, 30, 4); + + $seqR = AbeilleTools::reverseHex($seq); + $lenR = AbeilleTools::reverseHex($len); + parserLog2("debug", $addr, " Tuya-Zosung cmd ED00-01: Seq=${seqR}, Len=${lenR}, Cmd=${cmd}"); } else if ($cmdId == "02") { // Cmd 02 reminder // {name: 'seq', type: DataType.uint16}, @@ -386,9 +418,9 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { $seqR = AbeilleTools::reverseHex(substr($pl, 0, 4)); $positionR = AbeilleTools::reverseHex(substr($pl, 4, 8)); $maxLen = substr($pl, 12, 2); - parserLog("debug", " Tuya-Zosung cmd ED00-02: Seq=${seqR}, Pos=${positionR}, MaxLen=${maxLen}"); + parserLog2("debug", $addr, " Tuya-Zosung cmd ED00-02: Seq=${seqR}, Pos=${positionR}, MaxLen=${maxLen}"); - parserLog("debug", " Replying with cmd ED00-03"); + parserLog2("debug", $addr, " Replying with cmd ED00-03"); $data = array( 'seq' => hexdec($seqR), 'pos' => hexdec($positionR), @@ -402,7 +434,6 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { // {name: 'position', type: DataType.uint32}, // {name: 'msgpart', type: DataType.octetStr}, // {name: 'msgpartcrc', type: DataType.uint8}, - $zero = substr($pl, 0, 2); $seq = substr($pl, 2, 4); $pos = substr($pl, 6, 8); $msgPart = substr($pl, 14, -2); // Rest is msgpart + msgpartcrc @@ -411,26 +442,32 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { $seqR = AbeilleTools::reverseHex($seq); $posR = AbeilleTools::reverseHex($pos); - parserLog("debug", " Tuya-Zosung cmd ED00-03: Seq=${seqR}, Pos=${posR}, MsgSize=d${msgSize}, CRC=${crc}"); + parserLog2("debug", $addr, " Tuya-Zosung cmd ED00-03: Seq=${seqR}, Pos=${posR}, MsgSize=d${msgSize}, CRC=${crc}"); + $cCrc = tuyaZosungCrc($msgPart); + parserLog2("debug", $addr, " MsgPart=${msgPart}, computedCRC=${cCrc}"); if (!isset($GLOBALS['zosung']) || !isset($GLOBALS['zosung'][$seqR])) { - parserLog("debug", " Unexpected message => Ignored"); + parserLog2("debug", $addr, " Unexpected message => Ignored"); return $attrReportN; } - // TODO - $GLOBALS['zosung'][$seqR]['data'] = $msgPart; + $GLOBALS['zosung'][$seqR]['data'] .= $msgPart; // Append to end + $GLOBALS['zosung'][$seqR]['received'] += $msgSize; - $expSize = $GLOBALS['zosung'][$seqR]['expSize']; - if (($posR + $msgSize) < $expSize) { + $recSize = $GLOBALS['zosung'][$seqR]['received']; + $expSize = $GLOBALS['zosung'][$seqR]['expected']; + parserLog2("debug", $addr, " recSize=d${recSize}, expSize=d${expSize}, posR=${posR}, msgSize=d${msgSize}"); + if ($recSize < $expSize) { // Need more datas - parserLog("debug", " Replying with cmd ED00-02: Need more datas"); + parserLog2("debug", $addr, " Replying with cmd ED00-02: Need more datas"); + $pos = sprintf("%08X", hexdec($posR) + $msgSize); $data = $seq.$pos.'38'; msgToCmd(PRIO_NORM, "Cmd".$net."/".$addr."/cmd-Generic", "ep=".$ep."&clustId=ED00&cmd=02&data=${data}"); } else { // All data received - parserLog("debug", " Replying with cmd ED00-04: All datas received"); + parserLog2("debug", $addr, " Replying with cmd ED00-04: All datas received"); + $data = '00'.$seq.'0000'; msgToCmd(PRIO_NORM, "Cmd".$net."/".$addr."/cmd-Generic", "ep=".$ep."&clustId=ED00&cmd=04&data=${data}"); } @@ -441,7 +478,7 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { // {name: 'zero1', type: DataType.uint16}, $seq = substr($pl, 2, 4); $seqR = AbeilleTools::reverseHex($seq); - parserLog("debug", " Tuya-Zosung cmd ED00-04: Seq=${seqR} => Replying with cmd ED00-05"); + parserLog2("debug", $addr, " Tuya-Zosung cmd ED00-04: Seq=${seqR} => Replying with cmd ED00-05"); // Cmd 05 reminder // {name: 'seq', type: DataType.uint16}, @@ -453,11 +490,11 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { // {name: 'seq', type: DataType.uint16}, // {name: 'zero', type: DataType.uint16}, $seq = substr($pl, 0, 4); - $zero = substr($pl, 4, 4); $seqR = AbeilleTools::reverseHex($seq); + parserLog2("debug", $addr, " Tuya-Zosung cmd ED00-05: Seq=${seqR}"); if (!isset($GLOBALS['zosung']) || !isset($GLOBALS['zosung'][$seqR])) { - parserLog("debug", " Unexpected message (seq ${seqR}) => Ignored"); + parserLog2("debug", $addr, " Unexpected message (seq ${seqR}) => Ignored"); return $attrReportN; } @@ -471,7 +508,7 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) { ); unset($GLOBALS['zosung'][$seqR]); } else { - parserLog("debug", " Unsupported Tuya-Zosung cmd ".$cmdId." => ignored"); + parserLog2("debug", $addr, " Unsupported Tuya-Zosung cmd ".$cmdId." => ignored"); } return $attrReportN; diff --git a/core/php/AbeilleParser.php b/core/php/AbeilleParser.php index 22beb91209..3378623b3d 100644 --- a/core/php/AbeilleParser.php +++ b/core/php/AbeilleParser.php @@ -168,6 +168,7 @@ ); $allErrorCode = $event + $zdpCode + $apsCode + $nwkCode + $macCode; + $toMon = []; // Monitoring messages from device to monitor only /* Parser log function. If 'dev mode' & 'debug' level: message can be filtered according to "debug.json" */ @@ -180,6 +181,22 @@ function parserLog($level, $msg, $type = '') { logMessage($level, $msg); } + /* Parser log & monitoring function. + If 'dev mode' & 'debug' level: message can be filtered according to "debug.json" + Note: Regarding monitoring messages they have to be flushed at some point. + */ + function parserLog2($level, $addr, $msg, $type = '') { + if (($type != '') && ($level == "debug")) { + global $dbgParserLog; + if (isset($dbgParserLog) && isset($dbgParserLog[$type])) + return; // Log disabled for this type + } + logMessage($level, $msg); + + if (isset($GLOBALS["dbgMonitorAddr"]) && !strcasecmp($GLOBALS["dbgMonitorAddr"], $addr)) + $GLOBALS['toMon'][] = $msg; + } + /* New function to send msg to Abeille. Msg format is now flexible and can transport a bunch of infos coming from zigbee event instead of splitting them into several messages to Abeille. */ diff --git a/docs/fr_FR/Changelog.rst b/docs/fr_FR/Changelog.rst index 818ebea906..08ef5e16ff 100644 --- a/docs/fr_FR/Changelog.rst +++ b/docs/fr_FR/Changelog.rst @@ -3,6 +3,7 @@ ChangeLog - Interne: AbeilleCmd: Nouvelles modifs pour support Tuya Zosung (universal remote). - Interne: Tuya parser: Support cmd EF00-06 (TY_DATA_SEARCH ?) revue. +- Interne: Cmd & parser: Amélioration fonction de 'monitoring. 231004-BETA-1 -------------