Struct Client

Source
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>

Source

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 typically SRC_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 },
);
Source

pub fn set_client_id(&mut self, client_id: ClientId<'id>)

Set the MQTT client ID.

Source

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.

Source

pub fn is_connected(&self) -> bool

Returns true if the MQTT client is connected.

Source

pub fn publish<W5500: Registers>( &mut self, w5500: &mut W5500, topic: &str, payload: &[u8], ) -> Result<(), Error<W5500::Error>>

Publish data to the MQTT broker.

Source

pub fn subscribe<W5500: Registers>( &mut self, w5500: &mut W5500, filter: &str, ) -> Result<u16, Error<W5500::Error>>

Subscribe to a topic.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.