Page modem: section tests Miotiq UDP + masquer tests HTTP si SIM Miotiq
- Nouveau script SARA/sara_test_udp.py (test socket UDP vers 192.168.0.20:4242) - Section "Tests Miotiq (UDP)" avec PSD setup, test socket, placeholder aller-retour - Masque les tests HTTP/Send message quand send_miotiq est actif - Endpoint launcher.php sara_test_udp Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -389,6 +389,12 @@ if ($type == "sara_psd_setup") {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
if ($type == "sara_test_udp") {
|
||||
$command = 'sudo /usr/bin/python3 -u /var/www/nebuleair_pro_4g/SARA/sara_test_udp.py';
|
||||
$output = shell_exec($command);
|
||||
echo $output;
|
||||
}
|
||||
|
||||
|
||||
if ($type == "git_pull") {
|
||||
$command = 'sudo git pull';
|
||||
|
||||
@@ -302,6 +302,48 @@
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<div id="section_miotiq_tests" style="display:none;">
|
||||
<h3>Tests Miotiq (UDP)</h3>
|
||||
<div class="row mb-3">
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>1. Setup PSD connection</strong></p>
|
||||
<p class="text-muted small mb-2">Active la connexion PDP nécessaire pour les sockets UDP.</p>
|
||||
<button class="btn btn-primary" onclick="PSD_setup_miotiq()">Start</button>
|
||||
<div id="loading_PSD_miotiq" class="spinner-border spinner-border-sm" style="display: none;" role="status"></div>
|
||||
<div id="response_psd_setup_miotiq"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>2. Test socket UDP</strong></p>
|
||||
<p class="text-muted small mb-2">Crée un socket UDP, se connecte à 192.168.0.20:4242, envoie un payload test, puis ferme le socket.</p>
|
||||
<button class="btn btn-primary" onclick="testUdpSocket()">Test UDP</button>
|
||||
<div id="loading_udp_test" class="spinner-border spinner-border-sm" style="display: none;" role="status"></div>
|
||||
<div id="response_udp_test"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>3. Test aller-retour</strong></p>
|
||||
<p class="text-muted small mb-2">Envoie un payload spécial puis vérifie la réception via l'API descendante Miotiq. (à venir)</p>
|
||||
<button class="btn btn-secondary" disabled>Bientôt disponible</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="section_http_tests">
|
||||
<h3>Test HTTP server comm.</h3>
|
||||
<div class="row mb-3">
|
||||
<!-- SET URL -->
|
||||
@@ -397,6 +439,7 @@
|
||||
|
||||
|
||||
</div>
|
||||
</div><!-- end section_http_tests -->
|
||||
|
||||
<!-- toast -->
|
||||
|
||||
@@ -480,6 +523,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
// Show/hide config mode alert banner
|
||||
const alertEl = document.getElementById("configmode_alert");
|
||||
if (alertEl) alertEl.style.display = response.modem_config_mode ? "flex" : "none";
|
||||
|
||||
// Show Miotiq tests OR HTTP tests depending on SIM type
|
||||
const sectionHttp = document.getElementById("section_http_tests");
|
||||
const sectionMiotiq = document.getElementById("section_miotiq_tests");
|
||||
if (sectionHttp) sectionHttp.style.display = response.send_miotiq ? "none" : "";
|
||||
if (sectionMiotiq) sectionMiotiq.style.display = response.send_miotiq ? "" : "none";
|
||||
} else {
|
||||
console.error("Checkbox element not found");
|
||||
}
|
||||
@@ -1626,6 +1675,54 @@ function update_modem_configMode(param, checked){
|
||||
|
||||
|
||||
|
||||
function PSD_setup_miotiq() {
|
||||
console.log("Setup PSD connection (Miotiq):");
|
||||
$("#loading_PSD_miotiq").show();
|
||||
$("#response_psd_setup_miotiq").empty();
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=sara_psd_setup',
|
||||
dataType: 'text',
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
$("#loading_PSD_miotiq").hide();
|
||||
const formattedResponse = response.replace(/\n/g, "<br>");
|
||||
$("#response_psd_setup_miotiq").html(formattedResponse);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
$("#loading_PSD_miotiq").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testUdpSocket() {
|
||||
console.log("Test UDP socket to Miotiq:");
|
||||
$("#response_udp_test").empty();
|
||||
$("#loading_udp_test").show();
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=sara_test_udp',
|
||||
dataType: 'text',
|
||||
method: 'GET',
|
||||
timeout: 30000,
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
$("#loading_udp_test").hide();
|
||||
const formattedResponse = response.replace(/\n/g, "<br>");
|
||||
$("#response_udp_test").html(formattedResponse);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
$("#loading_udp_test").hide();
|
||||
$("#response_udp_test").html(`
|
||||
<div class="alert alert-danger py-2 mt-2">
|
||||
<strong>Erreur de communication</strong><br>
|
||||
<small>${error}</small>
|
||||
</div>`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Self test functions are now in assets/js/selftest.js
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user