Event synchronization
Precise timing between software and hardware.
Synchronizing digital events with physical actions.
Research project investigating deterministic synchronization between wireless digital events and physical camera capture.
Research areas
Precise timing between software and hardware.
Reliable messaging in real-world scenarios.
Bluetooth Low Energy communication.
Edge performance and embedded development.
Compensating delays in event systems.
Open hardware and open software.
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.
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.
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.
The normal SnapAzule trigger path still reacts to printer observations received through MQTT.
It remains in shadow until job identity, timing bounds, bootstrap behavior and physical validation are established.
BLE submission does not prove that the iPhone camera physically exposed a frame at the intended moment.
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.
Job, layer and event identity are preserved through the instrumented execution path.
Incomplete, retained or structurally invalid MQTT frames are no longer accepted as valid timing observations.
Printer values are parsed from the root print object instead of
arbitrary substring matches.
Camera HID actions are protected from overlapping BLE actions, and the expected GATT signature is checked.
It is no longer silently excluded from the normal capture path.
An affine interval clock and timer adapter are implemented and compile successfully.
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.
The received POST_PARK V3 template parks the print head and executes
M400 before the timelapse markers.
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.
Ten million synthetic events do not mean ten million photographs. MQTT-to-callback measurements also do not measure actual camera exposure.
Ten million events in the declared bounded affine timing domain.
125,000 input layers evaluated across nine architecture variants.
Recorded failures are retained instead of being filtered out of the benchmark.
Parser regressions plus 200,000 payloads under ASan/UBSan.
Causality, manifest, packet-loss and counterexample testing.
Historical data deduplicated by hash. MQTT-to-callback timing is not treated as exposure timing.
The next research phase is to correlate the software timing model with physical execution on the real Bambu Lab A1 and iPhone XR.
Preserve the sliced G-code or 3MF containing Metadata/plate_N.gcode,
profiles, firmware versions, iOS version, camera settings and hashes.
Characterize timer lateness, queues, HID submission, trace loss, minimum stack and minimum heap while Wi-Fi, BLE and CPU activity compete.
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.
Missing captures, duplicates, out-of-window exposures and lost evidence remain in the denominator.
Prediction remains shadow-only until job identity, bootstrap behavior, timing bounds and physical stability are validated.
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.
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.