Struct w5500_ll::SocketMode [−][src]
pub struct SocketMode(_);
Expand description
Socket Mode Register (Sn_MR).
This is used by the Registers::sn_mr
and
Registers::set_sn_mr
methods.
Implementations
Default value.
This is the same as default
, but as a const
value.
Example
use w5500_ll::SocketMode;
assert_eq!(SocketMode::DEFAULT, SocketMode::default());
Bit offset for the MULTI
field.
Bit offset for the MFEN
field.
Bit offset for the BCASTB
field.
Bit offset for the MMB
field.
Bit offset for the UCASTB
field.
Bit offset for the MIP6B
field.
Bit mask for the MULTI
field.
Bit mask for the BCASTB
field.
Bit mask for the UCASTB
field.
Bit mask for the MIP6B
field.
Bit mask for the PROTOCOL
field.
Get the protocol.
This returns an Err(u8)
with the protocol bits if the protocol bits
do not match a valid protocol.
Example
use w5500_ll::{Protocol, SocketMode};
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert_eq!(sn_mr.protocol(), Ok(Protocol::Closed));
Set the protocol.
Example
use w5500_ll::{Protocol, SocketMode};
const SN_MR: SocketMode = SocketMode::DEFAULT.set_protocol(Protocol::Tcp);
assert_eq!(SN_MR.protocol(), Ok(Protocol::Tcp));
Multicasting.
This applies only for a socket with the UDP protocol.
To use multicasting Registers::sn_dipr
and Registers::sn_dport
should be configured with the multicast group IP and port number
before the socket is opened.
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.multi_enabled());
let sn_mr: SocketMode = sn_mr.enable_multi();
assert!(sn_mr.multi_enabled());
let sn_mr: SocketMode = sn_mr.disable_multi();
assert!(!sn_mr.multi_enabled());
Enable multicasting.
Disable multicasting.
MAC filter.
This applies only for a socket with the MACRAW protocol.
When enabled the W5500 can only receive broadcasting packets sent to itself. When disabled the W5500 can receive all packets. If you want to implement a hybrid TCP/IP stack it is recommended that this is enabled for reducing host overhead to process all the received packets.
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mfen_enabled());
let sn_mr: SocketMode = sn_mr.enable_mfen();
assert!(sn_mr.mfen_enabled());
let sn_mr: SocketMode = sn_mr.disable_mfen();
assert!(!sn_mr.mfen_enabled());
Enable MAC filter.
Disable MAC filter.
Broadcast blocking.
This applies only for a socket with the MACRAW or UDP protocol.
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.bcastb_enabled());
let sn_mr: SocketMode = sn_mr.enable_bcastb();
assert!(sn_mr.bcastb_enabled());
let sn_mr: SocketMode = sn_mr.disable_bcastb();
assert!(!sn_mr.bcastb_enabled());
Enable broadcast blocking.
Disable broadcast blocking.
Use no delayed ACK.
This applies only for a socket with the TCP protocol.
When enabled the ACK packet is sent without delay as soon as a data
packet is received from a peer.
When disabled the ACK packet is sent after waiting for the time
configured by rtr
.
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.nd_enabled());
let sn_mr: SocketMode = sn_mr.enable_nd();
assert!(sn_mr.nd_enabled());
let sn_mr: SocketMode = sn_mr.disable_nd();
assert!(!sn_mr.nd_enabled());
Disable no delayed ACK.
Multicast IGMP version.
This applies only for a socket with the UDP protocol.
This field configures the version for IGMP messages (join/leave/report).
false
IGMP version 2true
IGMP version 1
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mc());
let sn_mr: SocketMode = sn_mr.set_igmp_v1();
assert!(sn_mr.mc());
let sn_mr: SocketMode = sn_mr.set_igmp_v2();
assert!(!sn_mr.mc());
Set IGMP version 1.
Set IGMP version 2.
Multicast blocking.
This applies only for a socket with the MACRAW protocol.
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mmb_enabled());
let sn_mr: SocketMode = sn_mr.enable_mmb();
assert!(sn_mr.mmb_enabled());
let sn_mr: SocketMode = sn_mr.disable_mmb();
assert!(!sn_mr.mmb_enabled());
Enable multicast blocking.
Disable multicast blocking.
Unicast blocking enabled.
This applies only for a socket with the UDP protocol.
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.ucastb_enabled());
let sn_mr: SocketMode = sn_mr.enable_ucastb();
assert!(sn_mr.ucastb_enabled());
let sn_mr: SocketMode = sn_mr.disable_ucastb();
assert!(!sn_mr.ucastb_enabled());
Enable unicast blocking.
Disable unicast blocking.
IPV6 packet blocking.
This applies only for a socket with the MACRAW protocol.
Example
use w5500_ll::SocketMode;
let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mip6b_enabled());
let sn_mr: SocketMode = sn_mr.enable_mip6b();
assert!(sn_mr.mip6b_enabled());
let sn_mr: SocketMode = sn_mr.disable_mip6b();
assert!(!sn_mr.mip6b_enabled());
Enable IPV6 packet blocking.
Disable IPV6 packet blocking.
Trait Implementations
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for SocketMode
impl Send for SocketMode
impl Sync for SocketMode
impl Unpin for SocketMode
impl UnwindSafe for SocketMode
Blanket Implementations
Mutably borrows from an owned value. Read more