Skip to content

Commit

Permalink
LQI collecte minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Aug 2, 2024
1 parent 6c702fa commit 7f99696
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 38 deletions.
4 changes: 2 additions & 2 deletions core/class/AbeilleParser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2449,11 +2449,11 @@ function decode8002_MgmtLqiRsp($dest, $srcAddr, $pl) {
$pl = substr($pl, 10);

$m = ' Management LQI response';
$m = $m.': SQN='.$sqn.', Status='.$status.', NTableEntries='.$nTableEntries.', StartIdx='.$startIdx.', NTableListCount='.$nTableListCount;
$m .= ': SQN='.$sqn.', Status='.$status.', NTableEntries='.$nTableEntries.', StartIdx='.$startIdx.', NTableListCount='.$nTableListCount;
parserLog2('debug', $srcAddr, $m);

$toLqiCollector = array(
'type' => '804E',
'type' => 'mgmtLqiRsp',
'srcAddr' => $srcAddr,
'status' => $status,
'tableEntries' => $nTableEntries,
Expand Down
24 changes: 15 additions & 9 deletions core/php/AbeilleLQI.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Starting from zigate (coordinator), send LQI request to get neighbour table
* - Send request thru AbeilleCmd (004E cmd)
* - Get response from AbeilleParser (804E cmd)
* - Get response from AbeilleParser (Mgmt_lqi_rsp cmd)
* - Identify each neighbour
* - If neighbor is router, added to list for interrogation
*/
Expand Down Expand Up @@ -73,7 +73,7 @@ function msgFromParserFlush() {
while (msg_receive($queueParserToLQI, 0, $msgType, 2048, $msgJson, false, MSG_IPC_NOWAIT | MSG_NOERROR));
}

/* Treat request responses (804E) from parser.
/* Treat request responses (Mgmt_lqi_rsp) from parser.
Returns: 0=OK, -1=fatal error, 1=timeout */
function msgFromParser($eqIdx) {
// logMessage("", " msgFromParser(eqIndex=".$eqIdx.")");
Expand All @@ -90,21 +90,25 @@ function msgFromParser($eqIdx) {
if (msg_receive($queueParserToLQI, 0, $msgType, $msgMax, $msgJson, false, MSG_IPC_NOWAIT, $errCode) == true) {
/* Message received. Let's check it is the expected one */
$msg = json_decode($msgJson);
if ($msg->type != "804E") {
if ($msg->type != "mgmtLqiRsp") {
logMessage("", " msgFromParser: Unsupported message type (".$msg->type.") => Ignored.");
continue;
}
if (hexdec($msg->startIdx) != $eqToInterrogate[$eqIdx]['tableIndex']) {
/* Note: this case is due to too many identical 004E messages sent to eq
leading to several identical 804E answers */
leading to several identical mgmtLqiRsp answers */
logMessage("", " msgFromParser: Unexpected start index (".$msg->startIdx.") => Ignored.");
continue;
}
if ($msg->srcAddr != $eqToInterrogate[$eqIdx]['addr']) {
logMessage("", " msgFromParser: Unexpected source addr (".$msg->srcAddr.") => Ignored.");
continue;
}
if ($msg->status != "00"){
if ($msg->status == "C1") {
logMessage("", " msgFromParser: No devices.");
break;
}
if ($msg->status != "00") {
logMessage("", " msgFromParser: Wrong message status (".$msg->status.") => Ignored.");
continue;
}
Expand Down Expand Up @@ -137,7 +141,7 @@ function msgFromParser($eqIdx) {

/* Message format reminder
$msg = array(
'type' => '804E',
'type' => 'mgmtLqiRsp',
'srcAddr' => $srcAddr,
'tableEntries' => $nTableEntries,
'tableListCount' => $nTableListCount,
Expand Down Expand Up @@ -347,7 +351,7 @@ function interrogateEq($eqIdx) {
list($netName, $addr) = explode('/', $logicId);
logMessage("", "Interrogating '${name}' (Addr=${addr}, EqIdx=${eqIdx})");
global $done, $total;
updateLockFile("Analyse du réseau ".$netName.": ${done}/${total} => interrogation de '".$name."' (".$addr.")");
updateLockFile("${netName} - ${done}/${total}: Interrogation de '".$name."' (".$addr.")");

while (true) {
$eq = $eqToInterrogate[$eqIdx]; // Read eq status
Expand All @@ -365,7 +369,7 @@ function interrogateEq($eqIdx) {
return -1;
}

$eq = $eqToInterrogate[$eqIdx]; // Read eq status
$eq = $eqToInterrogate[$eqIdx]; // Reread eq status
if ($eq['tableIndex'] >= $eq['tableEntries'])
break; // Exiting interrogation loop
}
Expand Down Expand Up @@ -536,6 +540,8 @@ function interrogateEq($eqIdx) {
} else if ($ret == 0) {
$eqToInterrogate[$eqIdx]['completed'] = true;
$done++;
if ($eqToInterrogate[$eqIdx]['tableEntries'] == 0)
updateLockFile("= Aucun équipement en vie.");
}
}

Expand Down Expand Up @@ -571,7 +577,7 @@ function interrogateEq($eqIdx) {
default: $status = "error"; break; // Interrupted
}
// file_put_contents($lockFile, "done/".time()."/".$status);
updateLockFile("done/".time()."/".$status);
updateLockFile("= Collecte terminée: ".time()."/".$status);
}

logMessage("", "<<< AbeilleLQI exiting.");
Expand Down
20 changes: 10 additions & 10 deletions desktop/js/AbeilleNetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,28 @@ function trackLQICollectStatus(_autoUpdate, zgId) {
$("#div_networkZigbeeAlert").hide();
}, 10000);
} else {
var data = res.content;
console.log("Status='" + data + "'");
var content = res.content;
console.log("Status='" + content + "'");
var alertLevel = "success";
if (data.toLowerCase().includes("oops")) {
if (content.toLowerCase().includes("oops")) {
alertLevel = "danger";
_autoUpdate = 0;
} else if (data.toLowerCase().includes("done")) {
// Reminder: done/<timestamp>/<status
data = "Collecte terminée";
} else if (content.includes("= Collecte")) {
// Reminder: '= Collecte terminée: <timestamp>/<status>'
content = "Collecte terminée";
_autoUpdate = 0; // Stop status refresh
}

if (data != prevTrackingMsg) {
if (content != prevTrackingMsg) {
$("#div_networkZigbeeAlert").showAlert({
message: data,
message: content,
level: alertLevel,
});
prevTrackingMsg = data;
prevTrackingMsg = content;
}

/* Collect status display stops when "done" found */
// _autoUpdate = data.toLowerCase().includes("done")?0:1;
// _autoUpdate = content.toLowerCase().includes("done")?0:1;
if (_autoUpdate) {
// Next status update in 1s
setTimeout(function () {
Expand Down
30 changes: 14 additions & 16 deletions desktop/modal/AbeilleRefreshLQI.modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,24 @@ function analysisProgress() {
// _autoUpdate = 0;
// setTimeout(function () { $('#div_networkZigbeeAlert').hide(); }, 10000);
} else {
var data = res.content;
console.log("Status='"+data+"'");
if (data.toLowerCase().includes("oops")) {
// networkInformationProgress = data;
// document.getElementById("refreshInformation").value = data;
textArea.innerHTML += data + "<br>";
var content = res.content;
console.log("Status='"+content+"'");
if (content.toLowerCase().includes("oops")) {
textArea.innerHTML += content + "<br>";
clearInterval(analysisStatus);
} else if (data.toLowerCase().includes("done")) {
// Reminder: done/<timestamp>/<status
// networkInformationProgress = "Collecte terminée";
// document.getElementById("refreshInformation").value = "Collecte terminée";
} else if (content.includes("= Collecte")) {
// Reminder: '= Collecte terminée: <timestamp>/<status>'
textArea.innerHTML += "Collecte terminée<br>";
textArea.innerHTML += "<br>Si aucun équipement n'est listé<br>";
textArea.innerHTML += "- soit votre réseau est vide<br>";
textArea.innerHTML += "- soit ils sont tous en timeout depuis un moment.<br>";
clearInterval(analysisStatus);
} else
networkInformationProgress = data;
// document.getElementById("refreshInformation").value = data;
if (data != analysisText) {
textArea.innerHTML += data + "<br>";
analysisText = data;
} else {
if (content != analysisText) {
textArea.innerHTML += content + "<br>";
analysisText = content;
}
}
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion desktop/php/Abeille-TopButtons.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$tools = array(
'health' => array( 'bouton'=>'bt_healthAbeille', 'icon'=>'fa-medkit', 'text'=>'{{Santé}}' ),
'netList' => array( 'bouton'=>'bt_network', 'icon'=>'fa-sitemap', 'text'=>'{{Réseau}}' ),
'net' => array( 'bouton'=>'bt_networkMap', 'icon'=>'fa-map', 'text'=>'{{Placement réseau (BETA)}}' ),
'net' => array( 'bouton'=>'bt_networkMap', 'icon'=>'fa-map', 'text'=>'{{Placement réseau}}' ),
'compat' => array( 'bouton'=>'bt_supportedEqList', 'icon'=>'fa-align-left', 'text'=>'{{Compatibilité}}' ),
'ota' => array( 'bouton'=>'bt_Ota', 'icon'=>'fa-paperclip', 'text'=>'{{Mises-à-jour OTA}}' ),
'support' => array( 'bouton'=>'bt_maintenancePage', 'icon'=>'fa-medkit', 'text'=>'{{Maintenance}}' ),
Expand Down
1 change: 1 addition & 0 deletions docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Correction: 'Commande 0102-01- inconnue' (2719).
- Sonoff SNZB-01P: Mise-à-jour du modèle (2716).
- Correction: Collecte LQI: Code C1 n'est plus un timeout mais 'aucun eq en vie'.

## 240710-BETA-2

Expand Down

0 comments on commit 7f99696

Please sign in to comment.