Struct w5500_ll::SocketMode
source · pub struct SocketMode(/* private fields */);
Expand description
Socket Mode Register (Sn_MR).
This is used by the Registers::sn_mr
and
Registers::set_sn_mr
methods.
Implementations§
source§impl SocketMode
impl SocketMode
sourcepub const DEFAULT: Self = _
pub const DEFAULT: Self = _
Default value.
This is the same as default
, but as a const
value.
Example
use w5500_ll::SocketMode;
assert_eq!(SocketMode::DEFAULT, SocketMode::default());
sourcepub const MULTI_OFFSET: u8 = 7u8
pub const MULTI_OFFSET: u8 = 7u8
Bit offset for the MULTI
field.
sourcepub const MFEN_OFFSET: u8 = 7u8
pub const MFEN_OFFSET: u8 = 7u8
Bit offset for the MFEN
field.
sourcepub const BCASTB_OFFSET: u8 = 6u8
pub const BCASTB_OFFSET: u8 = 6u8
Bit offset for the BCASTB
field.
sourcepub const MMB_OFFSET: u8 = 5u8
pub const MMB_OFFSET: u8 = 5u8
Bit offset for the MMB
field.
sourcepub const UCASTB_OFFSET: u8 = 4u8
pub const UCASTB_OFFSET: u8 = 4u8
Bit offset for the UCASTB
field.
sourcepub const MIP6B_OFFSET: u8 = 4u8
pub const MIP6B_OFFSET: u8 = 4u8
Bit offset for the MIP6B
field.
sourcepub const MULTI_MASK: u8 = 128u8
pub const MULTI_MASK: u8 = 128u8
Bit mask for the MULTI
field.
sourcepub const BCASTB_MASK: u8 = 64u8
pub const BCASTB_MASK: u8 = 64u8
Bit mask for the BCASTB
field.
sourcepub const UCASTB_MASK: u8 = 16u8
pub const UCASTB_MASK: u8 = 16u8
Bit mask for the UCASTB
field.
sourcepub const MIP6B_MASK: u8 = 16u8
pub const MIP6B_MASK: u8 = 16u8
Bit mask for the MIP6B
field.
sourcepub const PROTOCOL_MASK: u8 = 15u8
pub const PROTOCOL_MASK: u8 = 15u8
Bit mask for the PROTOCOL
field.
sourcepub const fn protocol(&self) -> Result<Protocol, u8>
pub const fn protocol(&self) -> Result<Protocol, u8>
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));
sourcepub const fn set_protocol(self, protocol: Protocol) -> Self
pub const fn set_protocol(self, protocol: Protocol) -> Self
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));
sourcepub const fn multi_enabled(&self) -> bool
pub const fn multi_enabled(&self) -> bool
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());
sourcepub const fn enable_multi(self) -> Self
pub const fn enable_multi(self) -> Self
Enable multicasting.
sourcepub const fn disable_multi(self) -> Self
pub const fn disable_multi(self) -> Self
Disable multicasting.
sourcepub const fn mfen_enabled(&self) -> bool
pub const fn mfen_enabled(&self) -> bool
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());
sourcepub const fn enable_mfen(self) -> Self
pub const fn enable_mfen(self) -> Self
Enable MAC filter.
sourcepub const fn disable_mfen(self) -> Self
pub const fn disable_mfen(self) -> Self
Disable MAC filter.
sourcepub const fn bcastb_enabled(&self) -> bool
pub const fn bcastb_enabled(&self) -> bool
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());
sourcepub const fn enable_bcastb(self) -> Self
pub const fn enable_bcastb(self) -> Self
Enable broadcast blocking.
sourcepub const fn disable_bcastb(self) -> Self
pub const fn disable_bcastb(self) -> Self
Disable broadcast blocking.
sourcepub const fn nd_enabled(&self) -> bool
pub const fn nd_enabled(&self) -> bool
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());
sourcepub const fn disable_nd(self) -> Self
pub const fn disable_nd(self) -> Self
Disable no delayed ACK.
sourcepub const fn mc(&self) -> bool
pub const fn mc(&self) -> bool
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());
sourcepub const fn set_igmp_v1(self) -> Self
pub const fn set_igmp_v1(self) -> Self
Set IGMP version 1.
sourcepub const fn set_igmp_v2(self) -> Self
pub const fn set_igmp_v2(self) -> Self
Set IGMP version 2.
sourcepub const fn mmb_enabled(&self) -> bool
pub const fn mmb_enabled(&self) -> bool
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());
sourcepub const fn enable_mmb(self) -> Self
pub const fn enable_mmb(self) -> Self
Enable multicast blocking.
sourcepub const fn disable_mmb(self) -> Self
pub const fn disable_mmb(self) -> Self
Disable multicast blocking.
sourcepub const fn ucastb_enabled(&self) -> bool
pub const fn ucastb_enabled(&self) -> bool
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());
sourcepub const fn enable_ucastb(self) -> Self
pub const fn enable_ucastb(self) -> Self
Enable unicast blocking.
sourcepub const fn disable_ucastb(self) -> Self
pub const fn disable_ucastb(self) -> Self
Disable unicast blocking.
sourcepub const fn mip6b_enabled(&self) -> bool
pub const fn mip6b_enabled(&self) -> bool
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());
sourcepub const fn enable_mip6b(self) -> Self
pub const fn enable_mip6b(self) -> Self
Enable IPV6 packet blocking.
sourcepub const fn disable_mip6b(self) -> Self
pub const fn disable_mip6b(self) -> Self
Disable IPV6 packet blocking.
Trait Implementations§
source§impl Clone for SocketMode
impl Clone for SocketMode
source§fn clone(&self) -> SocketMode
fn clone(&self) -> SocketMode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SocketMode
impl Debug for SocketMode
source§impl Default for SocketMode
impl Default for SocketMode
source§impl Display for SocketMode
impl Display for SocketMode
source§impl Format for SocketMode
Available on crate feature defmt
only.
impl Format for SocketMode
defmt
only.source§impl From<SocketMode> for u8
impl From<SocketMode> for u8
source§fn from(val: SocketMode) -> u8
fn from(val: SocketMode) -> u8
source§impl From<u8> for SocketMode
impl From<u8> for SocketMode
source§impl PartialEq for SocketMode
impl PartialEq for SocketMode
source§fn eq(&self, other: &SocketMode) -> bool
fn eq(&self, other: &SocketMode) -> bool
self
and other
values to be equal, and is used
by ==
.