> ## Documentation Index
> Fetch the complete documentation index at: https://docs.industrialpmr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Offline Storage & Resync Architecture

> Non-volatile SPI flash ring-buffering ensuring zero production data loss during factory network dropouts.

Factory floors frequently encounter Wi-Fi dead zones, network switch restarts, access point congestion, or temporary ISP link disruptions. Industrial PMR implements a dedicated **Non-Volatile Ring-Buffer** on the edge node's onboard SPI flash memory to guarantee **zero production data loss**.

***

## The Zero-Data-Loss Ingestion Pipeline

```mermaid theme={null}
sequenceDiagram
    autonumber
    participant Node as Edge Node (ipmr223m-v1 / ipmr226)
    participant RTC as Hardware Real-Time Clock
    participant Flash as SPI Flash Ring-Buffer
    participant Broker as Cloud MQTT Broker
    participant Ingest as Cloud Ingestion Engine

    Note over Node,Broker: Factory Wi-Fi Drops / Network Partition Occurs
    Node->>Node: Detect TCP socket disconnection & MQTT ping timeout
    loop During Network Outage (Up to 72+ Hours)
        Node->>RTC: Read high-precision hardware timestamp
        Node->>Node: Construct compressed binary telemetry record
        Node->>Flash: Append record to SPI flash ring-buffer
        Node->>Flash: Increment unacknowledged write pointer
    end

    Note over Node,Broker: Wi-Fi Re-associates & Network Restored
    Node->>Broker: Re-establish secure TLS connection (mqtt.industrialpmr.com)
    Node->>Flash: Read earliest unacknowledged record block
    loop Chronological Batch Replay (Chunks of 25-50 Records)
        Node->>Broker: Publish historical batch with original RTC timestamps
        Broker->>Ingest: Stream to InfluxDB & Cloud Database
        Ingest-->>Node: Publish Acknowledged (ACK) Callback
        Node->>Flash: Advance committed read pointer
    end
    Node->>Node: All flash records committed; resume live 1Hz streaming
```

***

## Technical Specifications of the Edge Buffer

| Parameter | Specification | Engineering Benefit |
| :- | :- | :- |
| **Storage Medium** | Dedicated SPI NOR Flash Partition | Non-volatile; immune to sudden factory power cuts. |
| **Hardware Clock (RTC)** | Dedicated battery-backed Real-Time Clock | Guarantees microsecond timestamp accuracy even without internet NTP servers. |
| **Buffer Capacity** | Over 65,000 discrete records | Equates to **over 72 hours of continuous offline production data** at standard logging rates. |
| **Replay Strategy** | First-In, First-Out (FIFO) chronological batches | Backfills time-series databases in true chronological sequence. |
| **Flow Control** | Strict ACK callback confirmation | Read pointers advance only after the cloud ingestion worker confirms database commit. |

***

## Factory Resync Behavior on the Web Dashboard

When an offline edge node reconnects to the network:

1. **Historical Backfill**: Historical production counts and power profiles populate the dashboard's hourly bar charts for the outage duration without leaving gaps.
2. **Audit Trail Integrity**: Shift handover reports compile accurate totals even if the network was down during shift boundary transitions.
3. **No Duplicate Strokes**: Unique transaction hashes prevent duplicate count registration if a retransmitted packet arrives twice.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.