Zephyr Project API
3.3.0
A Scalable Open Source RTOS
|
MQTT-SN Client Implementation. More...
Data Structures | |
struct | mqtt_sn_data |
Abstracts memory buffers. More... | |
union | mqtt_sn_evt_param |
struct | mqtt_sn_evt |
struct | mqtt_sn_transport |
Structure to describe an MQTT-SN transport. More... | |
struct | mqtt_sn_client |
Macros | |
#define | MQTT_SN_DATA_STRING_LITERAL(literal) ((struct mqtt_sn_data){literal, sizeof(literal) - 1}) |
Initialize memory buffer from C literal string. More... | |
#define | MQTT_SN_DATA_BYTES(...) ((struct mqtt_sn_data) { (uint8_t[]){ __VA_ARGS__ }, sizeof((uint8_t[]){ __VA_ARGS__ })}) |
Initialize memory buffer from single bytes. More... | |
Typedefs | |
typedef void(* | mqtt_sn_evt_cb_t) (struct mqtt_sn_client *client, const struct mqtt_sn_evt *evt) |
Asynchronous event notification callback registered by the application. More... | |
Enumerations | |
enum | mqtt_sn_qos { MQTT_SN_QOS_0 , MQTT_SN_QOS_1 , MQTT_SN_QOS_2 , MQTT_SN_QOS_M1 } |
enum | mqtt_sn_topic_type { MQTT_SN_TOPIC_TYPE_NORMAL , MQTT_SN_TOPIC_TYPE_PREDEF , MQTT_SN_TOPIC_TYPE_SHORT } |
enum | mqtt_sn_return_code { MQTT_SN_CODE_ACCEPTED = 0x00 , MQTT_SN_CODE_REJECTED_CONGESTION = 0x01 , MQTT_SN_CODE_REJECTED_TOPIC_ID = 0x02 , MQTT_SN_CODE_REJECTED_NOTSUP = 0x03 } |
enum | mqtt_sn_evt_type { MQTT_SN_EVT_CONNECTED , MQTT_SN_EVT_DISCONNECTED , MQTT_SN_EVT_ASLEEP , MQTT_SN_EVT_AWAKE , MQTT_SN_EVT_PUBLISH , MQTT_SN_EVT_PINGRESP } |
Functions | |
int | mqtt_sn_client_init (struct mqtt_sn_client *client, const struct mqtt_sn_data *client_id, struct mqtt_sn_transport *transport, mqtt_sn_evt_cb_t evt_cb, void *tx, size_t txsz, void *rx, size_t rxsz) |
Initialize a client. More... | |
void | mqtt_sn_client_deinit (struct mqtt_sn_client *client) |
Deinitialize the client. More... | |
int | mqtt_sn_connect (struct mqtt_sn_client *client, bool will, bool clean_session) |
Connect the client. More... | |
int | mqtt_sn_disconnect (struct mqtt_sn_client *client) |
Disconnect the client. More... | |
int | mqtt_sn_sleep (struct mqtt_sn_client *client, uint16_t duration) |
Set the client into sleep state for the given duration (seconds). More... | |
int | mqtt_sn_subscribe (struct mqtt_sn_client *client, enum mqtt_sn_qos qos, struct mqtt_sn_data *topic_name) |
Subscribe to a given topic. More... | |
int | mqtt_sn_unsubscribe (struct mqtt_sn_client *client, enum mqtt_sn_qos qos, struct mqtt_sn_data *topic_name) |
Unsubscribe from a topic. More... | |
int | mqtt_sn_publish (struct mqtt_sn_client *client, enum mqtt_sn_qos qos, struct mqtt_sn_data *topic_name, bool retain, struct mqtt_sn_data *data) |
Publish a value. More... | |
int | mqtt_sn_input (struct mqtt_sn_client *client) |
Check the transport for new incoming data. More... | |
MQTT-SN Client Implementation.
MQTT-SN Client's Application interface is defined in this header. Targets protocol version 1.2.
#define MQTT_SN_DATA_BYTES | ( | ... | ) | ((struct mqtt_sn_data) { (uint8_t[]){ __VA_ARGS__ }, sizeof((uint8_t[]){ __VA_ARGS__ })}) |
#include <include/zephyr/net/mqtt_sn.h>
Initialize memory buffer from single bytes.
Use it as follows:
struct mqtt_sn_data data = MQTT_SN_DATA_BYTES(0x13, 0x37);
#define MQTT_SN_DATA_STRING_LITERAL | ( | literal | ) | ((struct mqtt_sn_data){literal, sizeof(literal) - 1}) |
#include <include/zephyr/net/mqtt_sn.h>
Initialize memory buffer from C literal string.
Use it as follows:
struct mqtt_sn_data topic = MQTT_SN_DATA_STRING_LITERAL("/zephyr");
[in] | literal | Literal string from which to generate mqtt_sn_data object. |
typedef void(* mqtt_sn_evt_cb_t) (struct mqtt_sn_client *client, const struct mqtt_sn_evt *evt) |
#include <include/zephyr/net/mqtt_sn.h>
Asynchronous event notification callback registered by the application.
[in] | client | Identifies the client for which the event is notified. |
[in] | evt | Event description along with result and associated parameters (if any). |
enum mqtt_sn_evt_type |
#include <include/zephyr/net/mqtt_sn.h>
Event types that can be emitted by the library.
enum mqtt_sn_qos |
#include <include/zephyr/net/mqtt_sn.h>
Quality of Service. QoS 0-2 work the same as basic MQTT, QoS -1 is an MQTT-SN addition. QOS -1 is not supported yet.
Enumerator | |
---|---|
MQTT_SN_QOS_0 | QOS 0 |
MQTT_SN_QOS_1 | QOS 1 |
MQTT_SN_QOS_2 | QOS 2 |
MQTT_SN_QOS_M1 | QOS -1 |
enum mqtt_sn_return_code |
#include <include/zephyr/net/mqtt_sn.h>
enum mqtt_sn_topic_type |
#include <include/zephyr/net/mqtt_sn.h>
MQTT-SN topic types.
Enumerator | |
---|---|
MQTT_SN_TOPIC_TYPE_NORMAL | |
MQTT_SN_TOPIC_TYPE_PREDEF | |
MQTT_SN_TOPIC_TYPE_SHORT |
void mqtt_sn_client_deinit | ( | struct mqtt_sn_client * | client | ) |
#include <include/zephyr/net/mqtt_sn.h>
Deinitialize the client.
This removes all topics and publishes, and also deinits the transport.
int mqtt_sn_client_init | ( | struct mqtt_sn_client * | client, |
const struct mqtt_sn_data * | client_id, | ||
struct mqtt_sn_transport * | transport, | ||
mqtt_sn_evt_cb_t | evt_cb, | ||
void * | tx, | ||
size_t | txsz, | ||
void * | rx, | ||
size_t | rxsz | ||
) |
#include <include/zephyr/net/mqtt_sn.h>
Initialize a client.
int mqtt_sn_connect | ( | struct mqtt_sn_client * | client, |
bool | will, | ||
bool | clean_session | ||
) |
#include <include/zephyr/net/mqtt_sn.h>
Connect the client.
int mqtt_sn_disconnect | ( | struct mqtt_sn_client * | client | ) |
#include <include/zephyr/net/mqtt_sn.h>
Disconnect the client.
int mqtt_sn_input | ( | struct mqtt_sn_client * | client | ) |
#include <include/zephyr/net/mqtt_sn.h>
Check the transport for new incoming data.
Call this function periodically, or if you have good reason to believe there is any data. If the client's transport struct contains a poll-function, this function is non-blocking.
int mqtt_sn_publish | ( | struct mqtt_sn_client * | client, |
enum mqtt_sn_qos | qos, | ||
struct mqtt_sn_data * | topic_name, | ||
bool | retain, | ||
struct mqtt_sn_data * | data | ||
) |
#include <include/zephyr/net/mqtt_sn.h>
Publish a value.
If the topic is not yet registered with the gateway, the library takes care of it.
int mqtt_sn_sleep | ( | struct mqtt_sn_client * | client, |
uint16_t | duration | ||
) |
#include <include/zephyr/net/mqtt_sn.h>
Set the client into sleep state for the given duration (seconds).
int mqtt_sn_subscribe | ( | struct mqtt_sn_client * | client, |
enum mqtt_sn_qos | qos, | ||
struct mqtt_sn_data * | topic_name | ||
) |
#include <include/zephyr/net/mqtt_sn.h>
Subscribe to a given topic.
int mqtt_sn_unsubscribe | ( | struct mqtt_sn_client * | client, |
enum mqtt_sn_qos | qos, | ||
struct mqtt_sn_data * | topic_name | ||
) |
#include <include/zephyr/net/mqtt_sn.h>
Unsubscribe from a topic.