diff --git a/html/saraR4.html b/html/saraR4.html index 6d9505f..c6c39b2 100755 --- a/html/saraR4.html +++ b/html/saraR4.html @@ -67,15 +67,19 @@ -->
-
+
- +

General information.

- + -
- +
+
+
+ +
+
@@ -473,6 +477,90 @@ window.onload = function() { } +function getModemInfo(port, timeout) { + console.log("Getting modem info from port " + port); + + $("#loading_ttyAMA2_ATI").show(); + $("#modem_info_alert").empty(); + $("#response_ttyAMA2_ATI").empty(); + + $.ajax({ + url: 'launcher.php?type=sara&port=' + port + '&command=' + encodeURIComponent('ATI') + '&timeout=' + timeout, + dataType: 'text', + method: 'GET', + success: function(response) { + console.log("ATI response:", response); + $("#loading_ttyAMA2_ATI").hide(); + + // Store raw logs + const formattedLogs = response.replace(/\n/g, "
"); + $("#response_ttyAMA2_ATI").html(formattedLogs); + + // Parse response to detect modem model + let alertHtml = ''; + const responseUpper = response.toUpperCase(); + + if (response.includes('OK') && (responseUpper.includes('SARA-R5') || responseUpper.includes('SARA-R4'))) { + // Extract model name + let modelName = 'SARA'; + const modelMatch = response.match(/SARA-R[45]\d*[A-Z]*-\d+[A-Z]*-\d+/i); + if (modelMatch) { + modelName = modelMatch[0]; + } else if (responseUpper.includes('SARA-R5')) { + modelName = 'SARA-R5'; + } else if (responseUpper.includes('SARA-R4')) { + modelName = 'SARA-R4'; + } + + alertHtml = ` + `; + } else if (response.includes('ERROR') || response.trim() === '' || !response.includes('OK')) { + alertHtml = ` + `; + } else { + // Unknown response but got something + alertHtml = ` + `; + } + + $("#modem_info_alert").html(alertHtml); + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + $("#loading_ttyAMA2_ATI").hide(); + $("#modem_info_alert").html(` + `); + } + }); +} + function getData_saraR4(port, command, timeout){ console.log("Data from SaraR4"); console.log("Port: " + port );