v1.9.8: Self Test - vrai check Envea + firmware version + renommage

- Fix Envea Gas Sensors: scan physique via detect_envea_device (read_ref.py)
  sur ttyAMA3/4/5 au lieu de juste vérifier envea_sondes_table.connected=1.
  L'ancien check disait Passed même sans sonde branchée car read_value_v2.py -d
  imprime un en-tête de debug non vide et utilise "Failed" pas "error".
- Ajout Firmware Version dans les logs et le rapport (via firmware_version
  déjà retourné par get_config_sqlite, pas d'AJAX supplémentaire).
- Renommage titre modal "Modem Self Test" -> "Self Test" (couvre aussi
  capteurs et RTC, pas uniquement le modem).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-05-21 12:04:28 +02:00
parent bf38fdf811
commit ff1225d483
4 changed files with 81 additions and 25 deletions

View File

@@ -219,6 +219,7 @@ async function selfTestSequence() {
selfTestReport.deviceId = configResponse.deviceID || 'Unknown';
selfTestReport.deviceName = configResponse.deviceName || 'Unknown';
selfTestReport.modemVersion = configResponse.modem_version || 'Unknown';
selfTestReport.firmwareVersion = configResponse.firmware_version || 'Unknown';
selfTestReport.latitude = configResponse.latitude_raw || 'N/A';
selfTestReport.longitude = configResponse.longitude_raw || 'N/A';
selfTestReport.config = configResponse;
@@ -245,6 +246,7 @@ async function selfTestSequence() {
addSelfTestLog('════════════════════════════════════════════════════════');
addSelfTestLog(`Device ID: ${selfTestReport.deviceId}`);
addSelfTestLog(`Device Name: ${selfTestReport.deviceName}`);
addSelfTestLog(`Firmware Version: ${selfTestReport.firmwareVersion}`);
addSelfTestLog(`Modem Version: ${selfTestReport.modemVersion}`);
addSelfTestLog(`RTC Time: ${selfTestReport.systemTime}`);
addSelfTestLog(`Browser Time: ${new Date().toLocaleString()}`);
@@ -426,29 +428,42 @@ async function selfTestSequence() {
}
} else if (sensor.type === 'envea') {
// Envea sensor test - use the debug endpoint for all sensors
const enveaResult = await new Promise((resolve, reject) => {
$.ajax({
url: 'launcher.php?type=envea_debug',
dataType: 'text',
method: 'GET',
timeout: 30000,
success: function(data) { resolve(data); },
error: function(xhr, status, error) { reject(new Error(error || status)); }
});
// Envea sensor test - scan ports physically (same logic as Envea Sondes Detection)
// The envea_debug endpoint only confirms config (connected=1 in envea_sondes_table),
// not actual device presence. detect_envea_device runs read_ref.py per port and
// checks for a real Envea CAIRSENS response.
const enveaPorts = ['ttyAMA3', 'ttyAMA4', 'ttyAMA5'];
const enveaScan = await Promise.all(enveaPorts.map(port =>
new Promise(resolve => {
$.ajax({
url: `launcher.php?type=detect_envea_device&port=${port}`,
dataType: 'json',
method: 'GET',
cache: false,
timeout: 15000,
success: function(data) { resolve({ port, ...data }); },
error: function(xhr, status, error) { resolve({ port, success: false, detected: false, error: error || status }); }
});
})
));
selfTestReport.rawResponses['Envea Sensors'] = JSON.stringify(enveaScan, null, 2);
enveaScan.forEach(r => {
addSelfTestLog(`Envea ${r.port}: detected=${r.detected}${r.device_info || r.error || ''}`);
});
selfTestReport.rawResponses['Envea Sensors'] = enveaResult;
addSelfTestLog(`Envea response: ${enveaResult.trim().substring(0, 200)}`);
const detected = enveaScan.filter(r => r.detected);
const errored = enveaScan.filter(r => !r.success);
if (enveaResult.trim() !== '' && !enveaResult.toLowerCase().includes('error')) {
updateTestStatus(sensor.id, 'Passed', 'Sensors responding', 'bg-success');
if (detected.length > 0) {
const list = detected.map(r => `${r.port} (${r.device_info || 'Envea'})`).join(', ');
updateTestStatus(sensor.id, 'Passed', `Device(s) détecté(s): ${list}`, 'bg-success');
testsPassed++;
} else if (enveaResult.toLowerCase().includes('error')) {
updateTestStatus(sensor.id, 'Failed', 'Sensor error detected', 'bg-danger');
} else if (errored.length === enveaPorts.length) {
updateTestStatus(sensor.id, 'Failed', 'Aucun port accessible (erreur série)', 'bg-danger');
testsFailed++;
} else {
updateTestStatus(sensor.id, 'Failed', 'No data received', 'bg-danger');
updateTestStatus(sensor.id, 'Failed', 'Aucun device Envea détecté sur ttyAMA3/4/5', 'bg-danger');
testsFailed++;
}
@@ -825,12 +840,13 @@ function generateReport() {
DEVICE INFORMATION
------------------
Device ID: ${selfTestReport.deviceId || 'Unknown'}
Device Name: ${selfTestReport.deviceName || 'Unknown'}
Modem Version: ${selfTestReport.modemVersion || 'Unknown'}
System Time: ${selfTestReport.systemTime || 'Unknown'}
Report Date: ${selfTestReport.timestamp}
GPS Location: ${selfTestReport.latitude || 'N/A'}, ${selfTestReport.longitude || 'N/A'}
Device ID: ${selfTestReport.deviceId || 'Unknown'}
Device Name: ${selfTestReport.deviceName || 'Unknown'}
Firmware Version: ${selfTestReport.firmwareVersion || 'Unknown'}
Modem Version: ${selfTestReport.modemVersion || 'Unknown'}
System Time: ${selfTestReport.systemTime || 'Unknown'}
Report Date: ${selfTestReport.timestamp}
GPS Location: ${selfTestReport.latitude || 'N/A'}, ${selfTestReport.longitude || 'N/A'}
===============================================================
TEST RESULTS

View File

@@ -3,7 +3,7 @@
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="selfTestModalLabel">Modem Self Test</h5>
<h5 class="modal-title" id="selfTestModalLabel">Self Test</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" id="selfTestCloseBtn" disabled></button>
</div>
<div class="modal-body">