Skip to content

Commit

Permalink
Cmd fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Aug 14, 2024
1 parent 58ea655 commit 1004198
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions core/class/AbeilleCmdQueue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,15 @@ public static function addCmdToQueue2($priority, $net, $zgCmd, $payload = '', $a
} // End addCmdToQueue2()

/**
* Find cmd corresponding to SQNAPS
* Find cmd (by ref) corresponding to SQNAPS
* Returns: Found matching cmd, or null
* 'lastSent' is true if cmd is the last sent one for this zigate.
*/
function getCmd($zgId, $sqnAps, &$lastSent = false) {
$zg = $GLOBALS['zigates'][$zgId];
function &getCmd($zgId, $sqnAps, &$lastSent = false) {
$sentPri = $GLOBALS['zigates'][$zgId]['sentPri'];
$sentIdx = $GLOBALS['zigates'][$zgId]['sentIdx'];
foreach (range(priorityMax, priorityMin) as $prio) {
foreach ($zg['cmdQueue'][$prio] as $cmdIdx => $cmd) {
foreach ($GLOBALS['zigates'][$zgId]['cmdQueue'][$prio] as $cmdIdx => $cmd) {
if ($cmd['sqnAps'] == $sqnAps) {
// Is it the last sent cmd ?
if (($cmdIdx == $sentIdx) && ($prio == $sentPri))
Expand All @@ -427,7 +426,8 @@ function getCmd($zgId, $sqnAps, &$lastSent = false) {
}
}

return null;
static $error = [];
return $error;
}

function writeToDest($f, $port, $cmd, $datas) {
Expand Down Expand Up @@ -766,8 +766,8 @@ function processAcksQueue() {
}

else if ($msg['type'] == "8011") {
$cmd = $this->getCmd($zgId, $msg['sqnAps'], $lastSent);
if ($cmd == null) {
$cmd = &$this->getCmd($zgId, $msg['sqnAps'], $lastSent); // By ref
if ($cmd === []) {
cmdLog('debug', ' Corresponding cmd not found.');
continue;
}
Expand Down Expand Up @@ -798,7 +798,8 @@ function processAcksQueue() {

// If 'repeat' is set, checking if cmd must be retried
if (isset($cmd['repeat'])) {
if ($cmd['repeat'] != 0) {
$repeat = $cmd['repeat'];
if ($repeat != 0) {
cmdLog("debug", " Cmd ".$cmd['cmd']." failed (no ACK) but will be repeated.");
$cmd['repeat'] -= 1;
$GLOBALS['zigates'][$zgId]['available'] = 1; // Zigate is free again
Expand Down

0 comments on commit 1004198

Please sign in to comment.