Skip to content

Commit

Permalink
cmd fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Oct 4, 2024
1 parent e5eb987 commit 9a24bea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
6 changes: 4 additions & 2 deletions core/class/Abeille.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2307,11 +2307,12 @@ public static function publishMosquitto($queueId, $priority, $topic, $payload) {
}

$msg = array();
$msg['priority'] = $priority;
$msg['topic'] = $topic;
$msg['payload'] = $payload;
$msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES);

if (msg_send($queue, $priority, $msgJson, false, false, $error_code)) {
if (msg_send($queue, 1, $msgJson, false, false, $error_code)) {
log::add('Abeille', 'debug', " publishMosquitto(): Sent '".$msgJson."' to queue ".$queueId);
$queueStatus[$queueId] = "ok"; // Status ok
} else
Expand Down Expand Up @@ -2348,11 +2349,12 @@ public static function msgToCmd($priority, $topic, $payload = "") {
}

$msg = array();
$msg['priority'] = $priority;
$msg['topic'] = $topic;
$msg['payload'] = $payload;
$msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES);

if (msg_send($queue, $priority, $msgJson, false, false, $error_code)) {
if (msg_send($queue, 1, $msgJson, false, false, $error_code)) {
log::add('Abeille', 'debug', " msgToCmd(): Envoyé '".$msgJson."' vers queue ".$queueId);
$queueStatus[$queueId] = "ok"; // Status ok
} else
Expand Down
30 changes: 15 additions & 15 deletions core/class/AbeilleCmdProcess.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1975,11 +1975,11 @@ function processCmd($Command) {
$this->addCmdToQueue2(PRIO_NORM, $dest, $zgCmd, $data, $address, $addrMode);

// if ($addrMode == "02" ) {
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0006&attrId=0000" );
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+3), "ep=".$dstEp."&clustId=0008&attrId=0000" );
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0006&attrId=0000" );
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+3), "ep=".$dstEp."&clustId=0008&attrId=0000" );

// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+$Command['cmdParams']['onTime']), "ep=".$dstEp."&clustId=0006&attrId=0000" );
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+$Command['cmdParams']['onTime']), "ep=".$dstEp."&clustId=0008&attrId=0000" );
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+$Command['cmdParams']['onTime']), "ep=".$dstEp."&clustId=0006&attrId=0000" );
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$address."/readAttribute&time=".(time()+$Command['cmdParams']['onTime']), "ep=".$dstEp."&clustId=0008&attrId=0000" );
// }
return;
}
Expand Down Expand Up @@ -2185,7 +2185,7 @@ function processCmd($Command) {

$this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data);

$this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "Cmd".$dest."/0000/permitJoin", "Status" );
$this->sendToCmd(priorityInterrogation, "Cmd".$dest."/0000/permitJoin", "Status" );
} elseif ($mode == "stop") {
$cmd = "0049";
$data = "FFFC0000";
Expand All @@ -2201,7 +2201,7 @@ function processCmd($Command) {

$this->addCmdToQueue2(PRIO_NORM, $dest, $cmd, $data);

$this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "Cmd".$dest."/0000/permitJoin", "Status");
$this->sendToCmd(priorityInterrogation, "Cmd".$dest."/0000/permitJoin", "Status");
}
return;
} // End cmdName == 'zgSetPermitMode'
Expand Down Expand Up @@ -3890,11 +3890,11 @@ function processCmd($Command) {
$this->addCmdToQueue2(priorityUserCmd, $dest, $zgCmd, $data, $addr, $addrMode);

// if ($addrMode == "02") {
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3), "ep=".$dstEp."&clustId=0008&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3), "ep=".$dstEp."&clustId=0008&attrId=0000");

// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0008&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0008&attrId=0000");
// }
return;
}
Expand Down Expand Up @@ -3932,11 +3932,11 @@ function processCmd($Command) {
$this->addCmdToQueue2(priorityUserCmd, $dest, $zgCmd, $data, $addr, $addrMode);

// if ($addrMode == "02") {
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3), "ep=".$dstEp."&clustId=0008&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3), "ep=".$dstEp."&clustId=0008&attrId=0000");

// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0008&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0006&attrId=0000");
// $this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+3+$Command['cmdParams']['duration']), "ep=".$dstEp."&clustId=0008&attrId=0000");
// }
return;
}
Expand Down Expand Up @@ -4518,7 +4518,7 @@ function processCmd($Command) {
$this->addCmdToQueue2(priorityUserCmd, $dest, $zgCmd, $data, $addr, $addrMode);

if ($addrMode == "02") {
$this->publishMosquitto($abQueues['xToCmd']['id'], priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0300&attrId=0007" );
$this->sendToCmd(priorityInterrogation, "TempoCmd".$dest."/".$addr."/readAttribute&time=".(time()+2), "ep=".$dstEp."&clustId=0300&attrId=0007" );
}
return;
}
Expand Down
21 changes: 12 additions & 9 deletions core/class/AbeilleCmdQueue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,20 @@ public function addTempoCmdAbeille($topic, $msg, $priority) {
}
}

public function publishMosquitto($priority, $topic, $payload) {
global $abQueues;
$queue = msg_get_queue($abQueues['xToCmd']['id']);
public function sendToCmd($priority, $topic, $payload) {
// global $abQueues;
// $queue = msg_get_queue($abQueues['xToCmd']['id']);

$msg = array();
$msg['topic'] = $topic;
$msg['payload'] = $payload;
$msg = array(
'priority' => $priority,
'topic' => $topic,
'payload' => $payload,
);
$msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES);

if (msg_send($queue, $priority, $msgJson, false, false) == false) {
cmdLog('debug', ' publishMosquitto() ERROR: Could not add message '.$msgJson.' to queue xToCmd');
global $queueXToCmd;
if (msg_send($queueXToCmd, 1, $msgJson, false, false) == false) {
cmdLog('debug', ' sendToCmd() ERROR: Could not add message '.$msgJson.' to queue xToCmd');
}
}

Expand All @@ -120,7 +123,7 @@ public function execTempoCmdAbeille() {
continue;

// cmdLog('debug', 'execTempoCmdAbeille BEFORE - tempoMessageQueue='.json_encode($tempoMessageQueue));
$this->publishMosquitto($mqttMessage['priority'], $mqttMessage['topic'], $mqttMessage['params']);
$this->sendToCmd($mqttMessage['priority'], $mqttMessage['topic'], $mqttMessage['params']);
// msgToCmd()
// cmdLog('debug', 'execTempoCmdAbeille(): tempoMessageQueue='.json_encode($tempoMessageQueue[$key]));
// unset($tempoMessageQueue[$key]);
Expand Down
2 changes: 1 addition & 1 deletion core/php/AbeilleCliToQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$queueId = $_GET['queueId'];
else
$queueId = $abQueues['xToAbeille']['id'];
if (isset($dbgTcharp38)) logDebug("CliToQueue: queueId=".$queueId);
if (isset($dbgTcharp38)) logDebug("CliToQueue: queueId=".sprintf("0x%X", $queueId));
$queue = msg_get_queue($queueId);
if ($queue === false) {
if (isset($dbgTcharp38)) logDebug("CliToQueue: ERROR: Invalid queue ID ".$queueId);
Expand Down

0 comments on commit 9a24bea

Please sign in to comment.