SnapAzule

Synchronizing digital events with physical actions.

Research project investigating deterministic synchronization between wireless digital events and physical camera capture.

SnapAzule monitoring a 3D printer layer and transmitting a synchronized Bluetooth action

Event synchronization

Precise timing between software and hardware.

MQTT systems

Reliable messaging in real-world scenarios.

BLE integration

Bluetooth Low Energy communication.

ESP32 / Embedded

Edge performance and embedded development.

Timing systems

Compensating delays in event systems.

Open source

Open hardware and open software.

Domini Industries Research
Embedded Systems · Timing Systems
Research Note · 001

Predictive timing for wireless physical capture

SnapAzule investigates whether a wireless embedded system can synchronize 3D-printer events with smartphone camera exposure using predictive timing instead of relying exclusively on reactive MQTT triggers.

SnapAzule Bambu Lab A1 · ESP32-S3 · iPhone XR September 7, 2026 Gauntlet in progress

Abstract

The current SnapAzule production path remains reactive: printer observations arrive through MQTT and are used to trigger a BLE HID camera action. A new predictive timing core has been implemented and compiled, but it is not yet connected to production capture. The research now focuses on validating complete sliced-job timing, physical park windows, Bluetooth timing and actual iPhone camera exposure before predictive triggering is allowed to control real captures.

00 Verified status

The gauntlet is not complete.

No claim of perfect physical synchronization is currently made.

There are not yet 10,000 independently correlated real camera exposures. No firmware flash was performed during the current research session.

Production
Reactive capture remains active.

The normal SnapAzule trigger path still reacts to printer observations received through MQTT.

Experimental
Predictive timing core is compiled but isolated.

It remains in shadow until job identity, timing bounds, bootstrap behavior and physical validation are established.

Physical
Exposure validation remains pending.

BLE submission does not prove that the iPhone camera physically exposed a frame at the intended moment.

01 Implemented

The timing pipeline can now be observed instead of guessed.

The firmware now contains RAM-based timing instrumentation with job, layer and event context, exposed through an authenticated /timing endpoint.

Logging has been moved away from the critical capture path through asynchronous CSV handling.

Timing
Monotonic timing trace.

Job, layer and event identity are preserved through the instrumented execution path.

MQTT
Invalid observations are rejected.

Incomplete, retained or structurally invalid MQTT frames are no longer accepted as valid timing observations.

Parsing
JSON scope is restricted.

Printer values are parsed from the root print object instead of arbitrary substring matches.

BLE
Press/release is serialized.

Camera HID actions are protected from overlapping BLE actions, and the expected GATT signature is checked.

Layers
Layer three is back in the denominator.

It is no longer silently excluded from the normal capture path.

02 Predictive core

Prediction exists, but does not yet control the camera.

An affine interval clock and timer adapter are implemented and compile successfully.

Treal = aTmodel + b

The model represents a bounded relation between predicted model time and observed execution time.

The predictive path requires a complete timing manifest, verified job identity and calibrated delay bounds before it can schedule a real capture.

The legacy FTP timing parser is not considered a certified timing oracle.

Slicer patches currently exist only as reviewable candidates. They have not yet been compiled upstream or validated against real printer execution.

03 POST_PARK V3

A 1.5-second candidate capture window.

The received POST_PARK V3 template parks the print head and executes M400 before the timelapse markers.

Current template sequence
Park motion → M400 → M73 → M991 → M1004 → M400 P1500 → M971 → X0

For identification inside the actual sliced file, the current importer expects:

; SNAPAZULE_CAPTURE layer={layer_num+1}
M400 P1500

Structural acceptance of this sequence does not establish the physical print-head position, conditional execution behavior or native-camera latency.

It also remains necessary to determine whether the interaction between M1004 and the BLE shutter path produces duplicate captures under the real printer profile.

04 Evidence

Synthetic evidence is strong. Physical evidence is still incomplete.

10M synthetic events executed by the affine timing core
0 failures inside its declared bounded affine domain
125K input layers in the adversarial simulation suite
1.125M architecture/scenario evaluations across nine variants

Ten million synthetic events do not mean ten million photographs. MQTT-to-callback measurements also do not measure actual camera exposure.

Artifact
core_monte_carlo.json

Ten million events in the declared bounded affine timing domain.

Artifact
simulations.json

125,000 input layers evaluated across nine architecture variants.

Artifact
simulation_failures.csv.gz

Recorded failures are retained instead of being filtered out of the benchmark.

Artifact
parser_tests.txt

Parser regressions plus 200,000 payloads under ASan/UBSan.

Artifact
python_tests.txt

Causality, manifest, packet-loss and counterexample testing.

Artifact
legacy_analysis.json

Historical data deduplicated by hash. MQTT-to-callback timing is not treated as exposure timing.

05 Physical validation

The next stage is not another simulation.

The next research phase is to correlate the software timing model with physical execution on the real Bambu Lab A1 and iPhone XR.

01
Archive the exact executed job.

Preserve the sliced G-code or 3MF containing Metadata/plate_N.gcode, profiles, firmware versions, iOS version, camera settings and hashes.

02
Measure the ESP32 under contention.

Characterize timer lateness, queues, HID submission, trace loss, minimum stack and minimum heap while Wi-Fi, BLE and CPU activity compete.

03
Measure physical exposure.

Correlate each real camera exposure with the physical park interval using an optical reference with known temporal uncertainty. HID acknowledgement or EXIF alone is insufficient.

04
Collect at least 10,000 consecutive expected captures.

Missing captures, duplicates, out-of-window exposures and lost evidence remain in the denominator.

05
Only then enable predictive control.

Prediction remains shadow-only until job identity, bootstrap behavior, timing bounds and physical stability are validated.

06 Reproducibility

Reproduce the current software evidence.

python3 -m unittest discover -s tests/timing -p test_tools.py

clang -O2 -std=c11 -Wall -Wextra -Werror \
  -I main \
  main/predictive_clock.c \
  tests/timing/test_clock.c \
  -lm \
  -o /tmp/snapazule-clock

/tmp/snapazule-clock 10000000

python3 scripts/timing/simulate.py \
  --layers 25000 \
  --seed 20260907 \
  --out /tmp/snapazule-bench

python3 scripts/timing/simulate.py \
  --layers 25000 \
  --seed 20260907 \
  --window-ms 1500 \
  --capture-window-ms 1500 \
  --out /tmp/snapazule-v3

python3 scripts/timing/plot_results.py

. /Users/allan_domini/esp/esp-idf/export.sh
idf.py -B build-timing build

Final firmware build completed successfully using ESP-IDF 5.3.1. The resulting binary is 1,740,384 bytes, leaving 72% of the application partition free.

07 Next data

Collect real timing traces without changing the capture architecture.

Once the instrumented firmware is installed, timing can be collected passively while the existing production path remains reactive.

python3 scripts/timing/capture_trace.py \
  --device http://IP_DO_SNAPAZULE \
  --seconds 600 \
  --output /tmp/trace-novo.jsonl

Analysis:

python3 scripts/timing/analyze.py \
  --trace /tmp/trace-novo.jsonl \
  --output /tmp/trace-analise.json

Supporting research documents include MODEL.md, RESEARCH.md, HYPOTHESES.md, FAILURES.md and SCOREBOARD.md.

Research updates

Instrumentation Timing trace and asynchronous logging implemented
Reliability MQTT validation and stale-job rejection added
Model Affine interval clock and predictive timer adapter compiled
Simulation Ten-million-event bounded core test completed
G-code POST_PARK V3 1.5-second candidate window accepted structurally
Validation Physical A1 / ESP32-S3 / iPhone XR validation pending