pub struct RawMqttClient<'a, T, const MAX_PROPERTIES: usize, R: RngCore>{ /* private fields */ }
Implementations§
Source§impl<'a, T, const MAX_PROPERTIES: usize, R> RawMqttClient<'a, T, MAX_PROPERTIES, R>
impl<'a, T, const MAX_PROPERTIES: usize, R> RawMqttClient<'a, T, MAX_PROPERTIES, R>
pub fn new( network_driver: T, buffer: &'a mut [u8], buffer_len: usize, recv_buffer: &'a mut [u8], recv_buffer_len: usize, config: ClientConfig<'a, MAX_PROPERTIES, R>, ) -> Self
Sourcepub async fn connect_to_broker<'b>(&'b mut self) -> Result<(), ReasonCode>
pub async fn connect_to_broker<'b>(&'b mut self) -> Result<(), ReasonCode>
Method allows client connect to server. Client is connecting to the specified broker
in the ClientConfig
. Method selects proper implementation of the MQTT version based on the config.
If the connection to the broker fails, method returns Err variable that contains
Reason codes returned from the broker.
Sourcepub async fn disconnect<'b>(&'b mut self) -> Result<(), ReasonCode>
pub async fn disconnect<'b>(&'b mut self) -> Result<(), ReasonCode>
Method allows client disconnect from the server. Client disconnects from the specified broker
in the ClientConfig
. Method selects proper implementation of the MQTT version based on the config.
If the disconnect from the broker fails, method returns Err variable that contains
Reason codes returned from the broker.
Sourcepub async fn send_message<'b>(
&'b mut self,
topic_name: &'b str,
message: &'b [u8],
qos: QualityOfService,
retain: bool,
) -> Result<u16, ReasonCode>
pub async fn send_message<'b>( &'b mut self, topic_name: &'b str, message: &'b [u8], qos: QualityOfService, retain: bool, ) -> Result<u16, ReasonCode>
Method allows sending message to broker specified from the ClientConfig. Client sends the
message from the parameter message
to the topic topic_name
on the broker
specified in the ClientConfig. If the send fails method returns Err with reason code
received by broker.
Sourcepub async fn subscribe_to_topics<'b, const TOPICS: usize>(
&'b mut self,
topic_names: &'b Vec<&'b str, TOPICS>,
) -> Result<u16, ReasonCode>
pub async fn subscribe_to_topics<'b, const TOPICS: usize>( &'b mut self, topic_names: &'b Vec<&'b str, TOPICS>, ) -> Result<u16, ReasonCode>
Method allows client subscribe to multiple topics specified in the parameter
topic_names
on the broker specified in the ClientConfig
. Generics TOPICS
sets the value of the topics_names
vector. MQTT protocol implementation
is selected automatically.
Sourcepub async fn unsubscribe_from_topic<'b>(
&'b mut self,
topic_name: &'b str,
) -> Result<u16, ReasonCode>
pub async fn unsubscribe_from_topic<'b>( &'b mut self, topic_name: &'b str, ) -> Result<u16, ReasonCode>
Method allows client unsubscribe from the topic specified in the parameter
topic_name
on the broker from the ClientConfig
. MQTT protocol implementation
is selected automatically.
Sourcepub async fn send_ping<'b>(&'b mut self) -> Result<(), ReasonCode>
pub async fn send_ping<'b>(&'b mut self) -> Result<(), ReasonCode>
Method allows client send PING message to the broker specified in the ClientConfig
.
If there is expectation for long running connection. Method should be executed
regularly by the timer that counts down the session expiry interval.