dcf77

package
v0.331.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package dcf77 decodes DCF77 time-signal frames — the long-wave (77.5 kHz) radio broadcast from Mainflingen, Germany, that carries the current Central European time + date. Pure offline parser; no transport, no hardware.

Wrap-vs-native judgement: the DCF77 frame format is a fully public spec (PTB / "Time signal and frequency standard DCF77", ETSI EN 300 220-1). The walker is bit-level decoding over a 60-bit frame with BCD-weighted time/date fields and three parity bits. Wrapping a FAP for this would require an SD-card install + a firmware-fork dependency for a pure parser. Native delivers offline analysis — operators paste a 60-bit DCF77 bit-stream captured by their SDR (rtl_sdr → gnuradio DCF77 block) or consumer radio-clock test pin and decode the time without running a fresh capture.

What this package covers:

  • 60-bit frame walker: header (start-of-minute marker, weather, antenna-switch announcement, DST-change announcement, CET/CEST indicator, leap-second announcement), time field (start marker + 7-bit BCD minutes + parity + 6-bit BCD hours + parity), date field (6-bit BCD day-of-month + 3-bit BCD day-of-week + 5-bit BCD month + 8-bit BCD year + parity)
  • BCD weighting per the official table (1+2+4+8+10+20+40+80)
  • Even-parity validity checks for minutes / hours / date
  • DST flag interpretation (CET vs CEST = UTC+1 vs UTC+2)
  • Day-of-week mapping (1=Monday through 7=Sunday)

What this package does NOT cover (deliberately out of scope):

  • The first 14 bits (weather data) — encrypted by PTB, surfaced as raw hex for cross-reference
  • Demodulation / sync detection (operators bring the pre-aligned 60-bit frame)
  • Year-rollover detection (the 2-digit year wraps every century — we surface the raw decode and let the caller decide what century to apply)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame struct {
	// StartOfMinute is bit 0 — must be 0 per spec. Surfaced so
	// callers can flag malformed inputs.
	StartOfMinute bool `json:"start_of_minute_marker"`
	// WeatherDataHex is bits 1..14 — encrypted by PTB, surfaced
	// as 14-bit binary string for cross-reference.
	WeatherDataBits string `json:"weather_data_bits"`
	// AntennaSwitchAnnouncement (bit 15) — set when DCF77 is
	// about to switch from main to backup antenna in the next
	// hour.
	AntennaSwitchAnnouncement bool `json:"antenna_switch_announcement"`
	// DSTChangeAnnouncement (bit 16) — set when CET/CEST
	// transition will occur in the next hour.
	DSTChangeAnnouncement bool `json:"dst_change_announcement"`
	// CESTActive (bits 17..18) — true when CEST (UTC+2) is in
	// effect, false when CET (UTC+1).
	CESTActive bool `json:"cest_active"`
	// TimezoneOffsetHours is +1 for CET, +2 for CEST.
	TimezoneOffsetHours int `json:"timezone_offset_hours"`
	// LeapSecondAnnouncement (bit 19) — set when a leap second
	// will be inserted at end of the next hour.
	LeapSecondAnnouncement bool `json:"leap_second_announcement"`
	// StartOfTime (bit 20) — must be 1 per spec.
	StartOfTime bool `json:"start_of_time_marker"`
	// Minute (bits 21..27): 0-59.
	Minute int `json:"minute"`
	// MinuteParityValid — even parity over bits 21..27 (bit 28).
	MinuteParityValid bool `json:"minute_parity_valid"`
	// Hour (bits 29..34): 0-23.
	Hour int `json:"hour"`
	// HourParityValid — even parity over bits 29..34 (bit 35).
	HourParityValid bool `json:"hour_parity_valid"`
	// DayOfMonth (bits 36..41): 1-31.
	DayOfMonth int `json:"day_of_month"`
	// DayOfWeek (bits 42..44): 1=Mon, 2=Tue, ..., 7=Sun.
	DayOfWeek     int    `json:"day_of_week"`
	DayOfWeekName string `json:"day_of_week_name"`
	// Month (bits 45..49): 1-12.
	Month int `json:"month"`
	// Year (bits 50..57): 0-99 (the caller chooses the century).
	Year int `json:"year"`
	// DateParityValid — even parity over bits 36..57 (bit 58).
	DateParityValid bool `json:"date_parity_valid"`
	// FormattedTime renders the decoded time as "HH:MM" for
	// quick reads.
	FormattedTime string `json:"formatted_time"`
	// FormattedDate renders the decoded date as "YYYY-MM-DD"
	// using a 20YY century assumption (covers DCF77's current
	// operating window 2000-2099).
	FormattedDate string `json:"formatted_date"`
	// AllParityValid is the AND of MinuteParityValid +
	// HourParityValid + DateParityValid. Convenience flag for
	// callers that want a single "frame integrity" indicator.
	AllParityValid bool `json:"all_parity_valid"`
}

Frame is the top-level decoded DCF77 frame.

func Decode

func Decode(bitStream string) (Frame, error)

Decode parses a 60-bit string of '0' and '1' characters into a Frame. Tolerates ':' / '-' / '_' / whitespace separators.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL