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:
@@ -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}`);
|
||||
|
||||
// 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 = {
|
||||
0x01: "Sleep mode",
|
||||
0x02: "Degraded mode",
|
||||
@@ -362,6 +368,7 @@ async function selfTestSequence() {
|
||||
updateTestStatus(sensor.id, 'Warning', 'Incomplete data received', 'bg-warning');
|
||||
testsFailed++;
|
||||
}
|
||||
} // end else (not 0xFF)
|
||||
|
||||
} else if (sensor.type === 'BME280') {
|
||||
// BME280 sensor test
|
||||
|
||||
@@ -155,15 +155,29 @@
|
||||
// NPM status decoded
|
||||
if (response.npm_status !== undefined) {
|
||||
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(`
|
||||
<tr>
|
||||
<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>
|
||||
`);
|
||||
|
||||
// Decode individual error bits
|
||||
const statusFlags = {
|
||||
0x01: "Sleep mode",
|
||||
@@ -186,6 +200,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
|
||||
Reference in New Issue
Block a user