pub fn on_recv_interrupt<W5500: Registers>(
        &self,
        w5500: &mut W5500,
    ) -> Result<Reply, Error<W5500::Error>> {
        let sn_ir: SocketInterrupt = w5500.sn_ir(self.sn)?;
        if sn_ir.any_raised() {
            w5500.set_sn_ir(self.sn, sn_ir)?;
        }

        let mut buf: [u8; 48] = [0; 48];
        let mut reader: UdpReader<W5500> = w5500.udp_reader(self.sn)?;

        if reader.header().origin != self.server {
            debug!("unexpected packet from {}", reader.header().origin);
            reader.done()?;
            return Err(Error::WouldBlock);
        }
        reader.read_exact(&mut buf)?;
        reader.done()?;

        match Mode::try_from(buf[0] & 0b111) {
            Ok(Mode::Server) => (),
            Ok(mode) => {
                warn!("invalid mode for reply: {:?}", mode);
                return Err(Error::WouldBlock);
            }
            Err(value) => {
                warn!("invalid value for mode: {}", value);
                return Err(Error::WouldBlock);
            }
        };

        let version_number: u8 = (buf[0] >> 3) & 0b111;
        if version_number != VERSION_NUMBER {
            warn!("unsupported version number: {}", version_number);
            return Err(Error::WouldBlock);
        }

        let leap_indicator: LeapIndicator = LeapIndicator::from_bits(buf[0] >> 6);

        let stratum: Stratum = match buf[1].try_into() {
            Ok(stratum) => stratum,
            Err(value) => {
                warn!("invalid value for stratum: {}", value);
                return Err(Error::WouldBlock);
            }
        };

        let poll: u8 = buf[2];
        if poll != 0 {
            // poll is copied from request for unicast/multicast
            warn!("poll value should be zero not {}", poll);
            return Err(Error::WouldBlock);
        }

        Ok(Reply {
            leap_indicator,
            stratum,
            precision: buf[3] as i8,
            root_delay: FixedPoint {
                bits: u32::from_be_bytes(buf[4..8].try_into().unwrap()),
            },
            root_dispersion: FixedPoint {
                bits: u32::from_be_bytes(buf[8..12].try_into().unwrap()),
            },
            reference_identifier: buf[12..16].try_into().unwrap(),
            reference_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[16..24].try_into().unwrap()),
            },
            originate_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[24..32].try_into().unwrap()),
            },
            receive_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[32..40].try_into().unwrap()),
            },
            transmit_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[40..48].try_into().unwrap()),
            },
        })
    }
/// Read a reply from the server.
///
/// You should only call this method after sending a [`request`] and
/// receiving a RECV interrupt.
///
/// This will clear the pending RECV interrupt.
///
/// # Errors
///
/// This method can only return:
///
/// * [`Error::Other`]
/// * [`Error::WouldBlock`]
///   * In addition to being returned if there is no data to read this can
///     also be returned when receiving invalid packets.
///
/// # Example
///
/// ```no_run
/// # let mut w5500 = w5500_regsim::W5500::default();
/// use w5500_sntp::{
///     hl::Error,
///     ll::{
///         net::{Ipv4Addr, SocketAddrV4},
///         Sn,
///     },
///     Client, Reply, DST_PORT,
/// };
///
/// const SNTP_SRC_PORT: u16 = 123;
/// const SNTP_SERVER: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(216, 239, 35, 4), DST_PORT);
///
/// let sntp_client: Client = Client::new(Sn::Sn3, SNTP_SRC_PORT, SNTP_SERVER);
/// sntp_client.setup_socket(&mut w5500)?;
/// sntp_client.request(&mut w5500)?;
///
/// // ... wait for RECV interrupt with a timeout
///
/// let reply: Reply = match sntp_client.on_recv_interrupt(&mut w5500) {
///     Err(Error::WouldBlock) => todo!("implement retry logic here"),
///     Err(e) => todo!("handle error: {:?}", e),
///     Ok(reply) => reply,
/// };
/// # Ok::<(), w5500_hl::Error<std::io::ErrorKind>>(())
/// ```
///
/// [`request`]: Self::request
Read a reply from the server.
You should only call this method after sending a [`request`] and
receiving a RECV interrupt.

