mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
feat: add web API for status, sync, and configuration
Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) <aider@aider.chat>
This commit is contained in:
parent
a124aae424
commit
8ad553aaee
5 changed files with 297 additions and 125 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -1,10 +1,12 @@
|
|||
// src/main.rs
|
||||
|
||||
mod api;
|
||||
mod config;
|
||||
mod sync_logic;
|
||||
mod serial_input;
|
||||
mod ui;
|
||||
|
||||
use crate::api::start_api_server;
|
||||
use crate::config::watch_config;
|
||||
use crate::sync_logic::LtcState;
|
||||
use crate::serial_input::start_serial_thread;
|
||||
|
|
@ -30,7 +32,8 @@ fn ensure_config() {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// 🔄 Ensure there's always a config.json present
|
||||
ensure_config();
|
||||
|
||||
|
|
@ -73,7 +76,18 @@ fn main() {
|
|||
});
|
||||
}
|
||||
|
||||
// 6️⃣ Keep main thread alive
|
||||
// 6️⃣ Spawn the API server thread
|
||||
{
|
||||
let api_state = ltc_state.clone();
|
||||
let offset_clone = hw_offset.clone();
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = start_api_server(api_state, offset_clone).await {
|
||||
eprintln!("API server error: {}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 7️⃣ Keep main thread alive by processing LTC frames
|
||||
println!("📡 Main thread entering loop...");
|
||||
for _frame in rx {
|
||||
// no-op
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue