pub struct Client<'id, 'hn, 'psk, 'b, const N: usize> { /* private fields */ }
Available on crate feature
w5500-tls
only.Expand description
W5500 MQTT client over TLS.
The methods are nearly identical to crate::Client
, see crate::Client
for additional documentation and examples.
Implementations§
Source§impl<'id, 'hn, 'psk, 'b, const N: usize> Client<'id, 'hn, 'psk, 'b, N>
impl<'id, 'hn, 'psk, 'b, const N: usize> Client<'id, 'hn, 'psk, 'b, N>
Sourcepub fn new(
sn: Sn,
src_port: u16,
hostname: Hostname<'hn>,
dst: SocketAddrV4,
identity: &'psk [u8],
psk: &'psk [u8],
rx: &'b mut [u8; N],
) -> Self
pub fn new( sn: Sn, src_port: u16, hostname: Hostname<'hn>, dst: SocketAddrV4, identity: &'psk [u8], psk: &'psk [u8], rx: &'b mut [u8; N], ) -> Self
Create a new MQTT client.
§Arguments
sn
- The socket number to use for MQTT.src_port
- The MQTT source port, this is typicallySRC_PORT
.server
- The IP address and port for the MQTT server.
§Example
use w5500_mqtt::{
hl::Hostname,
ll::{
net::{Ipv4Addr, SocketAddrV4},
Sn,
},
tls::{Client, DST_PORT},
SRC_PORT,
};
static mut RXBUF: [u8; 2048] = [0; 2048];
let client: Client<2048> = Client::new(
Sn::Sn2,
SRC_PORT,
Hostname::new_unwrapped("mqtt.local"),
SocketAddrV4::new(Ipv4Addr::new(192, 168, 5, 6), DST_PORT),
load_identity_from_memory(),
&load_key_from_memory(),
unsafe { &mut RXBUF },
);
Sourcepub fn set_client_id(&mut self, client_id: ClientId<'id>)
pub fn set_client_id(&mut self, client_id: ClientId<'id>)
Set the MQTT client ID.
Sourcepub fn process<'w, 'ptr, W5500: Registers, R: RngCore + CryptoRng>(
&'ptr mut self,
w5500: &'w mut W5500,
rng: &mut R,
monotonic_secs: u32,
) -> Result<Event<Infallible, TlsReader<'b, 'ptr>>, Error<W5500::Error>>
pub fn process<'w, 'ptr, W5500: Registers, R: RngCore + CryptoRng>( &'ptr mut self, w5500: &'w mut W5500, rng: &mut R, monotonic_secs: u32, ) -> Result<Event<Infallible, TlsReader<'b, 'ptr>>, Error<W5500::Error>>
Process the MQTT client.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns true
if the MQTT client is connected.
Sourcepub fn publish<W5500: Registers>(
&mut self,
w5500: &mut W5500,
topic: &str,
payload: &[u8],
) -> Result<(), Error<W5500::Error>>
pub fn publish<W5500: Registers>( &mut self, w5500: &mut W5500, topic: &str, payload: &[u8], ) -> Result<(), Error<W5500::Error>>
Publish data to the MQTT broker.
Sourcepub fn subscribe<W5500: Registers>(
&mut self,
w5500: &mut W5500,
filter: &str,
) -> Result<u16, Error<W5500::Error>>
pub fn subscribe<W5500: Registers>( &mut self, w5500: &mut W5500, filter: &str, ) -> Result<u16, Error<W5500::Error>>
Subscribe to a topic.
Sourcepub fn unsubscribe<W5500: Registers>(
&mut self,
w5500: &mut W5500,
filter: &str,
) -> Result<u16, Error<W5500::Error>>
pub fn unsubscribe<W5500: Registers>( &mut self, w5500: &mut W5500, filter: &str, ) -> Result<u16, Error<W5500::Error>>
Unsubscribe from a topic.
Auto Trait Implementations§
impl<'id, 'hn, 'psk, 'b, const N: usize> Freeze for Client<'id, 'hn, 'psk, 'b, N>
impl<'id, 'hn, 'psk, 'b, const N: usize> RefUnwindSafe for Client<'id, 'hn, 'psk, 'b, N>
impl<'id, 'hn, 'psk, 'b, const N: usize> Send for Client<'id, 'hn, 'psk, 'b, N>
impl<'id, 'hn, 'psk, 'b, const N: usize> Sync for Client<'id, 'hn, 'psk, 'b, N>
impl<'id, 'hn, 'psk, 'b, const N: usize> Unpin for Client<'id, 'hn, 'psk, 'b, N>
impl<'id, 'hn, 'psk, 'b, const N: usize> !UnwindSafe for Client<'id, 'hn, 'psk, 'b, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more