mikroSDK Reference Manual
mqtt_sn_message.h
Go to the documentation of this file.
1
31#ifndef _MQTT_SN_MESSAGE_H
32#define _MQTT_SN_MESSAGE_H
33
34//Dependencies
35#include "core/net.h"
37
38//Maximum size of MQTT-SN messages
39#ifndef MQTT_SN_MAX_MSG_SIZE
40 #define MQTT_SN_MAX_MSG_SIZE 1024
41#elif (MQTT_SN_MAX_MSG_SIZE < 16)
42 #error MQTT_SN_MAX_MSG_SIZE parameter is not valid
43#endif
44
45//C++ guard
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50
55typedef struct
56{
57 uint8_t buffer[MQTT_SN_MAX_MSG_SIZE + 1];
58 size_t length;
59 size_t pos;
61
62
63//MQTT-SN related functions
64error_t mqttSnFormatHeader(MqttSnMessage *message, MqttSnMsgType type,
65 size_t length);
66
67error_t mqttSnFormatSearchGw(MqttSnMessage *message,
68 uint8_t radius);
69
70error_t mqttSnFormatConnect(MqttSnMessage *message, MqttSnFlags flags,
71 uint16_t duration, const char_t *clientId);
72
73error_t mqttSnFormatWillTopic(MqttSnMessage *message, MqttSnFlags flags,
74 const char_t *topicName);
75
76error_t mqttSnFormatWillMsg(MqttSnMessage *message, const void *data,
77 size_t dataLen);
78
79error_t mqttSnFormatRegister(MqttSnMessage *message,
80 uint16_t msgId, uint16_t topicId, const char_t *topicName);
81
82error_t mqttSnFormatRegAck(MqttSnMessage *message, uint16_t msgId,
83 uint16_t topicId, MqttSnReturnCode returnCode);
84
85error_t mqttSnFormatPublish(MqttSnMessage *message, MqttSnFlags flags,
86 uint16_t msgId, uint16_t topicId, const char_t *topicName,
87 const uint8_t *data, size_t dataLen);
88
89error_t mqttSnFormatPubAck(MqttSnMessage *message, uint16_t msgId,
90 uint16_t topicId, MqttSnReturnCode returnCode);
91
92error_t mqttSnFormatPubRec(MqttSnMessage *message, uint16_t msgId);
93error_t mqttSnFormatPubRel(MqttSnMessage *message, uint16_t msgId);
94error_t mqttSnFormatPubComp(MqttSnMessage *message, uint16_t msgId);
95
96error_t mqttSnFormatSubscribe(MqttSnMessage *message, MqttSnFlags flags,
97 uint16_t msgId, uint16_t topicId, const char_t *topicName);
98
99error_t mqttSnFormatUnsubscribe(MqttSnMessage *message, MqttSnFlags flags,
100 uint16_t msgId, uint16_t topicId, const char_t *topicName);
101
102error_t mqttSnFormatPingReq(MqttSnMessage *message, const char_t *clientId);
103error_t mqttSnFormatPingResp(MqttSnMessage *message);
104
105error_t mqttSnFormatDisconnect(MqttSnMessage *message,
106 uint16_t duration);
107
108error_t mqttSnFormatWillTopicUpd(MqttSnMessage *message, MqttSnFlags flags,
109 const char_t *topicName);
110
111error_t mqttSnFormatWillMsgUpd(MqttSnMessage *message, const void *data,
112 size_t dataLen);
113
114error_t mqttSnParseHeader(MqttSnMessage *message, MqttSnMsgType *type);
115
116error_t mqttSnParseGwInfo(const MqttSnMessage *message, uint8_t *gwId,
117 const uint8_t **gwAdd, size_t *gwAddLen);
118
119error_t mqttSnParseConnAck(const MqttSnMessage *message,
120 MqttSnReturnCode *returnCode);
121
122error_t mqttSnParseWillTopicReq(const MqttSnMessage *message);
123error_t mqttSnParseWillMsgReq(const MqttSnMessage *message);
124
125error_t mqttSnParseRegister(const MqttSnMessage *message, uint16_t *msgId,
126 uint16_t *topicId, const char_t **topicName);
127
128error_t mqttSnParseRegAck(const MqttSnMessage *message, uint16_t *msgId,
129 uint16_t *topicId, MqttSnReturnCode *returnCode);
130
131error_t mqttSnParsePublish(const MqttSnMessage *message, MqttSnFlags *flags,
132 uint16_t *msgId, uint16_t *topicId, const uint8_t **data, size_t *dataLen);
133
134error_t mqttSnParsePubAck(const MqttSnMessage *message, uint16_t *msgId,
135 uint16_t *topicId, MqttSnReturnCode *returnCode);
136
137error_t mqttSnParsePubRec(const MqttSnMessage *message, uint16_t *msgId);
138error_t mqttSnParsePubRel(const MqttSnMessage *message, uint16_t *msgId);
139error_t mqttSnParsePubComp(const MqttSnMessage *message, uint16_t *msgId);
140
141error_t mqttSnParseSubAck(const MqttSnMessage *message, MqttSnFlags *flags,
142 uint16_t *msgId, uint16_t *topicId, MqttSnReturnCode *returnCode);
143
144error_t mqttSnParseUnsubAck(const MqttSnMessage *message, uint16_t *msgId);
145
146error_t mqttSnParsePingReq(const MqttSnMessage *message,
147 const char_t **clientId);
148
149error_t mqttSnParsePingResp(const MqttSnMessage *message);
150
151error_t mqttSnParseDisconnect(const MqttSnMessage *message,
152 uint16_t *duration);
153
154error_t mqttSnParseWillTopicResp(const MqttSnMessage *message,
155 MqttSnReturnCode *returnCode);
156
157error_t mqttSnParseWillMsgResp(const MqttSnMessage *message,
158 MqttSnReturnCode *returnCode);
159
160//C++ guard
161#ifdef __cplusplus
162}
163#endif
164
165#endif
error_t
Error codes.
Definition error.h:43
Definitions common to MQTT-SN client and gateway.
MqttSnMsgType
MQTT-SN message types.
Definition mqtt_sn_common.h:92
MqttSnReturnCode
MQTT-SN return codes.
Definition mqtt_sn_common.h:129
TCP/IP stack core.
MQTT-SN message.
Definition mqtt_sn_message.h:56