// SPDX-License-Identifier: MIT OR Apache-2.0 // Copyright 2024 René Ladan use dcf77_utils::DCF77Utils; fn main() { let mut dcf77 = DCF77Utils::default(); // The 'N' is there to indicate the end-of-minute marker const MSGS: [&str; 2] = [ "0 0101.0010.1100.10 0 010 0 1 1110.000 1 1100.01 1 1001.00 010 0010.0 0010.0100 0N", "0 0110.0110.1010.10 0 010 0 1 1000.000 1 0100.01 0 0000.10 110 0010.0 0010.0100 0N", ]; for msg in MSGS { for m in msg.chars() { match m { '0' => dcf77.set_current_bit(Some(false)), '1' => dcf77.set_current_bit(Some(true)), '_' => dcf77.set_current_bit(None), 'N' => dcf77.force_new_minute(), _ => continue, // skip increasing the second counter, as this character is only syntactic sugar } if !dcf77.increase_second() { println!("Bad increase_second at second {}", dcf77.get_old_second()); } } // cache because decode_time() clears this on a successful decode let fm = dcf77.is_first_minute(); print!("first_minute={} ", fm); dcf77.decode_time(true, false); let rdt = dcf77.get_radio_datetime(); println!( "Date/time={:?}-{:?}-{:?} {:?}:{:?} {:?}", rdt.get_year(), rdt.get_month(), rdt.get_day(), rdt.get_hour(), rdt.get_minute(), rdt.get_weekday() ); if !fm { println!( "Jumps={} {} {} {} {} {}", rdt.get_jump_year(), rdt.get_jump_month(), rdt.get_jump_day(), rdt.get_jump_hour(), rdt.get_jump_minute(), rdt.get_jump_weekday() ); } } }