[][src]Enum w5500_ll::SocketCommand

#[repr(u8)]pub enum SocketCommand {
    Accepted,
    Open,
    Listen,
    Connect,
    Disconnect,
    Close,
    Send,
    SendMac,
    SendKeep,
    Recv,
}

Socket commands.

This is used to set the command for socket n.

After W5500 accepts the command, the crate::Registers::set_sn_cr register is automatically cleared to 0x00. Even though crate::Registers::set_sn_cr is cleared to 0x00, the command is still being processed. To check whether the command is completed or not, check crate::Registers::sn_ir or crate::Registers::sn_sr.

Variants

Accepted

The command register clears to this state once a command has been accepted.

Open
Listen

Operate the socket as a TCP server.

This will change the socket state from SocketStatus::Init to SocketStatus::Listen, and the socket will listen for a connection-request (SYN packet) from any TCP client.

When a TCP client connection request is successfully established, the socket state changes from SocketStatus::Listen to SocketStatus::Established and the CON socket interrupt is raised (crate::SocketInterrupt::con_raised).

When a TCP client connection request fails the TIMEOUT socket interrupt is set (crate::SocketInterrupt::timeout_raised) and the socket status changes to SocketStatus::Closed.

Only valid in Protocol::Tcp mode.

Connect

Connect to a TCP server.

A connect-request (SYN packet) is sent to the TCP server configured by crate::Registers::sn_dipr and crate::Registers::sn_dport (destination IPv4 address and port).

If the connect-request is successful, the socket state changes to SocketStatus::Established and the CON socket interrupt is raised (crate::SocketInterrupt::con_raised).

The connect-request fails in the following three cases:

  1. When a ARPTO occurs (crate::SocketInterrupt::con_raised) because the destination hardware address is not acquired through the ARP-process.
  2. When a SYN/ACK packet is not received within the TCP timeout duration set by crate::Registers::rcr and crate::Registers::rtr (crate::SocketInterrupt::timeout_raised).
  3. When a RST packet is received instead of a SYN/ACK packet.

In these cases the socket state changes to SocketStatus::Closed.

Only valid in Protocol::Tcp mode when acting as a TCP client.

Disconnect

Start the disconnect process.

  • Active close it transmits disconnect-request(FIN packet) to the connected peer.
  • Passive close when FIN packet is received from peer, a FIN packet is replied back to the peer.

When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), the socket state changes to SocketStatus::Closed. Otherwise, TCP timeout occurs (crate::SocketInterrupt::timeout_raised) and then the socket state changes to SocketStatus::Closed.

If SocketCommand::Close is used instead of SocketCommand::Disconnect, the socket state is changes to SocketStatus::Closed without the disconnect process.

If a RST packet is received from a peer during communication the socket status is unconditionally changed to SocketStatus::Closed.

Only valid in Protocol::Tcp mode.

Close

Close the socket.

The socket status is changed to SocketStatus::Closed.

Send

Transmits all the data in the socket TX buffer.

SendMac

The basic operation is same as SocketCommand::Send.

Normally SocketCommand::Send transmits data after destination hardware address is acquired by the automatic ARP-process (Address Resolution Protocol). SocketCommand::SendMac transmits data without the automatic ARP-process. In this case, the destination hardware address is acquired from crate::Registers::sn_dhar configured by the host, instead of the ARP process.

Only valid in Protocol::Udp mode.

SendKeep

Sends a 1 byte keep-alive packet.

If the peer cannot respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur (crate::SocketInterrupt::timeout_raised).

Only valid in Protocol::Tcp mode.

Recv

RECV completes the processing of the received data in socket RX buffer.

See crate::Registers::sn_rx_buf for an example.

Trait Implementations

impl Clone for SocketCommand[src]

impl Copy for SocketCommand[src]

impl Debug for SocketCommand[src]

impl Eq for SocketCommand[src]

impl Hash for SocketCommand[src]

impl Ord for SocketCommand[src]

impl PartialEq<SocketCommand> for SocketCommand[src]

impl PartialOrd<SocketCommand> for SocketCommand[src]

impl StructuralEq for SocketCommand[src]

impl StructuralPartialEq for SocketCommand[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.