XU XUv0.13.1
中文

#embedded/mqtt

import: #embedded/mqtt

counts: 1 functions, 8 methods, 2 types, 2 constants, 0 method sets

Standard library package `#embedded/mqtt`.

struct Message

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub const MAX_PACKET = 2048

Purpose

Constant MAX_PACKET, defining protocol or algorithm parameters.

const MAX_PAYLOAD

XuAPI
pub const MAX_PAYLOAD = 768

Purpose

Constant MAX_PAYLOAD, defining protocol or algorithm parameters.