NPM 0xFF = capteur deconnecte sur page sensors et self-test

Quand npm_status = 0xFF (aucune reponse du capteur), affiche
"Capteur deconnecte" au lieu de lister tous les flags d'erreur.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-03-18 16:31:23 +01:00
parent 361c0d1a76
commit 52b86dbc3d
2 changed files with 66 additions and 44 deletions

View File

@@ -336,7 +336,13 @@ async function selfTestSequence() {
addSelfTestLog(`NPM response: PM1=${npmResult.PM1}, PM2.5=${npmResult.PM25}, PM10=${npmResult.PM10}, status=${npmResult.npm_status_hex}`); addSelfTestLog(`NPM response: PM1=${npmResult.PM1}, PM2.5=${npmResult.PM25}, PM10=${npmResult.PM10}, status=${npmResult.npm_status_hex}`);
// Decode npm_status flags // Decode npm_status flags
const status = npmResult.npm_status || 0; const status = npmResult.npm_status !== undefined ? npmResult.npm_status : 0;
if (status === 0xFF) {
// 0xFF = no response = disconnected
updateTestStatus(sensor.id, 'Failed', 'Capteur déconnecté', 'bg-danger');
testsFailed++;
} else {
const statusFlags = { const statusFlags = {
0x01: "Sleep mode", 0x01: "Sleep mode",
0x02: "Degraded mode", 0x02: "Degraded mode",
@@ -362,6 +368,7 @@ async function selfTestSequence() {
updateTestStatus(sensor.id, 'Warning', 'Incomplete data received', 'bg-warning'); updateTestStatus(sensor.id, 'Warning', 'Incomplete data received', 'bg-warning');
testsFailed++; testsFailed++;
} }
} // end else (not 0xFF)
} else if (sensor.type === 'BME280') { } else if (sensor.type === 'BME280') {
// BME280 sensor test // BME280 sensor test

View File

@@ -155,15 +155,29 @@
// NPM status decoded // NPM status decoded
if (response.npm_status !== undefined) { if (response.npm_status !== undefined) {
const status = response.npm_status; const status = response.npm_status;
const statusText = status === 0 ? "OK" : response.npm_status_hex;
const statusColor = status === 0 ? "green" : "orange"; if (status === 0xFF) {
// 0xFF = no response from sensor = disconnected
$("#data-table-body_" + port).append(` $("#data-table-body_" + port).append(`
<tr> <tr>
<td>Status</td> <td>Status</td>
<td style="color: ${statusColor}; font-weight: bold;">${statusText}</td> <td style="color: red; font-weight: bold;">Capteur déconnecté</td>
</tr>
`);
} else if (status === 0) {
$("#data-table-body_" + port).append(`
<tr>
<td>Status</td>
<td style="color: green; font-weight: bold;">OK</td>
</tr>
`);
} else {
$("#data-table-body_" + port).append(`
<tr>
<td>Status</td>
<td style="color: orange; font-weight: bold;">${response.npm_status_hex}</td>
</tr> </tr>
`); `);
// Decode individual error bits // Decode individual error bits
const statusFlags = { const statusFlags = {
0x01: "Sleep mode", 0x01: "Sleep mode",
@@ -186,6 +200,7 @@
} }
}); });
} }
}
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
console.error('AJAX request failed:', status, error); console.error('AJAX request failed:', status, error);