diff --git a/core/class/AbeilleParser.class.php b/core/class/AbeilleParser.class.php index 533cf7716..53cd88100 100755 --- a/core/class/AbeilleParser.class.php +++ b/core/class/AbeilleParser.class.php @@ -483,38 +483,6 @@ function deviceAnnounce($net, $addr, $ieee, $macCapa, $rejoin) { } } - // /* Update device infos. - // As opposed to 'deviceUpdate()', info is NOT coming from the device himself. */ - // function updateDevice($net, $addr, $updates) { - // parserLog('debug', ' updateDevice('.$net.', '.$addr.', '.json_encode($updates).')'); - // if (isset($updates['ieee'])) - // $ieee = $updates['ieee']; - // else - // $ieee = null; - // $eq = &getDevice($net, $addr, $ieee, $newDev); // By ref - - // $confirmed = array(); - // foreach ($updates as $updKey => $updVal) { - // if ($updKey == 'ieee') - // continue; // This is already covered - // if (!isset($eq[$updKey]) || ($eq[$updKey] != $updVal)) { - // $eq[$updKey] = $updVal; - // $confirmed[$updKey] = $updVal; - // } - // } - - // // Any changes to report to Abeille ? - // if (count($confirmed) > 0) { - // $msg = array( - // 'type' => 'deviceUpdates', - // 'net' => $net, - // 'addr' => $addr, - // 'updates' => $confirmed, - // ); - // msgToAbeille2($msg); - // } - // } - /* There are device infos updates (ex: endpoints, manufId, modelId, location, ...). */ function deviceUpdates($net, $addr, $ep, $updates = []) { parserLog('debug', " deviceUpdates(${net}, ${addr}, EP=${ep}, Upd=".json_encode($updates, JSON_UNESCAPED_SLASHES).")"); diff --git a/core/class/AbeilleTools.class.php b/core/class/AbeilleTools.class.php index f1c6d8ea7..279a818f2 100755 --- a/core/class/AbeilleTools.class.php +++ b/core/class/AbeilleTools.class.php @@ -1170,5 +1170,17 @@ public static function base64url2base64($data) { return $b64; } + + // Returns 'msg_send' error description + public static function getMsgSendErr($errCode) { + $errDesc = array( + '11' => 'Queue full', + '13' => 'Permission denied' + ); + if (isset($errDesc[$errCode])) + return $errDesc[$errCode]; + else + return "?"; + } } ?> diff --git a/core/php/AbeilleCmd.php b/core/php/AbeilleCmd.php index eee9e3e88..baf8edf12 100644 --- a/core/php/AbeilleCmd.php +++ b/core/php/AbeilleCmd.php @@ -156,8 +156,9 @@ function msgToCmd($topic, $payload = '') { global $abQueues; $queue = msg_get_queue($abQueues["xToCmd"]["id"]); - if (msg_send($queue, 1, $msgJson, false, false, $errCode) == false) { - cmdLog("debug", "msgToCmd(): ERROR ".$errCode); + // Note: '@' to suppress PHP warning message. + if (@msg_send($queue, 1, $msgJson, false, false, $errCode) == false) { + cmdLog("debug", " msgToCmd(xToCmd) ERROR ${errCode}/".AbeilleTools::getMsgSendErr($errCode)); } } @@ -166,8 +167,9 @@ function msgToAbeille($msg) { global $abQueues; $queue = msg_get_queue($abQueues["xToAbeille"]["id"]); - if (msg_send($queue, 1, json_encode($msg), false, false, $errCode) == false) { - cmdLog("debug", "msgToAbeille(): ERROR ".$errCode); + // Note: '@' to suppress PHP warning message. + if (@msg_send($queue, 1, json_encode($msg), false, false, $errCode) == false) { + cmdLog("debug", " msgToAbeille() ERROR ${errCode}/".AbeilleTools::getMsgSendErr($errCode)); } } diff --git a/core/php/AbeilleParser.php b/core/php/AbeilleParser.php index 076326f0a..4e451fba7 100644 --- a/core/php/AbeilleParser.php +++ b/core/php/AbeilleParser.php @@ -205,11 +205,7 @@ function msgToAbeille2($msg) { global $queueXToAbeille; // 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}"); + parserLog("debug", "msgToAbeille2() ERROR ${errCode}/".AbeilleTools::getMsgSendErr($errCode)); } } @@ -223,16 +219,18 @@ function msgToCmd($prio, $topic, $payload = '') { $msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES); global $queueXToCmd; - if (msg_send($queueXToCmd, 1, $msgJson, false, false, $errCode) == false) { - parserLog("debug", " ERROR: msgToCmd(): Can't write to 'queueXToCmd', error=".$errCode); + // Note: '@' to suppress PHP warning message. + if (@msg_send($queueXToCmd, 1, $msgJson, false, false, $errCode) == false) { + parserLog("debug", " msgToCmd(queueXToCmd) ERROR ${errCode}/".AbeilleTools::getMsgSendErr($errCode)); } } function msgToCmdAck($msg) { $msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES); global $queueParserToCmdAck; - if (msg_send($queueParserToCmdAck, 1, $msgJson, false, false) == false) { - parserLog("error", " ERROR: Can't send msg to 'queueParserToCmdAck'. msg=".$msgJson); + // Note: '@' to suppress PHP warning message. + if (@msg_send($queueParserToCmdAck, 1, $msgJson, false, false, $errCode) == false) { + parserLog("debug", " msgToCmd(queueParserToCmdAck) ERROR ${errCode}/".AbeilleTools::getMsgSendErr($errCode)); } }