migrate service name to some place public

This commit is contained in:
bunnie 2025-11-29 01:01:04 +08:00
parent 4a62108da2
commit 4ec0eda2b5
2 changed files with 6 additions and 4 deletions

View file

@ -1,3 +1,7 @@
/// This is a "well known name" used by `libstd` to connect to the time server
/// Anyone who wants to check if time has been initialized would use this name.
pub const TIME_SERVER_PUBLIC: &'static [u8; 16] = b"timeserverpublic";
/// Do not modify the discriminants in this structure. They are used in `libstd` directly.
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
pub enum TimeOp {

View file

@ -1,12 +1,9 @@
use bao1x_hal::rtc::*;
use utralib::*;
use crate::api::TIME_SERVER_PUBLIC;
use crate::api::TimeOp;
/// This is a "well known name" used by `libstd` to connect to the time server
/// Anyone who wants to check if time has been initialized would use this name.
pub const TIME_SERVER_PUBLIC: &'static [u8; 16] = b"timeserverpublic";
pub fn start_rtc_service() {
let _ = std::thread::spawn({
move || {
@ -144,6 +141,7 @@ fn rtc_service() -> ! {
let tz_hi_ms = scalar.arg1;
let tz_lo_ms = scalar.arg2;
let tz_ms = ((tz_hi_ms as i64) << 32) | (tz_lo_ms as i64);
log::info!("TZ offset set to {}", tz_ms / 1000);
// sanity check with very broad bounds: I don't know of any time zones that are more
// than +/2 days from UTC 86400 seconds in a day, times 1000
// milliseconds, times 2 days