#embedded/mqtt
Xu 0.13.1 API
import: #embedded/mqtt
counts: 1 functions, 8 methods, 2 types, 2 constants, 0 method sets
Standard library package `#embedded/mqtt`.
struct Message
pub struct Message {
pub valid bool
pub payload string
pub retained bool
}
Purpose
Structure encapsulating valid, payload, retained.
Public fields
valid bool- field (bool)
payload string- field (string)
retained bool- field (bool)
struct Client
pub struct Client {
pub error int
pub received int
pub published int
pub retransmits int
}
Purpose
Mqtt Client session maintaining connection and operations.
Public fields
error int- field (int)
received int- field (int)
published int- field (int)
retransmits int- field (int)
create
pub fn create(id string, command_topic string, will_topic string, now int) Client
Purpose
Create a new file, directory, or resource.
Parameters
id string- id (string)
command_topic string- command_topic (string)
will_topic string- will_topic (string)
now int- now (int)
Returns
Client — a value of this type
(&Client) ready
pub fn (c &Client) ready() bool
Purpose
Execute ready on &Client.
Parameters
c &Client- The
Client instance used by this call (borrow).
Returns
bool — true or false
(&Client) failed
pub fn (c &Client) failed() bool
Purpose
Execute failed on &Client.
Parameters
c &Client- The
Client instance used by this call (borrow).
Returns
bool — true or false
(&Client) can_publish
pub fn (c &Client) can_publish() bool
Purpose
Operation on &Client: can publish.
Parameters
c &Client- The
Client instance used by this call (borrow).
Returns
bool — true or false
($&Client) publish
pub fn (c $&Client) publish(topic &string, payload &string, retain bool) bool
Purpose
Publish message data to the given topic or channel.
Parameters
c $&Client- The
Client instance used by this call (exclusive borrow).
topic &string- topic (read-only borrow; caller keeps the original; type &string)
payload &string- payload (read-only borrow; caller keeps the original; type &string)
retain bool- retain (bool)
Returns
bool — true or false
($&Client) feed
pub fn (c $&Client) feed(bytes &string, now int) bool
Purpose
Execute feed on $&Client.
Parameters
c $&Client- The
Client instance used by this call (exclusive borrow).
bytes &string- bytes (read-only borrow; caller keeps the original; type &string)
now int- now (int)
Returns
bool — true or false
($&Client) read
pub fn (c $&Client) read() Message
Purpose
Operation on $&Client: read up to max bytes.
Parameters
c $&Client- The
Client instance used by this call (exclusive borrow).
Returns
Message — a value of this type
($&Client) poll
pub fn (c $&Client) poll(now int) string
Purpose
Execute poll on $&Client.
Parameters
c $&Client- The
Client instance used by this call (exclusive borrow).
now int- now (int)
Returns
string — result string
($&Client) reset
pub fn (c $&Client) reset(id string, command_topic string, will_topic string, now int)
Purpose
Operation on $&Client: clear internal state so the value can be reused.
Parameters
c $&Client- The
Client instance used by this call (exclusive borrow).
id string- id (string)
command_topic string- command_topic (string)
will_topic string- will_topic (string)
now int- now (int)
Returns
This call does not return a value.
const MAX_PACKET
pub const MAX_PACKET = 2048
Purpose
Constant MAX_PACKET, defining protocol or algorithm parameters.
const MAX_PAYLOAD
pub const MAX_PAYLOAD = 768
Purpose
Constant MAX_PAYLOAD, defining protocol or algorithm parameters.