diff --git a/core/class/Abeille.class.php b/core/class/Abeille.class.php index 0e19e57841..bca5c8facc 100644 --- a/core/class/Abeille.class.php +++ b/core/class/Abeille.class.php @@ -412,8 +412,10 @@ public static function cron() { log::add('Abeille', 'info', "cron(): ERREUR: Pb d'accès à la queue '".$queueName."' (id ".$queueId.")"); continue; } - if (msg_stat_queue($queue)["msg_qnum"] > 100) - log::add('Abeille', 'info', "cron(): ERREUR: La queue '".$queueName."' (id ".$queueId.") contient plus de 100 messages."); + if (msg_stat_queue($queue)["msg_qnum"] > 50) { + log::add('Abeille', 'error', "cron(): La queue '".$queueName."' (id ".$queueId.") contient plus de 50 messages => redémarrage des démons."); + self::deamon_start(); + } } // https://github.com/jeelabs/esp-link @@ -449,7 +451,7 @@ public static function cron() { $lastComm = strtotime($lastComm); // log::add('Abeille', 'info', "lastComm2=".$lastComm); if ((time() - $lastComm) > (2 * 60)) { - log::add('Abeille', 'info', "Pas de réponse de la Zigate ".$gtwId." depuis plus de 2min"); + log::add('Abeille', 'info', "Pas de réponse de la Zigate ".$gtwId." depuis plus de 2min => reset"); $zgType = $config['ab::gtwSubType'.$gtwId]; $zgPort = $config['ab::gtwPort'.$gtwId]; if (($zgType == "USB") || ($zgType == "USBv2")) { diff --git a/core/class/AbeilleCmdProcess.class.php b/core/class/AbeilleCmdProcess.class.php index 194f225305..f5609c37da 100755 --- a/core/class/AbeilleCmdProcess.class.php +++ b/core/class/AbeilleCmdProcess.class.php @@ -787,60 +787,6 @@ function readAttribute($priority, $dest, $addr, $dstEp, $clustId, $attribId, $ma // $this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data, $address); // } - /** - * reviewPriority() - * - * See if we need to change the priority reaquested for a message - * - * @param Command - * @return priority re-evaluated - * - */ - // function reviewPriority($Command) { - // if (isset($Command['priority'])) { - // // TODO: Eq Address and Group Address can't be distingueshed here. Probability to have a group address = eq address is low but exist. - // if (isset($Command['cmdParams']['address'])) { - // if ($NE = Abeille::byLogicalId($Command['dest'].'/'.$Command['cmdParams']['address'], 'Abeille')) { - // if ($NE->getIsEnable()) { - // if (( time() - strtotime($NE->getStatus('lastCommunication'))) < (60*$NE->getTimeout()) ) { - // if ($NE->getStatus('APS_ACK', '1') == '1') { - // return $Command['priority']; - // } - // else { - // cmdLog('debug', " NE n a pas repondu lors de precedente commande alors je mets la priorite au minimum."); - // return priorityLostNE; - // } - // } - // else { - // cmdLog('debug', " NE en Time Out alors je mets la priorite au minimum."); - // return priorityLostNE; - // } - // } - // else { - // /* Tcharp38: Preventing cmd to be sent if EQ is disabled is not good here. - // If EQ was disabled but now under pairing process (dev announce) - // this prevents interrogation of EQ and therefore reinclusion. - // This check should be done at source not here. At least don't filter - // requests from parser. */ - // // cmdLog('debug', " NE desactive, je n envoie pas de commande."); - // // return -1; - // return $Command['priority']; - // } - // } - // else { - // cmdLog('debug', " NE n existe pas dans Abeille, une annonce/une commande de groupe, je ne touche pas à la priorite."); - // return $Command['priority']; - // } - // } - // else { - // return $Command['priority']; - // } - // } - // else { - // cmdLog('debug', " priority not defined !!!"); - // return priorityInterrogation; - // } - // } /** * processCmd() @@ -904,52 +850,14 @@ function processCmd($Command) { // } // abeilleList abeilleListAll - if (isset($Command['abeilleList'])) { + if ($Command['name'] == 'abeilleList') { + cmdLog('debug', " Get Abeilles List", $this->debug['processCmd']); // $this->addCmdToQueue($priority,$dest,"0015","0000",""); $this->addCmdToQueue2(PRIO_NORM, $dest, "0015"); return; } - if (isset($Command['setCertificationCE'])) { - cmdLog('debug', " setCertificationCE", $this->debug['processCmd']); - $cmd = "0019"; - $data = "01"; - - // $length = sprintf("%04s", dechex(strlen($data) / 2)); - // $this->addCmdToQueue($priority, $dest, $cmd, $length, $data); - $this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data); - return; - } - - if (isset($Command['setCertificationFCC'])) { - cmdLog('debug', " setCertificationFCC", $this->debug['processCmd']); - $cmd = "0019"; - $data = "02"; - - // $length = sprintf("%04s", dechex(strlen($data) / 2)); - // $this->addCmdToQueue($priority, $dest, $cmd, $length, $data); - $this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data); - return; - } - - - // // https://github.com/fairecasoimeme/ZiGate/issues/145 - // // PHY_PIB_TX_POWER_DEF (default - 0x80) - // // PHY_PIB_TX_POWER_MIN (minimum - 0) - // // PHY_PIB_TX_POWER_MAX (maximum - 0xbf) - // if (isset($Command['cmdParams']['txPower']) ) { // Obsolete !! Replaced by zgSetTxPower - // cmdLog('debug', " TxPower", $this->debug['processCmd']); - // $cmd = "0806"; - // $data = $Command['cmdParams']['txPower']; - // if ($data < 10 ) $data = '0'.$data; - - // // $length = sprintf("%04s", dechex(strlen($data) / 2)); - // // $this->addCmdToQueue($priority, $dest, $cmd, $length, $data); - // $this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data); - // return; - // } - //---------------------------------------------------------------------- // Bind // Title => 000B57fffe3025ad (IEEE de l ampoule) @@ -1716,55 +1624,6 @@ function processCmd($Command) { return; } - // /* Expected format: - // net/0000 ActiveEndpointRequest address=*/ - // if (isset($Command['ActiveEndPoint'])) // OBSOLETE: Use getActiveEndpoints instead - // { - // $cmd = "0045"; - - // // - - // $address = $Command['cmdParams']['address']; // -> 4 - - // // 4 = 4/2 => 2 - // // $length = "0002"; - - // $data = $address; - - // // $this->addCmdToQueue($priority, $dest, $cmd, $length, $data, $address); - // $this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data, $address); - // return; - // } - - //---------------------------------------------------------------------------- - // OBSOLETE: Replaced by getNwkAddress() - // if (isset($Command['Network_Address_request'])) - // { - // $cmd = "0040"; - - // // -> 4 - // // -> 16 - // // -> 2 - // // -> 2 - // // Request Type: - // // 0 = Single Request 1 = Extended Request - // // -> 24 / 2 = 12 => 0x0C - - // $address = $Command['cmdParams']['address']; - // $IeeeAddress = $Command['IEEEAddress']; - // $requestType = "01"; - // $startIndex = "00"; - - // $data = $address.$IeeeAddress.$requestType.$startIndex ; - // // $length = "000C"; // A verifier - - // cmdLog('debug', ' Network_Address_request: '.$data.' - '.$length, $this->debug['processCmd'] ); - - // // $this->addCmdToQueue($priority, $dest, $cmd, $length, $data, $address); - // $this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data, $address); - // return; - // } - // Don't know how to make it works if ($Command['name'] == 'touchLinkFactoryResetTarget') { @@ -2183,37 +2042,6 @@ function processCmd($Command) { return; } - // if (isset($Command['getManufacturerName']) && isset($Command['cmdParams']['address'])) - // { - // if ($Command['cmdParams']['destinationEndpoint'] == "" ) { $Command['cmdParams']['destinationEndpoint'] = "01"; } - // $this->readAttribute(PRIO_NORM, $dest, $Command['cmdParams']['address'], $Command['cmdParams']['destinationEndpoint'], "0000", "0004"); - // return; - // } - - // if (isset($Command['getName']) && isset($Command['cmdParams']['address'])) - // { - // if ($Command['cmdParams']['destinationEndpoint'] == "" ) { $Command['cmdParams']['destinationEndpoint'] = "01"; } - // $this->readAttribute(PRIO_NORM, $dest, $Command['cmdParams']['address'], $Command['cmdParams']['destinationEndpoint'], "0000", "0005"); - // return; - // } - - // if (isset($Command['getLocation']) && isset($Command['cmdParams']['address'])) - // { - // if ($Command['cmdParams']['destinationEndpoint'] == "" ) { $Command['cmdParams']['destinationEndpoint'] = "01"; } - // $this->readAttribute(PRIO_NORM, $dest, $Command['cmdParams']['address'], $Command['cmdParams']['destinationEndpoint'], "0000", "0010"); - // return; - // } - - // Tcharp38: Seems no longer used - // if (isset($Command['setLocation']) && isset($Command['cmdParams']['address'])) - // { - // if ($Command['location'] == "" ) { $Command['location'] = "Not Def"; } - // if ($Command['cmdParams']['destinationEndpoint'] == "" ) { $Command['cmdParams']['destinationEndpoint'] = "01"; } - - // $this->setParam2( $dest, $Command['cmdParams']['address'], "0000", "0010",$Command['cmdParams']['destinationEndpoint'],$Command['location'], "42" ); - // return; - // } - if ($Command['name'] == 'MgtLeave') { // Zigbee specification @@ -2298,7 +2126,7 @@ function processCmd($Command) { * Zigate specific commands */ - // Zigate specific command + // Zigate specific command: Set mode (raw, hybrid, normal) if ($cmdName == 'zgSetMode') { $mode = $Command['cmdParams']['mode']; if ($mode == "raw") { @@ -2312,8 +2140,34 @@ function processCmd($Command) { return; } + // Zigate specific command: Set certfication (CE, FCC) + else if ($cmdName == 'zgSetCertification') { + $required = ['certif']; + if (!$this->checkRequiredParams($required, $Command)) + return; + + $zgCmd = "0019"; + $certif = $Command['cmdParams']['certif']; + if ($certif == "CE") + $data = "01"; + else if ($certif == "FCC") + $data = "02"; + else { + cmdLog('error', ' zgSetCertification: Certification invalide ! ('.$certif.')'); + return; + } + + cmdLog('debug', " zgSetCertification: Certif=${data}/${certif}"); + $this->addCmdToQueue2(PRIO_NORM, $dest, $zgCmd, $data); + return; + } + // Zigate specific command else if ($cmdName == 'zgSetPermitMode') { + $required = ['mode']; + if (!$this->checkRequiredParams($required, $Command)) + return; + $mode = $Command['cmdParams']['mode']; if ($mode == "start") { $cmd = "0049"; diff --git a/core/class/AbeilleCmdQueue.class.php b/core/class/AbeilleCmdQueue.class.php index b2aac5f5b5..dca5c8c71f 100755 --- a/core/class/AbeilleCmdQueue.class.php +++ b/core/class/AbeilleCmdQueue.class.php @@ -602,7 +602,7 @@ function processCmdQueues() { if (isset($GLOBALS["dbgMonitorAddr"]) && ($cmd['addr'] != "") && ($GLOBALS["dbgMonitorAddr"] != "") && !strncasecmp($cmd['addr'], $GLOBALS["dbgMonitorAddr"], 4)) monMsgToZigate($cmd['addr'], $cmd['cmd'].'-'.$cmd['datas']); // Monitor this addr ? - cmdLog('debug', " Zigate=".json_encode($GLOBALS['zigates'][$zgId])); + // cmdLog('debug', " Zigate=".json_encode($GLOBALS['zigates'][$zgId])); } } // End zigates loop } diff --git a/core/config/AbeilleInternalCmds.json b/core/config/AbeilleInternalCmds.json index 6444b98cf7..15e2f986f4 100644 --- a/core/config/AbeilleInternalCmds.json +++ b/core/config/AbeilleInternalCmds.json @@ -40,8 +40,6 @@ "WindowsCoveringGroup": {}, "abeilleList": {}, - "setCertificationCE": {}, - "setCertificationFCC": {}, "setExtendedPANID": {}, "bind": {}, "setReportRaw": {}, @@ -56,6 +54,7 @@ "MgtLeave": {}, "Remove": {}, "zgSetMode": {}, + "zgSetCertification": {}, "zgSetPermitMode": {}, "permitJoin": {}, "zgGetNetworkStatus": {}, diff --git a/core/php/AbeilleParser.php b/core/php/AbeilleParser.php index fa26459732..076326f0ae 100644 --- a/core/php/AbeilleParser.php +++ b/core/php/AbeilleParser.php @@ -201,9 +201,15 @@ function parserLog2($level, $addr, $msg, $type = '') { 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. */ function msgToAbeille2($msg) { + $msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES); global $queueXToAbeille; - if (msg_send($queueXToAbeille, 1, json_encode($msg, JSON_UNESCAPED_SLASHES), false, false, $errCode) == false) { - parserLog("debug", "msgToAbeille2(): ERROR ".$errCode); + // Note: '@' to suppress PHP warning message. + if (@msg_send($queueXToAbeille, 1, $msgJson, false, false, $errCode) == false) { + // Err 11 = EAGAIN = Queue full ? + $errDesc = ""; + if ($errCode == 11) + $errDesc = "/queue FULL"; + parserLog("debug", "msgToAbeille2(): ERROR ${errCode}${errDesc}"); } } diff --git a/core/php/AbeilleSerialRead.php b/core/php/AbeilleSerialRead.php index 936420f277..9f09922860 100644 --- a/core/php/AbeilleSerialRead.php +++ b/core/php/AbeilleSerialRead.php @@ -16,7 +16,6 @@ /* Developers mode ? */ if (file_exists(dbgFile)) { - // include_once dbgFile; /* Dev mode: enabling PHP errors logging */ error_reporting(E_ALL); ini_set('error_log', __DIR__.'/../../../../log/AbeillePHP.log'); diff --git a/desktop/js/Abeille.js b/desktop/js/Abeille.js index 8ac56cb71a..ae5a85ff05 100755 --- a/desktop/js/Abeille.js +++ b/desktop/js/Abeille.js @@ -1576,9 +1576,8 @@ function sendZigate(action, param) { else payload = "value=0"; break; case "setCertif": - if (param == "CE") - topic = "CmdAbeille" + zgId + "/0000/setCertificationCE"; - else topic = "CmdAbeille" + zgId + "/0000/setCertificationFCC"; + topic = "CmdAbeille" + zgId + "/0000/zgSetCertification"; + payload = param; // 'CE' or 'FCC' break; case "startNetwork": // Not required for end user but for developper. topic = "CmdAbeille" + zgId + "/0000/zgStartNetwork"; diff --git a/docs/fr_FR/Changelog.md b/docs/fr_FR/Changelog.md index 199acc6e14..708300a5f5 100644 --- a/docs/fr_FR/Changelog.md +++ b/docs/fr_FR/Changelog.md @@ -15,6 +15,9 @@ - Amélioration: Cmd: Ajout support 'repeat' pour repeter une action jusqu'a acquittement (Attention !! Limiter son usage). - Améliorations: Interne cmd. - Améliorations: Interne main daemon: Config sauvé en global. +- Amélioration: Interne parser: Suppression warning si queue 'main' pleine. +- Amélioration: Redémarrage de tous les démons si une des queues est saturée (>50 messages). +- Amélioration: Interne cmd: setCertificationCE/FCC => 'zgSetCertification'. ## 240808-BETA-1