Skip to content

Commit

Permalink
Removed some useless cmds from Zigate + added set TX power to advanced
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed May 17, 2024
1 parent fbfa45c commit 53a671c
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 524 deletions.
4 changes: 2 additions & 2 deletions core/ajax/AbeilleZigate.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function logToFile($msg = "")
$msg = array();
$msg['topic'] = $topic;
$msg['payload'] = $payload;
$msgJson = json_encode($msg);
$msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES);

$queue = msg_get_queue($abQueues['xToCmd']['id']);
if (msg_send($queue, 1, $msgJson, false, false) == false) {
Expand All @@ -72,7 +72,7 @@ function logToFile($msg = "")
"type" => $type,
"network" => $network
);
$msgJson = json_encode($msg);
$msgJson = json_encode($msg, JSON_UNESCAPED_SLASHES);

if (msg_send($queue, 1, $msgJson, false, false) == false) {
$error = "Could not send msg to 'xToParser': msg=".$msgJson;
Expand Down
27 changes: 14 additions & 13 deletions core/class/Abeille.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,15 @@ public static function cron() {
// Checking how many gateways are in pairing mode
$count = 0;
for ($gtwId = 1; $gtwId <= $GLOBALS['maxGateways']; $gtwId++) {
if (self::checkInclusionStatus("Abeille".$gtwId) == 1) {
Abeille::publishMosquitto($abQueues['xToCmd']['id'], PRIO_NORM, "CmdAbeille".$gtwId."/0000/permitJoin", "Status");
$incStatus = self::checkInclusionStatus("Abeille${gtwId}");
log::add('Abeille', 'debug', "cron(): Abeille${gtwId} => inclusion status = ${incStatus}");
if ($incStatus === 1) {
Abeille::publishMosquitto($abQueues['xToCmd']['id'], PRIO_NORM, "CmdAbeille${gtwId}/0000/permitJoin", "Status");
$count++;
}
}
if ($count > 1)
message::add("Abeille", "Attention !! Vous avez plusieurs (${count}) passerelles en mode inclusion.");
message::add("Abeille", "Attention !! Vous avez plusieurs passerelles en mode inclusion.");

// log::add( 'Abeille', 'debug', 'cron(): Fin ------------------------------------------------------------------------------------------------------------------------' );
} // End cron()
Expand Down Expand Up @@ -1019,15 +1021,14 @@ public static function postSave() {
}

/* Returns inclusion status: 1=include mode, 0=normal, -1=ERROR */
public static function checkInclusionStatus($dest) {
// Return: Inclusion status or -1 if error
$ruche = Abeille::byLogicalId($dest.'/0000', 'Abeille');

if ($ruche) {
// echo "Join status collection\n";
$cmdJoinStatus = $ruche->getCmd('Info', 'permitJoin-Status');
if ($cmdJoinStatus) {
return $cmdJoinStatus->execCmd();
public static function checkInclusionStatus($net) {
$eqLogic = eqLogic::byLogicalId($net.'/0000', 'Abeille');
if (is_object($eqLogic)) {
$cmdJoinStatus = $eqLogic->getCmd('info', 'permitJoin-Status');
if (is_object($cmdJoinStatus)) {
$incStatus = $cmdJoinStatus->execCmd();
if (($incStatus === 0) || ($incStatus === 1))
return $incStatus;
}
}

Expand Down Expand Up @@ -1794,7 +1795,7 @@ public static function msgFromParser($msg) {
if (isset($eqLogic)) {
$eqLogic->setIsEnable(0);
/* Display message only if NOT in include mode */
if (self::checkInclusionStatus($net) != 1)
if (self::checkInclusionStatus($net) !== 1)
message::add("Abeille", $eqLogic->getHumanName().": A quitté le réseau => désactivé.", '');
$eqLogic->save();
$eqLogic->refresh();
Expand Down
316 changes: 33 additions & 283 deletions core/class/AbeilleCmdProcess.class.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/config/AbeilleInternalCmds.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"abeilleList": {},
"setCertificationCE": {},
"setCertificationFCC": {},
"TxPower": {},
"setExtendedPANID": {},
"bind": {},
"setReportRaw": {},
Expand All @@ -65,6 +64,7 @@
"zgSoftReset": {},
"zgSetTimeServer": {},
"zgGetTimeServer": {},
"zgSetTxPower": {},
"zgGetTxPower": {},
"zgStartNetwork": {},
"zgSetLed": {},
Expand Down
75 changes: 0 additions & 75 deletions core/config/devices/KiwiHC16_Test_01/KiwiHC16_Test_01.json

This file was deleted.

115 changes: 1 addition & 114 deletions core/config/rucheCommand.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,6 @@
"invertBinary": "0",
"template": ""
},
"Set inclusion mode": {
"name": "Set inclusion mode",
"comment": "Readded this function for case #2476",
"isHistorized": "0",
"isVisible": "1",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "zgSetPermitMode",
"request": "mode=start"
}
},
"Get Inclusion Status": {
"name": "Get Inclusion Status",
"isHistorized": "0",
"isVisible": "0",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "permitJoin",
"request": "Status"
},
"display": {
"forceReturnLineAfter": "1"
}
},
"permitJoin-Status": {
"name": "Inclusion Status",
"isHistorized": "0",
Expand Down Expand Up @@ -277,17 +251,6 @@
"invertBinary": "0",
"template": ""
},
"Network Status Request": {
"name": "Network Status Request (Not implemented)",
"isHistorized": "0",
"isVisible": "0",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "networkStatus",
"request": "Request"
}
},
"joinLeave-IEEE": {
"name": "joinLeave",
"isHistorized": "1",
Expand All @@ -297,38 +260,6 @@
"invertBinary": "0",
"template": ""
},
"Factory New Reset": {
"name": "Factory New Reset",
"isHistorized": "0",
"isVisible": "0",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "FactoryNewReset",
"request": "FactoryNewReset"
},
"display": {
"forceReturnLineAfter": "1"
}
},
"Network-Bind": {
"name": "Last Bind",
"isHistorized": "0",
"isVisible": "0",
"Type": "info",
"subType": "string",
"invertBinary": "0",
"template": ""
},
"Network-Report": {
"name": "Last Report",
"isHistorized": "0",
"isVisible": "0",
"Type": "info",
"subType": "string",
"invertBinary": "0",
"template": ""
},
"Group-Membership": {
"isVisible": 0,
"name": "Groups",
Expand All @@ -342,52 +273,8 @@
"visibilityCategory": "Network"
}
},
"Set Power 0": {
"name": "Set Power (0dBm)",
"isHistorized": "0",
"isVisible": "0",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "TxPower",
"request": "00"
}
},
"Set Power 9": {
"name": "Set Power (-9dBm)",
"isHistorized": "0",
"isVisible": "0",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "TxPower",
"request": "34"
}
},
"Set Power 20": {
"name": "Set Power (-20dBm)",
"isHistorized": "0",
"isVisible": "0",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "TxPower",
"request": "28"
}
},
"Set Power 32": {
"name": "Set Power (-32dBm)",
"isHistorized": "0",
"isVisible": "0",
"Type": "action",
"subType": "other",
"configuration": {
"topic": "TxPower",
"request": "20"
}
},
"ZiGate-Power": {
"name": "ZiGate-Power",
"name": "TX power",
"isHistorized": "0",
"isVisible": "0",
"Type": "info",
Expand Down
5 changes: 3 additions & 2 deletions desktop/js/Abeille.js
Original file line number Diff line number Diff line change
Expand Up @@ -1595,8 +1595,9 @@ function sendZigate(action, param) {
payload = "";
break;
case "setTXPower":
topic = "CmdAbeille" + zgId + "/0000/TxPower";
payload = "ff"; // TODO
topic = "CmdAbeille" + zgId + "/0000/zgSetTxPower";
var power = $("#idZgTxPower").val();
payload = "txPower=" + power; // TODO
break;
case "getTime":
topic = "CmdAbeille" + zgId + "/0000/zgGetTimeServer";
Expand Down
7 changes: 6 additions & 1 deletion desktop/php/Abeille-Eq-Advanced-Zigate.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ function addZgButton($name, $class, $onclick, $onclick2 = "", $leftMargin = true
</div>
<div class="col-sm-5" advInfo="ZiGate-Power">
<input type="text" value="" readonly>
<!-- <a class="btn btn-default" onclick="sendZigate('getTXPower', '')">{{Lire}}</a> -->
<?php addZgButton("{{Lire}}", "btn-default", 'getTXPower', ''); ?>
<select id="idZgTxPower" style="width:80px; margin-left:4px" title="{{Puissance TX}}">
<option value=00>{{Min}}</option>
<option value=80 selected>{{Défaut}}</option>
<option value=BF>{{Max}}</option>
</select>
<?php addZgButton("{{Appliquer}}", "btn-default", 'setTXPower', ''); ?>
</div>
</div>

Expand Down
32 changes: 0 additions & 32 deletions desktop/php/AbeilleFormAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,38 +149,6 @@ function sendMessageFromFormToCmd($topic, $payload) {
}
break;
}

// // TX Power
// foreach ( $zigateIds as $zigateId ) {
// if ( $_POST['submitButton'] == 'TxPower Z'.$zigateId ) {
// echo "TxPower request processing";
// sendMessageFromFormToCmd('CmdAbeille'.$zigateId.'/0000/TxPower', $_POST['TxPowerValue'] );
// }
// }

// // Set Extended PANID
// foreach ( $zigateIds as $zigateId ) {
// if ( $_POST['submitButton'] == 'Set Extended PANID Z'.$zigateId ) {
// echo "Set Extended PANID request processing";
// sendMessageFromFormToCmd('CmdAbeille'.$zigateId.'/0000/setExtendedPANID', $_POST['extendedPanId'] );
// }
// }

// // Set Certification CE
// foreach ( $zigateIds as $zigateId ) {
// if ( $_POST['submitButton'] == 'Set Certification CE Z'.$zigateId ) {
// echo "Set Certification CE";
// sendMessageFromFormToCmd('CmdAbeille'.$zigateId.'/0000/setCertificationCE', "");
// }
// }

// // Set Certification FCC
// foreach ( $zigateIds as $zigateId ) {
// if ( $_POST['submitButton'] == 'Set Certification FCC Z'.$zigateId ) {
// echo "Set Certification FCC";
// sendMessageFromFormToCmd('CmdAbeille'.$zigateId.'/0000/setCertificationFCC', "");
// }
// }
} catch (Exception $e) {
echo '<br>error: '.$e->getMessage();
}
Expand Down
4 changes: 3 additions & 1 deletion docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

- Support multi-passerelles: Des tas de modifs internes.
- Interne: Cmd: Mise-à-jour 'getBindingTable()' (suppression champ 'address')
- Dépendance nécessaire: Ajout 'pyserial'.
- Dépendances nécessaires: Ajout 'pyserial'.
- Interne: Cmd: 'TxPower' => 'zgSetTxPower'
- Zigate/avancé: Ajout controle puissance TX.

## 240501-STABLE-1

Expand Down

0 comments on commit 53a671c

Please sign in to comment.