v1.7.1: Detection SIM injoignable avant escalade hardware reboot

- Nouvelle fonction check_sim_status() (AT+CPIN? + AT+CCID)
- Branche d'echec PDP: diagnostic SIM avant reboot hardware
- Logs HTML tres visibles si SIM absente (bordure rouge, action claire)
- Notification WiFi dediee: 'SIM NOT DETECTED -> physical check required'
- Zero impact happy path: check uniquement quand PDP reset echoue

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-05-12 11:27:28 +02:00
parent 2e5be6f542
commit c004d32f0b
3 changed files with 75 additions and 1 deletions

View File

@@ -1 +1 @@
1.7.0
1.7.1

View File

@@ -1,5 +1,22 @@
{
"versions": [
{
"version": "1.7.1",
"date": "2026-05-12",
"changes": {
"features": [],
"improvements": [
"Loop SARA: detection SIM injoignable avant escalade hardware reboot (evite les reboots inutiles en boucle quand la SIM est absente/mal inseree)",
"Logs HTML: bloc rouge tres visible quand la SIM n'est pas detectee (bordure, fond rose, message d'action clair)",
"Notification WiFi dediee: 'SIM NOT DETECTED -> physical check required' au lieu du generique 'UDP socket creation failed'"
],
"fixes": [
"Plus de hardware reboots repetes a chaque cycle de 60s quand la SIM est physiquement injoignable (economie courant + usure transistor GPIO 16)"
],
"compatibility": []
},
"notes": "Quand la sequence PDP echoue, le script verifie maintenant AT+CPIN? et AT+CCID pour diagnostiquer si le probleme vient de la SIM ou du reseau. Si SIM absente: notification claire + arret propre, pas de reboot. Si SIM presente: comportement actuel (reboot hardware). Le check ne s'execute qu'en cas d'erreur, zero impact sur le happy path."
},
{
"version": "1.7.0",
"date": "2026-04-27",

View File

@@ -620,6 +620,35 @@ def reset_PSD_CSD_connection():
return pdp_reset_success
def check_sim_status():
"""
Quick SIM presence check using AT+CPIN? and AT+CCID.
Called only when something has already gone wrong (eg. PDP reset failed),
to distinguish a SIM problem from a network/PDP problem.
returns True if SIM is detected and READY, False otherwise.
"""
print("➡️ Checking SIM status (AT+CPIN? and AT+CCID)")
# 1. CPIN -> doit retourner READY
ser_sara.reset_input_buffer()
ser_sara.write(b'AT+CPIN?\r')
response_cpin = read_complete_response(ser_sara, wait_for_lines=["OK", "+CME ERROR", "ERROR"], debug=False)
print('<p class="text-danger-emphasis">', end="")
print(response_cpin)
print("</p>", end="")
cpin_ok = response_cpin is not None and "READY" in response_cpin
# 2. CCID -> doit retourner l'ICCID
ser_sara.reset_input_buffer()
ser_sara.write(b'AT+CCID\r')
response_ccid = read_complete_response(ser_sara, wait_for_lines=["OK", "+CME ERROR", "ERROR"], debug=False)
print('<p class="text-danger-emphasis">', end="")
print(response_ccid)
print("</p>", end="")
ccid_ok = response_ccid is not None and "+CCID" in response_ccid and "ERROR" not in response_ccid
return cpin_ok and ccid_ok
def reset_server_hostname(profile_id):
"""
Function that reset server hostname (URL) connection for the SARA R5
@@ -1208,6 +1237,34 @@ try:
print(response_SARA_1)
else:
print("⛔There were issues with the modem CSD PSD reinitialize process")
# Diagnostic : SIM injoignable OU problème réseau/PDP ?
sim_ok = check_sim_status()
if not sim_ok:
# SIM injoignable -> un reboot hardware ne résoudra rien
print('<hr>')
print('<div style="border: 3px solid red; background-color: #ffe5e5; padding: 10px; margin: 10px 0;">')
print('<span style="color: red;font-weight: bold;font-size: 1.4em;">🚨🚨🚨 SIM CARD NOT DETECTED 🚨🚨🚨</span><br>')
print('<span style="color: red;font-weight: bold;">⛔ Le modem ne parvient pas à lire la carte SIM.</span><br>')
print('<span style="color: red;font-weight: bold;">⛔ AT+CPIN? et AT+CCID ont tous les deux échoué.</span><br>')
print('<span style="color: red;font-weight: bold;">👉 Action requise : vérifier physiquement la carte SIM (sortir/réinsérer, nettoyer les contacts).</span><br>')
print('<span style="color: red;font-weight: bold;">👉 Pas de hardware reboot — inutile dans ce cas, économise courant et usure.</span>')
print('</div>')
print('<hr>')
# LED rouge clignotante
led_thread = Thread(target=blink_led, args=(24, 5, 0.5))
led_thread.start()
# Notification WIFI explicite
send_error_notification(device_id, "SIM NOT DETECTED -> physical check required (no hardware reboot)")
# end loop, pas d'escalade
sys.exit()
# SIM OK -> c'est un problème réseau/PDP, escalade hardware reboot comme avant
print('<span style="color: green;font-weight: bold;">✅ SIM card detected — issue is network/PDP related</span>')
print("🔄 PDP reset failed → escalating to hardware reboot")
# Clignotement LED rouge en cas d'erreur
led_thread = Thread(target=blink_led, args=(24, 5, 0.5))