MQTT-SN client API declaration. More...
Data Structures | |
struct | MQTTSNClientEventHandlers |
Structure grouping event callbacks for MQTT-SN client. More... | |
struct | MQTTSNTopicDescriptor |
Structure describing a single MQTT-SN topic. More... | |
struct | MQTTSNSessionFlags |
MQTT-SN session flags. More... | |
struct | MQTTSNQosMsg |
Structure describing the MQTTSN QOS(1-2) message. More... | |
struct | MQTTSNClient |
Structure describing the MQTT-SN Client. More... | |
Macros | |
#define | MQTTSN_MAX_TOPIC_NAME_LENGTH 38 |
Maximum length of the MQTT-SN topic name. | |
#define | MQTTSN_MAX_MESSAGE_DATA 32 |
Maximum length of the MQTT-SN message data. | |
#define | MQTTSN_MAX_CLIENT_ID_LENGTH 23 |
Maximum length of the MQTT-SN client id. | |
#define | MQTTSN_CLIENT_GATEWAY_RESPONSE_TIMEOUT_MS 10000 |
Gateway response timeout in milliseconds, after which the client assumes the gateway is not responding. | |
#define | MQTTSN_CLIENT_MAX_TOPICS_TO_SUBSCRIBE 10 |
Maximum number of topics that the client can subscribe to. | |
#define | MQTTSN_CLIENT_MAX_TOPICS_TO_PUBLISH 10 |
Maximum number of topics that the client can publish to. | |
#define | MQTTSN_CLIENT_MAX_PINGRESP_LOST 3 |
Maximum number of consecutive PINGRESP messages that can be lost before the client assumes the gateway is not responding. | |
Typedefs | |
typedef uint16_t | MQTTSNTopicId |
Type describing topic id. | |
typedef void(* | MQTTSNOnClientConnected) (struct MQTTSNClient *client) |
Callback function type describing a function that is called when the MQTT-SN client connects to the gateway. | |
typedef void(* | MQTTSNOnClientDisconnected) (struct MQTTSNClient *client) |
Callback function type describing a function that is called when the MQTT-SN client gets disconnected from the gateway. | |
typedef void(* | MQTTSNOnTopicRegisteredByClient) (const struct MQTTSNClient *client, MQTTSNTopicId topicId, char const *topicName) |
Callback function type describing a function that is called when a topic is successfully registered by the client in the gateway. | |
typedef void(* | MQTTSNOnTopicRegisteredByGateway) (struct MQTTSNClient *client, MQTTSNTopicId topicId, char const *topicName) |
Callback function type describing a function that is called when a topic is successfully registered by the gateway. | |
typedef void(* | MQTTSNOnTopicSubscribedByClient) (const struct MQTTSNClient *client, MQTTSNTopicId topicId, char const *topicName) |
Callback function type describing a function that is called when the client successfully subscribes to a topic. | |
typedef void(* | MQTTSNOnTopicUnsubscribedByClient) (const struct MQTTSNClient *client, MQTTSNTopicId topicId, char const *topicName) |
Callback function type describing a function that is called when the client successfully unsubscribes from a topic. | |
typedef void(* | MQTTSNOnPublishReceived) (struct MQTTSNClient *client, MQTTSNTopicId topicId, void const *data, size_t dataSize) |
Callback function type describing a function that is called when a message is received on a topic. | |
typedef void(* | MQTTSNOnPublishSent) (struct MQTTSNClient *client, MQTTSNTopicId topicId, void const *data, size_t dataSize) |
Callback function type describing a function that is called when a message is sent to a topic. | |
typedef struct MQTTSNTopicDescriptor | MQTTSNTopicDescriptor |
Structure describing a single MQTT-SN topic. | |
typedef struct MQTTSNQosMsg | MQTTSNQosMsg |
Structure describing the MQTTSN QOS(1-2) message. | |
typedef struct MQTTSNClient | MQTTSNClient |
Structure describing the MQTT-SN Client. | |
Functions | |
MQTTSNClientResult | MQTTSN_CLIENT_Init (MQTTSNClient *client, uint16_t port, char const *clientId, MQTTSNClientEventHandlers const *eventHandlers) |
Initializes the MQTT-SN client. | |
void | MQTTSN_CLIENT_Deinit (MQTTSNClient *client) |
Deinitializes the MQTT-SN client. | |
MQTTSNClientResult | MQTTSN_CLIENT_Connect (MQTTSNClient *client, EMBENET_IPV6 const *gatewayAddress, uint16_t gatewayPort, uint16_t keepAliveTime, uint16_t pingPeriod, char const *willTopic, uint8_t const *willMsg, uint8_t const qosRetransmissions) |
Makes the client try to connect to a gateway. | |
MQTTSNClientResult | MQTTSN_CLIENT_CleanConnect (MQTTSNClient *client, EMBENET_IPV6 const *gatewayAddress, uint16_t gatewayPort, uint16_t keepAliveTime, uint16_t pingPeriod, char const *willTopic, uint8_t const *willMsg, uint8_t const qosRetransmissions) |
Makes the client try to connect to a gateway using clean connection. | |
MQTTSNClientResult | MQTTSN_CLIENT_Disconnect (MQTTSNClient *client) |
Disconnects the client from the gateway. | |
MQTTSNClientResult | MQTTSN_CLIENT_RegisterTopic (MQTTSNClient *client, char const *topic, MQTTSNOnTopicRegisteredByClient onTopicRegisteredCallback) |
Registers a topic in the gateway. | |
MQTTSNTopicId | MQTTSN_CLIENT_GetTopicId (MQTTSNClient *client, char const *topic) |
Gets the id of the registered topic. | |
MQTTSNClientResult | MQTTSN_CLIENT_PublishMessage (MQTTSNClient *client, char const *topic, MQTTSNPacketQoS qos, char const *message, size_t messageLen, MQTTSNOnPublishSent onPublishSentCallback) |
Publishes a message on a topic given the topic string. | |
MQTTSNClientResult | MQTTSN_CLIENT_PublishMessageById (MQTTSNClient *client, MQTTSNTopicId topicId, MQTTSNPacketQoS qos, char const *message, size_t messageLen, MQTTSNOnPublishSent onPublishSentCallback) |
Publishes a message on a topic given the topic id. | |
MQTTSNClientResult | MQTTSN_CLIENT_Subscribe (MQTTSNClient *client, char const *topic, MQTTSNPacketQoS qos, MQTTSNOnTopicSubscribedByClient onTopicSubscribedByClient, MQTTSNOnPublishReceived onPublishReceivedCallback) |
Subscribes to the topic. | |
MQTTSNClientResult | MQTTSN_CLIENT_Unsubscribe (MQTTSNClient *client, char const *topic, MQTTSNOnTopicUnsubscribedByClient onTopicUnsubscribedByClient) |
Unsubscribes from the topic by a regular topic name via UNSUBSCRIBE packet. Once unsubscribed, the client will no longer receive messages published on the topic. | |
MQTT-SN client API declaration.
This implementation of MQTT-SN client is based on the MQTT-SN specification version 1.2.
Any question or remarks? Just write us a message!
Feel free to get in touch