Error flags byte 66: implementation RTC flags + escalade PDP reset → hardware reboot
- Constantes error_flags (byte 66) + methodes SensorPayload - Construction byte 66 avec flags RTC (disconnected/reset) - Escalade: si PDP reset echoue apres echec UDP → notification + hardware reboot + exit - Doc: ajout byte 68 device_status (specification) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -151,6 +151,16 @@ payload_json = {
|
||||
aircarto_profile_id = 0
|
||||
uSpot_profile_id = 1
|
||||
|
||||
# Error flags constants (byte 66)
|
||||
ERR_RTC_DISCONNECTED = 0x01
|
||||
ERR_RTC_RESET = 0x02
|
||||
ERR_BME280 = 0x04
|
||||
ERR_NPM = 0x08
|
||||
ERR_ENVEA = 0x10
|
||||
ERR_NOISE = 0x20
|
||||
ERR_MPPT = 0x40
|
||||
ERR_WIND = 0x80
|
||||
|
||||
# database connection
|
||||
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
|
||||
cursor = conn.cursor()
|
||||
@@ -358,6 +368,18 @@ class SensorPayload:
|
||||
if direction is not None:
|
||||
self.payload[64:66] = struct.pack('>H', int(direction))
|
||||
|
||||
def set_error_flags(self, flags):
|
||||
"""Set system error flags (byte 66)"""
|
||||
self.payload[66] = flags & 0xFF
|
||||
|
||||
def set_npm_status(self, status):
|
||||
"""Set NextPM status register (byte 67)"""
|
||||
self.payload[67] = status & 0xFF
|
||||
|
||||
def set_device_status(self, status):
|
||||
"""Set device status flags (byte 68)"""
|
||||
self.payload[68] = status & 0xFF
|
||||
|
||||
def get_bytes(self):
|
||||
"""Get the complete 100-byte payload"""
|
||||
return bytes(self.payload)
|
||||
@@ -1090,6 +1112,14 @@ try:
|
||||
|
||||
'''
|
||||
|
||||
# ---- Build error_flags (byte 66) ----
|
||||
error_flags = 0x00
|
||||
if rtc_status == "disconnected":
|
||||
error_flags |= ERR_RTC_DISCONNECTED
|
||||
if rtc_status == "reset":
|
||||
error_flags |= ERR_RTC_RESET
|
||||
payload.set_error_flags(error_flags)
|
||||
|
||||
if send_miotiq:
|
||||
print('<p class="fw-bold">➡️SEND TO MIOTIQ</p>', end="")
|
||||
|
||||
@@ -1125,9 +1155,20 @@ try:
|
||||
print(response_SARA_1)
|
||||
else:
|
||||
print("⛔There were issues with the modem CSD PSD reinitialize process")
|
||||
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))
|
||||
led_thread.start()
|
||||
#Send notification (WIFI)
|
||||
send_error_notification(device_id, "UDP socket creation failed + PDP reset failed -> hardware reboot")
|
||||
#Hardware Reboot
|
||||
hardware_reboot_success = modem_hardware_reboot()
|
||||
if hardware_reboot_success:
|
||||
print("✅Modem successfully rebooted and reinitialized")
|
||||
else:
|
||||
print("⛔There were issues with the modem reboot/reinitialize process")
|
||||
#end loop
|
||||
sys.exit()
|
||||
|
||||
#Retreive Socket ID
|
||||
socket_id = None
|
||||
|
||||
Reference in New Issue
Block a user