This commit is contained in:
Your Name
2025-02-26 09:48:56 +01:00
parent 49e93ab3ad
commit 8fecde5d56
3 changed files with 69 additions and 43 deletions

View File

@@ -5,7 +5,9 @@
___) / ___ \| _ < / ___ \ ___) / ___ \| _ < / ___ \
|____/_/ \_\_| \_\/_/ \_\ |____/_/ \_\_| \_\/_/ \_\
Script that starts at the boot of the RPI Script that starts at the boot of the RPI (with cron)
@reboot sleep 30 && /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/reboot/start.py >> /var/www/nebuleair_pro_4g/logs/app.log 2>&1
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/reboot/start.py /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/reboot/start.py
@@ -118,6 +120,19 @@ def read_complete_response(serial_connection, timeout=2, end_of_response_timeout
try: try:
print('<h3>Start reboot python script</h3>') print('<h3>Start reboot python script</h3>')
#check modem status
print("Check SARA Status")
command = f'ATI\r'
ser_sara.write(command.encode('utf-8'))
response_SARA_ATI = read_complete_response(ser_sara, wait_for_lines=["IMEI"])
print(response_SARA_ATI)
match = re.search(r"Model:\s*(.+)", response_SARA_ATI)
model = match.group(1).strip() if match else "Unknown" # Strip unwanted characters
print(f" Model: {model}")
update_json_key(config_file, "modem_version", model)
time.sleep(1)
# 1. Set AIRCARTO URL # 1. Set AIRCARTO URL
print('Set aircarto URL') print('Set aircarto URL')
aircarto_profile_id = 0 aircarto_profile_id = 0

View File

@@ -30,6 +30,7 @@
"MQTT_GUI": false, "MQTT_GUI": false,
"send_aircarto": true, "send_aircarto": true,
"send_uSpot": false, "send_uSpot": false,
"modem_version": "XXX",
"envea_sondes": [ "envea_sondes": [
{ {
"connected": false, "connected": false,

View File

@@ -110,55 +110,65 @@
const loop_card_content = document.getElementById('card_loop_content'); const loop_card_content = document.getElementById('card_loop_content');
const boot_card_content = document.getElementById('card_boot_content'); const boot_card_content = document.getElementById('card_boot_content');
fetch('../logs/master.log') //Getting Master logs
.then((response) => { console.log("Getting master logs");
if (!response.ok) {
throw new Error('Failed to fetch the log file.');
}
return response.text();
})
.then((data) => {
const lines = data.split('\n');
// Format log content fetch('../logs/master.log')
const formattedLog = lines .then((response) => {
.map((line) => line.trim()) // Remove extra whitespace console.log("OK");
.filter((line) => line) // Remove empty lines
.join('<br>'); // Join formatted lines with line breaks
loop_card_content.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word; margin: 0;">${formattedLog}</pre>`; if (!response.ok) {
loop_card_content.scrollTop = loop_card_content.scrollHeight; // Scroll to the bottom throw new Error('Failed to fetch the log file.');
}
return response.text();
})
.then((data) => {
const lines = data.split('\n');
}) // Format log content
.catch((error) => { const formattedLog = lines
console.error(error); .map((line) => line.trim()) // Remove extra whitespace
loop_card_content.textContent = 'Error loading log file.'; .filter((line) => line) // Remove empty lines
}); .join('<br>'); // Join formatted lines with line breaks
fetch('../logs/app.log') loop_card_content.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word; margin: 0;">${formattedLog}</pre>`;
.then((response) => { loop_card_content.scrollTop = loop_card_content.scrollHeight; // Scroll to the bottom
if (!response.ok) {
throw new Error('Failed to fetch the log file.');
}
return response.text();
})
.then((data) => {
const lines = data.split('\n');
// Format log content })
const formattedLog = lines .catch((error) => {
.map((line) => line.trim()) // Remove extra whitespace console.error(error);
.filter((line) => line) // Remove empty lines loop_card_content.textContent = 'Error loading log file.';
.join('<br>'); // Join formatted lines with line breaks });
boot_card_content.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word; margin: 0;">${formattedLog}</pre>`; console.log("Getting app/boot logs");
boot_card_content.scrollTop = loop_card_content.scrollHeight; // Scroll to the bottom
}) //Getting App logs
.catch((error) => { fetch('../logs/app.log')
console.error(error); .then((response) => {
boot_card_content.textContent = 'Error loading log file.'; console.log("OK");
});
if (!response.ok) {
throw new Error('Failed to fetch the log file.');
}
return response.text();
})
.then((data) => {
const lines = data.split('\n');
// Format log content
const formattedLog = lines
.map((line) => line.trim()) // Remove extra whitespace
.filter((line) => line) // Remove empty lines
.join('<br>'); // Join formatted lines with line breaks
boot_card_content.innerHTML = `<pre style="white-space: pre-wrap; word-wrap: break-word; margin: 0;">${formattedLog}</pre>`;
boot_card_content.scrollTop = loop_card_content.scrollHeight; // Scroll to the bottom
})
.catch((error) => {
console.error(error);
boot_card_content.textContent = 'Error loading log file.';
});