mqttsn_client.h File Reference

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  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   5000
 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.
 

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, const char *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, const char *topicName)
 Callback function type describing a function that is called when a topic is successfully registered by the gateway.
 
typedef void(* MQTTSNOnPublishReceived) (struct MQTTSNClient *client, MQTTSNTopicId topicId, const void *data, size_t dataSize)
 Callback function type describing a function that is called when a message is received on a topic.
 
typedef struct MQTTSNTopicDescriptor MQTTSNTopicDescriptor
 Structure describing a single MQTT-SN topic.
 
typedef struct MQTTSNClient MQTTSNClient
 Structure describing the MQTT-SN Client.
 

Enumerations

enum  MQTTSNClientState {
  MQTTSN_CLIENT_STATE_DISCONNECTED , MQTTSN_CLIENT_STATE_CONNECTING , MQTTSN_CLIENT_STATE_AWAITING_WILL_TOPIC_REQ , MQTTSN_CLIENT_STATE_AWAITING_WILL_MSG_REQ ,
  MQTTSN_CLIENT_STATE_CONNECTED , MQTTSN_CLIENT_STATE_DISCONNECTING
}
 Possible states of the MQTT-SN client. More...
 
enum  MQTTSNClientResult {
  MQTTSN_CLIENT_RESULT_OK = 0 , MQTTSN_CLIENT_RESULT_INVALID_INPUT_ARGUMENT , MQTTSN_CLIENT_RESULT_FAILED_TO_REGISTER_UDP_SOCKET , MQTTSN_CLIENT_RESULT_FAILED_TO_CREATE_TASK ,
  MQTTSN_CLIENT_RESULT_FAILED_TO_SEND_PACKET , MQTTSN_CLIENT_RESULT_CONNECT_SERIALIZATION_ERR , MQTTSN_CLIENT_RESULT_BUFFER_OR_CLIENT_IS_NULL , MQTTSN_CLIENT_CLIENTID_FORBIDDEN_LENGTH ,
  MQTTSN_CLIENT_UNEXPECTED_ACK_RECEIVED , MQTTSN_CLIENT_TOPIC_NOT_IN_REGISTRATION , MQTTSN_CLIENT_REGACK_DESERIALIZATION_FAILED , MQTTSN_CLIENT_PUBLISH_DESERIALIZATION_FAILED ,
  MQTTSN_CLIENT_SUBACK_DESERIALIZATION_FAILED , MQTTSN_CLIENT_GW_ERR_CONGESTION , MQTTSN_CLIENT_GW_INVALID_TOPIC_ID , MQTTSN_CLIENT_GW_ERR_NOT_SUPPORTED ,
  MQTTSN_CLIENT_UNKNOWN_ERROR , MQTTSN_CLIENT_WILL_TOPIC_SERIALIZATION_ERROR , MQTTSN_CLIENT_UNEXPECTED_WILL_TOPIC_REQ_RECEIVED , MQTTSN_CLIENT_UNEXPECTED_WILL_MSG_REQ_RECEIVED ,
  MQTTSN_CLIENT_WILL_MSG_SERIALIZATION_ERROR , MQTTSN_CLIENT_PING_SERIALIZATION_ERROR , MQTTSN_CLIENT_TXTOPICS_BUFFER_FULL , MQTTSN_CLIENT_REGISTER_SERIALIZATION_ERROR ,
  MQTTSN_CLIENT_PUBLISH_SERIALIZATION_ERROR , MQTTSN_CLIENT_TOPIC_NOT_REGISTERED , MQTTSN_CLIENT_SUBSCRIBE_SERIALIZATION_ERROR , MQTTSN_CLIENT_RECEIVED_BROKEN_PACKET ,
  MQTTSN_CLIENT_CLIENT_NOT_CONNECTED , MQTTSN_CLIENT_CLIENT_NOT_DISCONNECTED , MQTTSN_CLIENT_DISCONNECT_SERIALIZATION_ERROR , MQTTSN_CLIENT_RESULT_TOPIC_NOT_FOUND ,
  MQTTSN_CLIENT_RESULT_TOPIC_NOT_PENDING_REGISTRATION , MQTTSN_CLIENT_RESULT_DISCONNECT_SERIALIZATION_ERROR , MQTTSN_CLIENT_SUBSCRIBE_BUFFER_FULL , MQTTSN_CLIENT_TOPIC_EXCEEDS_SET_MAX_LEN
}
 Possible results of the MQTT-SN client API calls. More...
 

Functions

MQTTSNClientResult MQTTSN_CLIENT_Init (MQTTSNClient *client, uint16_t port, const char *clientId, const MQTTSNClientEventHandlers *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, const char *willTopic, const uint8_t *willMsg)
 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, const char *willTopic, const uint8_t *willMsg)
 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, const char *topic, MQTTSNOnTopicRegisteredByClient onTopicRegisteredCallback)
 Registers a topic in the gateway.
 
MQTTSNTopicId MQTTSN_CLIENT_GetTopicId (MQTTSNClient *client, const char *topic)
 Gets the id of the registered topic.
 
MQTTSNClientResult MQTTSN_CLIENT_PublishMessage (MQTTSNClient *client, const char *topic, const char *message, size_t messageLen)
 Publishes a message on a topic given the topic string.
 
MQTTSNClientResult MQTTSN_CLIENT_PublishMessageById (MQTTSNClient *client, MQTTSNTopicId topicId, const char *message, size_t messageLen)
 Publishes a message on a topic given the topic id.
 
MQTTSNClientResult MQTTSN_CLIENT_Subscribe (MQTTSNClient *client, const char *topic, MQTTSNOnPublishReceived onPublishReceivedCallback)
 Subscribes to the topic.
 

Detailed Description

MQTT-SN client API declaration.

License: $License$
Version
$Revision$
Purpose: embeNET MQTT-SN client

This implementation of MQTT-SN client is based on the MQTT-SN specification version 1.2.

Go to Top