# 6. Diagnostics & Maintainability

## Overview
To support a fleet of devices, the system must provide clear diagnostics that allow for remote troubleshooting and predictive maintenance.

## Diagnostic Code System
A standardized diagnostic code system is used to categorize and report issues across the fleet.

**Format: `0xSCCC`**
*   **S:** Severity (1 = Info, 2 = Warning, 3 = Error, 4 = Critical)
*   **CCC:** Subsystem Code

| Range | Subsystem |
| :--- | :--- |
| **0x1xxx** | Data Acquisition (DAQ) |
| **0x2xxx** | Communication (COM) |
| **0x3xxx** | Security (SEC) |
| **0x4xxx** | Over-the-Air Updates (OTA) |
| **0x5xxx** | Hardware (HW) |

This structured approach enables **fleet analytics**, allowing operators to identify patterns of failure across many devices.

## Layered Watchdogs
To ensure the system remains responsive, multiple levels of watchdogs are implemented:

| Watchdog | Purpose | Baseline Timeout |
| :--- | :--- | :--- |
| **Task WDT** | Detects deadlocks in specific FreeRTOS tasks. | 10 seconds |
| **Interrupt WDT** | Detects hangs within Interrupt Service Routines (ISRs). | 3 seconds |
| **RTC WDT** | Provides a final safety net for total system freezes. | 30 seconds |

These layered watchdogs ensure that the device can recover automatically from software glitches or hardware-induced hangs.
