v1.16.5 - Microsecond-Precision RTC Timestamps (2025-12-12)¶
What Changed?¶
This release adds microsecond-precision timestamp support to the RTC (Real-Time Clock) system. The detected_at field now captures detection events with ~4 microsecond precision instead of 1-second granularity, enabling high-precision event correlation across multiple detectors. Three new commands provide access to timestamps at different precisions (seconds, milliseconds, microseconds).
What's New¶
Main Feature: Microsecond-Precision RTC Timestamps¶
What it does:
detected_atfield upgraded fromuint32_t(seconds) touint64_t(microseconds)- Three new command levels for timestamp queries:
GET_RTC_TIME(seconds),GET_RTC_TIME_MS(milliseconds),GET_RTC_TIME_US(microseconds) - High-precision timestamp capture for detection event correlation
How to use it:
-
Query current RTC timestamp in microseconds:
# Via serial command interface GET_RTC_TIME_US # Response: {"type":"response","status":"ok","rtc_time_us":1732046789123456} -
Alternative precisions:
GET_RTC_TIME # Seconds (uint32_t)
GET_RTC_TIME_MS # Milliseconds (uint64_t)
GET_RTC_TIME_US # Microseconds (uint64_t)
Code example:
// In detection_processor.cpp - capture event with microsecond precision
void DetectionProcessor::add_rtc_data(event_t* event) {
#if ENABLE_RTC
event->detected_at = rtc_get_time_us(); // ~4ยตs precision
#endif
}
// In stream_formatter output - detected_at now in microseconds
#if ENABLE_RTC
Serial.print(delimiter);
Serial.print(data->detected_at); // uint64_t microseconds
#endif
Installation¶
Quick Start¶
# Get the release
git checkout v1.16.5
# Build with RTC support
PLATFORMIO_BUILD_FLAGS="-DENABLE_RTC=1" task build
# Upload
task upload
# Test RTC commands
task monitor
Then send: GET_RTC_TIME_US to verify microsecond-precision timestamps.
What's Different from the Last Version?¶
โ Added¶
rtc_get_time_ms()- Millisecond-precision RTC time getterrtc_get_time_us()- Microsecond-precision RTC time getterCommand::get_rtc_time_ms()andCommand::get_rtc_time_us()methodsGET_RTC_TIME_MSandGET_RTC_TIME_UScommand handlershit_typefield output to JSONL format (stream_formatter)
๐ง Changed¶
detected_atfield type:uint32_tโuint64_t(seconds โ microseconds)- RTC timestamp capture uses
rtc_get_time_us()for high precision stream_data_t.detected_atdocumentation updated to reflect microsecond units- JSONL output now includes
hit_typefield whenENABLE_HITTYPE=1
๐ Fixed¶
- JSONL format was missing
hit_typefield (now included) - RTC timestamp precision limited to seconds (now microseconds)
Is It Safe to Upgrade?¶
Backward Compatible: Mostly Yes (with notes)
- Breaking change:
detected_atfield type changed fromuint32_ttouint64_t - If you parse
detected_atin client code expecting 32-bit values, update your parsers - JSON serialization handles this transparently
-
Serial text output works without changes
-
New commands are additive (no breaking changes)
- JSONL
hit_typefield is optional (only whenENABLE_RTC=1+ENABLE_HITTYPE=1)
Tests Passed¶
- โ Builds without errors (esp32dev-release profile)
- โ RTC manager functions compile and link correctly
- โ Command dispatch table updated with new handlers
- โ Pre-commit hooks passed (trailing whitespace, formatting)
- โ stream_formatter JSONL output includes all fields
Release Details¶
- Date: 2025-12-12
- Version: v1.16.5
- Files Changed: 13
include/rtc_manager.h- Added function signaturessrc/rtc_manager.cpp- Implementedrtc_get_time_ms(),rtc_get_time_us()include/command.h- Added Command class methodssrc/command.cpp- Implemented methodssrc/command/rtc.cpp- Added handlers for GET_RTC_TIME_MS, GET_RTC_TIME_USsrc/command_manager.cpp- Registered commandsinclude/stream_data.h- Updateddetected_attype and docssrc/stream_formatter.cpp- Added JSONL hit_type outputsrc/main.cpp- Updated to usertc_get_time_us()src/detection_processor.cpp- Updated to usertc_get_time_us()
Next Steps¶
- Phase 7: GNSS timestamp integration with microsecond precision
- Consider 1PPS (1 Pulse Per Second) signal synchronization for multi-detector coordination
- Timestamp field documentation and migration guide for client libraries