From 70bf8aa5602d3b716fac3e440621674c4d850ac3 Mon Sep 17 00:00:00 2001 From: Tcharp38 Date: Fri, 20 Sep 2024 15:38:55 +0200 Subject: [PATCH] parser: mktime issue: poch doesn't fit in a PHP integer --- core/class/AbeilleCmdQueue.class.php | 8 ++------ core/class/AbeilleParser.class.php | 15 ++++++++++----- docs/fr_FR/Changelog.md | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/core/class/AbeilleCmdQueue.class.php b/core/class/AbeilleCmdQueue.class.php index 3d30c0c61..24221e2fb 100755 --- a/core/class/AbeilleCmdQueue.class.php +++ b/core/class/AbeilleCmdQueue.class.php @@ -176,7 +176,7 @@ public static function pushZigateCmd($zgId, $pri, $zgCmd, $payload, $repeat, $ad 'cmd' => $zgCmd, // Zigate message type 'datas' => $payload, 'zgOnly' => zgIsZigateOnly($zgCmd), // Msg for Zigate only if true, not to be transmitted - 'status' => '', // '', 'SENT', '8000', '8012' or '8702', '8011' + 'status' => '', // '', 'SENT' 'try' => maxRetryDefault + 1, // Number of retries if failed 'sentTime' => 0, // For lost cmds timeout // Timeout: Zigate has 7s internal timeout when ACK @@ -789,11 +789,7 @@ function checkZigatesStatus() { if ($cmd['status'] == '') continue; // Not sent yet - // Timeout: At least 4sec to let Zigate do its job but is that enough ? - // if ($cmd['ackAps']) - // $timeout = 8; // Zigate has 7s internal timeout when ACK - // else - // $timeout = 4; + $timeout = $cmd['timeout']; if ($cmd['sentTime'] + $timeout > time()) continue; // Timeout not reached yet diff --git a/core/class/AbeilleParser.class.php b/core/class/AbeilleParser.class.php index 1c93170b9..213f6aa2f 100755 --- a/core/class/AbeilleParser.class.php +++ b/core/class/AbeilleParser.class.php @@ -3294,11 +3294,16 @@ function decode8002($dest, $payload, $lqi) { // PHP uses 00:00:00 @1st of jan 1970 (Linux ref) // Attr 0007, type uint32/0x23 $lt = localtime(null, true); - $localTime = mktime($lt['tm_hour'], $lt['tm_min'], $lt['tm_sec'], $lt['tm_mon'], $lt['tm_mday'], $lt['tm_year']); - $localTime -= mktime(0, 0, 0, 1, 1, 2000); // PHP to Zigbee shift - $localTime = sprintf("%04X", $localTime); - msgToCmd(PRIO_NORM, "Cmd".$dest."/".$srcAddr."/sendReadAttributesResponse", 'ep='.$srcEp.'&clustId='.$clustId.'&attrId='.$attrId.'&status=00&attrType=23&attrVal='.$localTime); - parserLog2('debug', $srcAddr, " Attribute 0007/LocalTime: Answering to device"); + // $localTime = @mktime($lt['tm_hour'], $lt['tm_min'], $lt['tm_sec'], $lt['tm_mon'], $lt['tm_mday'], $lt['tm_year']); + $localTime = @mktime($lt['tm_hour']); + if ($localTime === false) { // mktime(): Epoch doesn't fit in a PHP integer + parserLog2('error', $srcAddr, " Attribute 0007/LocalTime: CAN'T answer to device. mktime() failed."); + } else { + $localTime -= mktime(0, 0, 0, 1, 1, 2000); // PHP to Zigbee shift + $localTime = sprintf("%04X", $localTime); + msgToCmd(PRIO_NORM, "Cmd".$dest."/".$srcAddr."/sendReadAttributesResponse", 'ep='.$srcEp.'&clustId='.$clustId.'&attrId='.$attrId.'&status=00&attrType=23&attrVal='.$localTime); + parserLog2('debug', $srcAddr, " Attribute 0007/LocalTime: Answering to device"); + } } else { parserLog2('debug', $srcAddr, " WARNING: Unsupported time cluster attribute ".$attrId); } diff --git a/docs/fr_FR/Changelog.md b/docs/fr_FR/Changelog.md index 3bc610042..534984098 100644 --- a/docs/fr_FR/Changelog.md +++ b/docs/fr_FR/Changelog.md @@ -10,6 +10,7 @@ - Corrections: Interne: install.php & AbeilleTools.class.php - Amélioration: Flasher PI Zigate: Création package standalone. - Correction: Page santé. Crash interne si plusieurs autre passerelles désactivées. +- Correction: Parser: mktime() sur systeme 32bits. ## 240902-BETA-1