diff --git a/src/ptp.rs b/src/ptp.rs index 0a2dfc1..85c0b85 100644 --- a/src/ptp.rs +++ b/src/ptp.rs @@ -102,7 +102,7 @@ async fn run_ptp_session( // 5. Create network handles fn create_socket( - interface: &str, + _interface: &str, port: u16, ) -> Result> { let socket = Socket::new(Domain::IPV4, Type::DGRAM, Some(Protocol::UDP))?; @@ -159,22 +159,20 @@ async fn run_ptp_session( return Ok(()); } - let timer_instant = running_port - .get_next_timer_instant() - .map(tokio::time::Instant::from_std) - .unwrap_or_else(|| tokio::time::Instant::now() + Duration::from_secs(1)); - actions = Vec::new(); tokio::select! { - _ = tokio::time::sleep_until(timer_instant) => { - actions.extend(running_port.handle_timer()); + _ = tokio::time::sleep(Duration::from_millis(100)) => { + // Handle periodic timer events + actions.extend(running_port.handle_sync_timer()); + actions.extend(running_port.handle_announce_timer()); + actions.extend(running_port.handle_delay_request_timer()); } Ok((len, source_address)) = event_socket.recv_from(&mut event_buf) => { - actions.extend(running_port.handle_message(&event_buf[..len], source_address)); + actions.extend(running_port.handle_event_receive(&event_buf[..len], source_address)); } Ok((len, source_address)) = general_socket.recv_from(&mut general_buf) => { - actions.extend(running_port.handle_message(&general_buf[..len], source_address)); + actions.extend(running_port.handle_general_receive(&general_buf[..len], source_address)); } }