Appendix D — Event ID Encoding Reference
Event IDs are 64-bit (8-byte) values carried in Producer/Consumer Event Report (PCER) messages and identification messages. This appendix documents the well-known event IDs, broadcast time encoding, train search encoding, and range encoding used by the library.
D.1 Well-Known Events: Auto-Routed
Events in the 0x0100000000xxxxxx range are automatically forwarded by gateways between network segments:
| Constant | Event ID | Description |
|---|---|---|
EVENT_ID_EMERGENCY_OFF | 0x010000000000FFFF | Emergency Off -- immediately stop all layout activity |
EVENT_ID_CLEAR_EMERGENCY_OFF | 0x010000000000FFFE | Clear Emergency Off -- resume normal operation |
EVENT_ID_EMERGENCY_STOP | 0x010000000000FFFD | Emergency Stop -- stop all trains but maintain power |
EVENT_ID_CLEAR_EMERGENCY_STOP | 0x010000000000FFFC | Clear Emergency Stop -- trains may resume |
EVENT_ID_NODE_RECORDED_NEW_LOG | 0x010000000000FFF8 | Node has recorded a new log entry |
EVENT_ID_POWER_SUPPLY_BROWN_OUT_NODE | 0x010000000000FFF1 | Power supply brown-out detected on specific node |
EVENT_ID_POWER_SUPPLY_BROWN_OUT_STANDARD | 0x010000000000FFF0 | Power supply brown-out on standard power bus |
EVENT_ID_IDENT_BUTTON_COMBO_PRESSED | 0x010000000000FF00 | Identification button combination pressed |
EVENT_ID_LINK_ERROR_CODE_1 | 0x010000000000FF01 | Link layer error code 1 |
EVENT_ID_LINK_ERROR_CODE_2 | 0x010000000000FF02 | Link layer error code 2 |
EVENT_ID_LINK_ERROR_CODE_3 | 0x010000000000FF03 | Link layer error code 3 |
EVENT_ID_LINK_ERROR_CODE_4 | 0x010000000000FF04 | Link layer error code 4 |
D.2 Well-Known Events: Non-Auto-Routed
Events in the 0x0101xxxxxxxxxxxx range are segment-local and not forwarded by gateways:
| Constant | Event ID | Description |
|---|---|---|
EVENT_ID_DUPLICATE_NODE_DETECTED | 0x0101000000000201 | Duplicate Node ID detected on network |
EVENT_ID_TRAIN | 0x0101000000000303 | Train node identification event |
EVENT_ID_TRAIN_PROXY | 0x0101000000000304 | Train proxy identification (deprecated) |
EVENT_ID_FIRMWARE_CORRUPTED | 0x0101000000000601 | Node firmware is corrupted |
EVENT_ID_FIRMWARE_UPGRADE_BY_HARDWARE_SWITCH | 0x0101000000000602 | Firmware upgrade initiated by hardware switch |
D.3 Broadcast Time Event Encoding
Broadcast time events use 8-byte Event IDs where the upper 6 bytes identify the clock and the lower 2 bytes encode the time data or command:
Event ID layout:
Bytes 0-5: Clock ID (identifies which clock)
Bytes 6-7: Command/Data (time, date, year, rate, or control command)
Example: Default Fast Clock, Report Time 14:30
Clock ID: 01.01.00.00.01.00
Data: 0E.1E (hour=14 in bits 12-8, minute=30 in bits 7-0)
Event ID: 01.01.00.00.01.00.0E.1E
Clock Identifiers
| Constant | Clock ID (6 bytes) | Description |
|---|---|---|
BROADCAST_TIME_ID_DEFAULT_FAST_CLOCK | 01.01.00.00.01.00 | Default Fast Clock |
BROADCAST_TIME_ID_DEFAULT_REALTIME_CLOCK | 01.01.00.00.01.01 | Default Real-time Clock |
BROADCAST_TIME_ID_ALTERNATE_CLOCK_1 | 01.01.00.00.01.02 | Alternate Clock 1 |
BROADCAST_TIME_ID_ALTERNATE_CLOCK_2 | 01.01.00.00.01.03 | Alternate Clock 2 |
Data Type Ranges (Lower 2 Bytes)
| Constant | Range | Description |
|---|---|---|
BROADCAST_TIME_REPORT_TIME_BASE | 0x0000-0x17FF | Report Time: hour (bits 12-8) + minute (bits 7-0) |
BROADCAST_TIME_REPORT_DATE_BASE | 0x2100-0x2CFF | Report Date: month (bits 11-8) + day (bits 7-0) |
BROADCAST_TIME_REPORT_YEAR_BASE | 0x3000-0x3FFF | Report Year: year (bits 11-0) |
BROADCAST_TIME_REPORT_RATE_BASE | 0x4000-0x4FFF | Report Rate: 12-bit signed fixed-point (2 fractional bits) |
BROADCAST_TIME_SET_TIME_BASE | 0x8000-0x97FF | Set Time command (same encoding as Report Time) |
BROADCAST_TIME_SET_DATE_BASE | 0xA100-0xACFF | Set Date command (same encoding as Report Date) |
BROADCAST_TIME_SET_YEAR_BASE | 0xB000-0xBFFF | Set Year command (same encoding as Report Year) |
BROADCAST_TIME_SET_RATE_BASE | 0xC000-0xCFFF | Set Rate command (same encoding as Report Rate) |
BROADCAST_TIME_QUERY | 0xF000 | Query -- request synchronization |
BROADCAST_TIME_STOP | 0xF001 | Stop clock |
BROADCAST_TIME_START | 0xF002 | Start clock |
BROADCAST_TIME_DATE_ROLLOVER | 0xF003 | Date Rollover (midnight crossing) |
D.4 Train Search Event Encoding
Train search events use the 09.00.99.FF prefix. The lower 4 bytes encode the search address and flags:
Event ID: 09.00.99.FF.xx.xx.xx.xx
Bytes 4-6: Search address encoded as 6 BCD nibbles, MSB first
Short queries padded with 0xF nibbles
Byte 7: Flags byte
Train Search Flags
| Constant | Value | Description |
|---|---|---|
TRAIN_SEARCH_FLAG_ALLOCATE | 0x80 | Allocate new train node if no match found |
TRAIN_SEARCH_FLAG_EXACT | 0x40 | Exact match only (no partial matching) |
TRAIN_SEARCH_FLAG_ADDRESS_ONLY | 0x20 | Match address only (not name) |
TRAIN_SEARCH_FLAG_DCC | 0x08 | DCC protocol |
TRAIN_SEARCH_FLAG_LONG_ADDR | 0x04 | Force long (14-bit) DCC address |
TRAIN_SEARCH_SPEED_STEP_MASK | 0x03 | Speed step mode (bits 1-0): 0=default, 1=14, 2=28, 3=128 |
D.5 Event Range Encoding
Event ranges allow a node to express interest in a contiguous block of Event IDs using a single identification message. The range is defined by a base Event ID and a power-of-2 count:
// Range structure
typedef struct {
event_id_t start_base; // Starting Event ID
event_range_count_enum event_count; // Number of consecutive IDs
} event_id_range_t;
Supported range sizes (defined in event_range_count_enum):
| Enum Value | Range Size |
|---|---|
EVENT_RANGE_COUNT_1 | 1 (single event) |
EVENT_RANGE_COUNT_2 | 2 |
EVENT_RANGE_COUNT_4 | 4 |
EVENT_RANGE_COUNT_8 | 8 |
EVENT_RANGE_COUNT_16 | 16 |
| ... | (powers of 2) |
EVENT_RANGE_COUNT_32768 | 32768 |
Well-known event IDs are defined in openlcb_defines.h (groups well_known_events_auto and well_known_events_local). Broadcast time constants are in the broadcast_time_events group. Train search constants are in the well_known_events_local group. Range types are in openlcb_types.h.