This will clear the pending RECV interrupt.
Read a reply from the server . You should only call this method after sending a [ ` request ` ] and receiving a RECV interrupt . This will clear the pending RECV interrupt .
pub fn on_recv_interrupt<W5500: Registers>(
        &self,
        w5500: &mut W5500,
    ) -> Result<Reply, Error<W5500::Error>> {
        let sn_ir: SocketInterrupt = w5500.sn_ir(self.sn)?;
        if sn_ir.any_raised() {
            w5500.set_sn_ir(self.sn, sn_ir)?;
        }
        let mut buf: [u8; 48] = [0; 48];
        let mut reader: UdpReader<W5500> = w5500.udp_reader(self.sn)?;
        if reader.header().origin != self.server {
            debug!("unexpected packet from {}", reader.header().origin);
            reader.done()?;
            return Err(Error::WouldBlock);
        }
        reader.read_exact(&mut buf)?;
        reader.done()?;
        match Mode::try_from(buf[0] & 0b111) {
            Ok(Mode::Server) => (),
            Ok(mode) => {
                warn!("invalid mode for reply: {:?}", mode);
                return Err(Error::WouldBlock);
            }
            Err(value) => {
                warn!("invalid value for mode: {}", value);
                return Err(Error::WouldBlock);
            }
        };
        let version_number: u8 = (buf[0] >> 3) & 0b111;
        if version_number != VERSION_NUMBER {
            warn!("unsupported version number: {}", version_number);
            return Err(Error::WouldBlock);
        }
        let leap_indicator: LeapIndicator = LeapIndicator::from_bits(buf[0] >> 6);
        let stratum: Stratum = match buf[1].try_into() {
            Ok(stratum) => stratum,
            Err(value) => {
                warn!("invalid value for stratum: {}", value);
                return Err(Error::WouldBlock);
            }
        };
        let poll: u8 = buf[2];
        if poll != 0 {
            // poll is copied from request for unicast/multicast
            warn!("poll value should be zero not {}", poll);
            return Err(Error::WouldBlock);
        }
        Ok(Reply {
            leap_indicator,
            stratum,
            precision: buf[3] as i8,
            root_delay: FixedPoint {
                bits: u32::from_be_bytes(buf[4..8].try_into().unwrap()),
            },
            root_dispersion: FixedPoint {
                bits: u32::from_be_bytes(buf[8..12].try_into().unwrap()),
            },
            reference_identifier: buf[12..16].try_into().unwrap(),
            reference_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[16..24].try_into().unwrap()),
            },
            originate_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[24..32].try_into().unwrap()),
            },
            receive_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[32..40].try_into().unwrap()),
            },
            transmit_timestamp: Timestamp {
                bits: u64::from_be_bytes(buf[40..48].try_into().unwrap()),
            },
        })
    }
