ENABLE_DEVICE_RESPONSE¶
Flag to enable unified device response protocol.
Controls whether the firmware uses a unified device_response_t type for all output messages (responses and events) or legacy separate response_t/event_t types.
v2 (Always Enabled)¶
In v2, the unified device response protocol is a standard feature — always enabled, no flag required.
All output uses device_response_t:
{"type":"response","status":"ok","sent_us":1748012345678901,"version":"2.6.0"}
{"type":"event","status":"ok","sent_us":1748012345678901,"hit1":45,"hit2":38,"hit3":42,"detected_us":1748012345678456}
v1 (Configurable)¶
In v1, the unified protocol is opt-in via ENABLE_DEVICE_RESPONSE.
Default¶
- v1: Disabled by default (
ENABLE_DEVICE_RESPONSE=0, legacy protocol)
Options¶
ENABLE_DEVICE_RESPONSE=1: Use unifieddevice_response_tfor all output (v1.12.0+)ENABLE_DEVICE_RESPONSE=0: Use legacy separateresponse_t/event_ttypes (default)
Override with platformio.override.ini¶
[env:esp32dev-v1]
build_flags =
-D ENABLE_DEVICE_RESPONSE=1
Features (when enabled)¶
- Single unified message structure for all output
- JSON schema validation (strict and flexible modes)
- Type and status enumerations
- Builder functions for safe initialization
- Error code standardization
JSON Schemas¶
All messages conform to:
docs/schemas/device-response.json— Strict validation (recommended for code generation)docs/schemas/device-response-flexible.json— Permissive validation (for protocol evolution)
Memory Overhead¶
- Flash: ~1-2KB (builder functions)
- RAM: Minimal (no additional state)
- Zero overhead when disabled: All code excluded by preprocessor
History¶
- v1.12.0 — Initial implementation, opt-in (
ENABLE_DEVICE_RESPONSE=1) - v2.0.0 — Promoted to always-enabled standard feature