diff --git a/SARA/reboot/start.py b/SARA/reboot/start.py index 8d7b7a1..4e0e215 100644 --- a/SARA/reboot/start.py +++ b/SARA/reboot/start.py @@ -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 @@ -118,6 +120,19 @@ def read_complete_response(serial_connection, timeout=2, end_of_response_timeout try: print('

Start reboot python script

') + #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 print('➡️Set aircarto URL') aircarto_profile_id = 0 diff --git a/config.json.dist b/config.json.dist index 7c23ae8..eb776d0 100755 --- a/config.json.dist +++ b/config.json.dist @@ -30,6 +30,7 @@ "MQTT_GUI": false, "send_aircarto": true, "send_uSpot": false, + "modem_version": "XXX", "envea_sondes": [ { "connected": false, diff --git a/html/logs.html b/html/logs.html index 143d06d..62127be 100755 --- a/html/logs.html +++ b/html/logs.html @@ -110,55 +110,65 @@ const loop_card_content = document.getElementById('card_loop_content'); const boot_card_content = document.getElementById('card_boot_content'); - fetch('../logs/master.log') - .then((response) => { - if (!response.ok) { - throw new Error('Failed to fetch the log file.'); - } - return response.text(); - }) - .then((data) => { - const lines = data.split('\n'); + //Getting Master logs + console.log("Getting master logs"); - // Format log content - const formattedLog = lines - .map((line) => line.trim()) // Remove extra whitespace - .filter((line) => line) // Remove empty lines - .join('
'); // Join formatted lines with line breaks + fetch('../logs/master.log') + .then((response) => { + console.log("OK"); - loop_card_content.innerHTML = `
${formattedLog}
`; - 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'); - }) - .catch((error) => { - console.error(error); - loop_card_content.textContent = 'Error loading log file.'; - }); + // Format log content + const formattedLog = lines + .map((line) => line.trim()) // Remove extra whitespace + .filter((line) => line) // Remove empty lines + .join('
'); // Join formatted lines with line breaks - fetch('../logs/app.log') - .then((response) => { - if (!response.ok) { - throw new Error('Failed to fetch the log file.'); - } - return response.text(); - }) - .then((data) => { - const lines = data.split('\n'); + loop_card_content.innerHTML = `
${formattedLog}
`; + loop_card_content.scrollTop = loop_card_content.scrollHeight; // Scroll to the bottom - // Format log content - const formattedLog = lines - .map((line) => line.trim()) // Remove extra whitespace - .filter((line) => line) // Remove empty lines - .join('
'); // Join formatted lines with line breaks + }) + .catch((error) => { + console.error(error); + loop_card_content.textContent = 'Error loading log file.'; + }); - boot_card_content.innerHTML = `
${formattedLog}
`; - boot_card_content.scrollTop = loop_card_content.scrollHeight; // Scroll to the bottom + console.log("Getting app/boot logs"); - }) - .catch((error) => { - console.error(error); - boot_card_content.textContent = 'Error loading log file.'; - }); + //Getting App logs + fetch('../logs/app.log') + .then((response) => { + 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('
'); // Join formatted lines with line breaks + + boot_card_content.innerHTML = `
${formattedLog}
`; + 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.'; + });