pub fn on_recv_interrupt < W5500 : Registers > ( & self , w5500 : & mut W5500 , ) -> Result < Reply , Error < W5500 :: Error > > { let sn_ir : SocketInterrupt = w5500 . sn_ir ( self . sn ) ? ; if sn_ir . any_raised ( ) { w5500 . set_sn_ir ( self . sn , sn_ir ) ? ; } let mut buf : [ u8 ; 48 ] = [ 0 ; 48 ] ; let mut reader : UdpReader < W5500 > = w5500 . udp_reader ( self . sn ) ? ; if reader . header ( ) . origin != self . server { debug ! ( " " reader header ( ) origin ) ; reader . done ( ) ? ; return Err ( Error :: WouldBlock ) ; } reader . read_exact ( & mut buf ) ? ; reader . done ( ) ? ; match Mode :: try_from ( buf [ 0 ] & 0b111 ) { Ok ( Mode :: Server ) => ( ) , Ok ( mode ) => { warn ! ( " " mode ) ; return Err ( Error :: WouldBlock ) ; } Err ( value ) => { warn ! ( " " value ) ; return Err ( Error :: WouldBlock ) ; } } ; let version_number : u8 = ( buf [ 0 ] >> 3 ) & 0b111 ; if version_number != VERSION_NUMBER { warn ! ( " " version_number ) ; return Err ( Error :: WouldBlock ) ; } let leap_indicator : LeapIndicator = LeapIndicator :: from_bits ( buf [ 0 ] >> 6 ) ; let stratum : Stratum = match buf [ 1 ] . try_into ( ) { Ok ( stratum ) => stratum , Err ( value ) => { warn ! ( " " value ) ; return Err ( Error :: WouldBlock ) ; } } ; let poll : u8 = buf [ 2 ] ; if poll != 0 { // poll is copied from request for unicast/multicast warn ! ( " " poll ) ; return Err ( Error :: WouldBlock ) ; } Ok ( Reply { leap_indicator , stratum , precision : buf [ 3 ] as i8 , root_delay : FixedPoint { bits : u32 :: from_be_bytes ( buf [ 4 .. 8 ] . try_into ( ) . unwrap ( ) ) , } , root_dispersion : FixedPoint { bits : u32 :: from_be_bytes ( buf [ 8 .. 12 ] . try_into ( ) . unwrap ( ) ) , } , reference_identifier : buf [ 12 .. 16 ] . try_into ( ) . unwrap ( ) , reference_timestamp : Timestamp { bits : u64 :: from_be_bytes ( buf [ 16 .. 24 ] . try_into ( ) . unwrap ( ) ) , } , originate_timestamp : Timestamp { bits : u64 :: from_be_bytes ( buf [ 24 .. 32 ] . try_into ( ) . unwrap ( ) ) , } , receive_timestamp : Timestamp { bits : u64 :: from_be_bytes ( buf [ 32 .. 40 ] . try_into ( ) . unwrap ( ) ) , } , transmit_timestamp : Timestamp { bits : u64 :: from_be_bytes ( buf [ 40 .. 48 ] . try_into ( ) . unwrap ( ) ) , } , } ) }
Read a reply from the server.
Read a reply from the server .
&self
w5500
&mut W5500
&self
w5500
&mut W5500
errors
This method can only return.

[`Error::Other`]
[`Error::WouldBlock`]
In addition to being returned if there is no data to read this can
also be returned when receiving invalid packets.
This method can only return . [ ` Error :: Other ` ] [ ` Error :: WouldBlock ` ] In addition to being returned if there is no data to read this can also be returned when receiving invalid packets .
example
None
let mut w5500 = w5500_regsim::w5500::default();
use w5500_sntp::{
hl::Error,
ll::{
net::{Ipv4Addr, SocketAddrV4},
Sn,
},
Client, Reply, DST_PORT,
}.

const SNTP_SRC_PORT: u16 = 123;
const SNTP_SERVER: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(216, 239, 35, 4), DST_PORT).

let sntp_client: Client = Client::new(Sn::Sn3, SNTP_SRC_PORT, SNTP_SERVER);
sntp_client.setup_socket(&mut w5500)?;
sntp_client.request(&mut w5500)?.

wait for RECV interrupt with a timeout

let reply: Reply = match sntp_client.on_recv_interrupt(&mut w5500) {
Err(Error::WouldBlock) => todo!("implement retry logic here"),
Err(e) => todo!("handle error: {:?}", e),
Ok(reply) => reply,
}.
use w5500_sntp :: { hl :: Error ll :: { net :: { Ipv4Addr SocketAddrV4 } Sn } Client Reply DST_PORT } . const SNTP_SRC_PORT : u16 = 123 ; const SNTP_SERVER : SocketAddrV4 = SocketAddrV4 :: new ( Ipv4Addr :: new ( 216 239 35 4 ) DST_PORT ) . let sntp_client : Client = Client :: new ( Sn :: Sn3 SNTP_SRC_PORT SNTP_SERVER ) ; sntp_client . setup_socket ( &mut w5500 ) ? ; sntp_client . request ( &mut w5500 ) ? . wait for RECV interrupt with a timeout let reply : Reply = match sntp_client . on_recv_interrupt ( &mut w5500 ) { Err ( Error :: WouldBlock ) = > todo! ( " implement retry logic here " ) Err ( e ) = > todo! ( " handle error : { : ? } " e ) Ok ( reply ) = > reply } .
ok::<(), w5500_hl::error<std::io::errorkind>>(())
None