Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mqtt_sn_transport Struct Reference

Structure to describe an MQTT-SN transport. More...

#include <mqtt_sn.h>

Data Fields

int(* init )(struct mqtt_sn_transport *transport)
 Will be called once on client init to initialize the transport.
 
void(* deinit )(struct mqtt_sn_transport *transport)
 Will be called on client deinit.
 
int(* sendto )(struct mqtt_sn_client *client, void *buf, size_t sz, const void *dest_addr, size_t addrlen)
 Will be called by the library when it wants to send a message.
 
ssize_t(* recvfrom )(struct mqtt_sn_client *client, void *rx_buf, size_t rx_len, void *src_addr, size_t *addrlen)
 Will be called by the library when it wants to receive a message.
 
int(* poll )(struct mqtt_sn_client *client)
 Check if incoming data is available.
 

Detailed Description

Structure to describe an MQTT-SN transport.

MQTT-SN does not require transports to be reliable or to hold a connection. Transports just need to be frame-based, so you can use UDP, ZigBee, or even a simple UART, given some kind of framing protocol is used.

Field Documentation

◆ deinit

void(* mqtt_sn_transport::deinit) (struct mqtt_sn_transport *transport)

Will be called on client deinit.

Use this to close sockets or similar. May be NULL.

◆ init

int(* mqtt_sn_transport::init) (struct mqtt_sn_transport *transport)

Will be called once on client init to initialize the transport.

Use this to open sockets or similar. May be NULL.

◆ poll

int(* mqtt_sn_transport::poll) (struct mqtt_sn_client *client)

Check if incoming data is available.

If poll() returns a positive number, recv must not block.

May be NULL, but recv should not block then either.

Returns
Positive number if data is available, or zero if there is none. Negative values signal errors.

◆ recvfrom

ssize_t(* mqtt_sn_transport::recvfrom) (struct mqtt_sn_client *client, void *rx_buf, size_t rx_len, void *src_addr, size_t *addrlen)

Will be called by the library when it wants to receive a message.

Implementations should follow recvfrom conventions with the exception of a NULL src_addr being a broadcast message.

◆ sendto

int(* mqtt_sn_transport::sendto) (struct mqtt_sn_client *client, void *buf, size_t sz, const void *dest_addr, size_t addrlen)

Will be called by the library when it wants to send a message.

Implementations should follow sendto conventions with exceptions. When dest_addr == NULL, message should be broadcast with addrlen being the broadcast radius. This should also handle setting up/destroying connections as required when the address changes.

Returns
ENOERR on connection+transmission success, Negative values signal errors.

The documentation for this struct was generated from the following file: