MQTT-SN message formatting and parsing. More...
#include "core/net.h"
#include "mqtt_sn/mqtt_sn_client.h"
#include "mqtt_sn/mqtt_sn_message.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL MQTT_SN_TRACE_LEVEL |
Detailed Description
MQTT-SN message formatting and parsing.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file mqtt_sn_message.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL MQTT_SN_TRACE_LEVEL |
Definition at line 32 of file mqtt_sn_message.c.
Function Documentation
◆ mqttSnFormatConnect()
error_t mqttSnFormatConnect | ( | MqttSnMessage * | message, |
MqttSnFlags | flags, | ||
uint16_t | duration, | ||
const char_t * | clientId | ||
) |
Format CONNECT message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] flags Flags [in] duration Value of the keep-alive timer [in] clientId Client identifier
- Returns
- Error code
Definition at line 145 of file mqtt_sn_message.c.
◆ mqttSnFormatDisconnect()
error_t mqttSnFormatDisconnect | ( | MqttSnMessage * | message, |
uint16_t | duration | ||
) |
Format DISCONNECT message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] duration Value of the sleep timer
- Returns
- Error code
Definition at line 705 of file mqtt_sn_message.c.
◆ mqttSnFormatHeader()
error_t mqttSnFormatHeader | ( | MqttSnMessage * | message, |
MqttSnMsgType | type, | ||
size_t | length | ||
) |
Format MQTT-SN message header.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] type Message type [in] length Length of the message, in bytes
- Returns
- Error code
Definition at line 52 of file mqtt_sn_message.c.
◆ mqttSnFormatPingReq()
error_t mqttSnFormatPingReq | ( | MqttSnMessage * | message, |
const char_t * | clientId | ||
) |
Format PINGREQ message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] clientId Client identifier
- Returns
- Error code
Definition at line 661 of file mqtt_sn_message.c.
◆ mqttSnFormatPingResp()
error_t mqttSnFormatPingResp | ( | MqttSnMessage * | message | ) |
Format PINGRESP message.
- Parameters
-
[in] message Pointer to the MQTT-SN message
- Returns
- Error code
Definition at line 686 of file mqtt_sn_message.c.
◆ mqttSnFormatPubAck()
error_t mqttSnFormatPubAck | ( | MqttSnMessage * | message, |
uint16_t | msgId, | ||
uint16_t | topicId, | ||
MqttSnReturnCode | returnCode | ||
) |
Format PUBACK message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] msgId Message identifier of the corresponding PUBLISH message [in] topicId Topic identifier [in] returnCode Return code
- Returns
- Error code
Definition at line 384 of file mqtt_sn_message.c.
◆ mqttSnFormatPubComp()
error_t mqttSnFormatPubComp | ( | MqttSnMessage * | message, |
uint16_t | msgId | ||
) |
Format PUBCOMP message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] msgId Message identifier of the corresponding PUBLISH message
- Returns
- Error code
Definition at line 465 of file mqtt_sn_message.c.
◆ mqttSnFormatPublish()
error_t mqttSnFormatPublish | ( | MqttSnMessage * | message, |
MqttSnFlags | flags, | ||
uint16_t | msgId, | ||
uint16_t | topicId, | ||
const char_t * | topicName, | ||
const uint8_t * | data, | ||
size_t | dataLen | ||
) |
Format PUBLISH message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] flags Flags [in] msgId Message identifier [in] topicId Topic identifier [in] topicName Short topic name [in] data Message payload [in] dataLen Length of the message payload
- Returns
- Error code
Definition at line 310 of file mqtt_sn_message.c.
◆ mqttSnFormatPubRec()
error_t mqttSnFormatPubRec | ( | MqttSnMessage * | message, |
uint16_t | msgId | ||
) |
Format PUBREC message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] msgId Message identifier of the corresponding PUBLISH message
- Returns
- Error code
Definition at line 413 of file mqtt_sn_message.c.
◆ mqttSnFormatPubRel()
error_t mqttSnFormatPubRel | ( | MqttSnMessage * | message, |
uint16_t | msgId | ||
) |
Format PUBREL message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] msgId Message identifier of the corresponding PUBLISH message
- Returns
- Error code
Definition at line 439 of file mqtt_sn_message.c.
◆ mqttSnFormatRegAck()
error_t mqttSnFormatRegAck | ( | MqttSnMessage * | message, |
uint16_t | msgId, | ||
uint16_t | topicId, | ||
MqttSnReturnCode | returnCode | ||
) |
Format REGACK message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] msgId Message identifier [in] topicId Topic identifier [in] returnCode Return code
- Returns
- Error code
Definition at line 276 of file mqtt_sn_message.c.
◆ mqttSnFormatRegister()
error_t mqttSnFormatRegister | ( | MqttSnMessage * | message, |
uint16_t | msgId, | ||
uint16_t | topicId, | ||
const char_t * | topicName | ||
) |
Format REGISTER message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] msgId Message identifier [in] topicId Topic identifier [in] topicName Topic name
- Returns
- Error code
Definition at line 243 of file mqtt_sn_message.c.
◆ mqttSnFormatSearchGw()
error_t mqttSnFormatSearchGw | ( | MqttSnMessage * | message, |
uint8_t | radius | ||
) |
Format SEARCHGW message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] radius Broadcast radius of SEARCHGW message
- Returns
- Error code
Definition at line 116 of file mqtt_sn_message.c.
◆ mqttSnFormatSubscribe()
error_t mqttSnFormatSubscribe | ( | MqttSnMessage * | message, |
MqttSnFlags | flags, | ||
uint16_t | msgId, | ||
uint16_t | topicId, | ||
const char_t * | topicName | ||
) |
Format SUBSCRIBE message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] flags Flags [in] msgId Message identifier [in] topicId Topic identifier [in] topicName Topic name
- Returns
- Error code
Definition at line 494 of file mqtt_sn_message.c.
◆ mqttSnFormatUnsubscribe()
error_t mqttSnFormatUnsubscribe | ( | MqttSnMessage * | message, |
MqttSnFlags | flags, | ||
uint16_t | msgId, | ||
uint16_t | topicId, | ||
const char_t * | topicName | ||
) |
Format UNSUBSCRIBE message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] flags Flags [in] msgId Message identifier [in] topicId Topic identifier [in] topicName Topic name
- Returns
- Error code
Definition at line 579 of file mqtt_sn_message.c.
◆ mqttSnFormatWillMsg()
error_t mqttSnFormatWillMsg | ( | MqttSnMessage * | message, |
const void * | data, | ||
size_t | dataLen | ||
) |
Format WILLMSG message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] data Will message [in] dataLen Length of the Will message
- Returns
- Error code
Definition at line 218 of file mqtt_sn_message.c.
◆ mqttSnFormatWillMsgUpd()
error_t mqttSnFormatWillMsgUpd | ( | MqttSnMessage * | message, |
const void * | data, | ||
size_t | dataLen | ||
) |
Format WILLMSGUPD message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] data Will message [in] dataLen Length of the Will message
- Returns
- Error code
Definition at line 784 of file mqtt_sn_message.c.
◆ mqttSnFormatWillTopic()
error_t mqttSnFormatWillTopic | ( | MqttSnMessage * | message, |
MqttSnFlags | flags, | ||
const char_t * | topicName | ||
) |
Format WILLTOPIC message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] flags Flags [in] topicName Topic name
- Returns
- Error code
Definition at line 178 of file mqtt_sn_message.c.
◆ mqttSnFormatWillTopicUpd()
error_t mqttSnFormatWillTopicUpd | ( | MqttSnMessage * | message, |
MqttSnFlags | flags, | ||
const char_t * | topicName | ||
) |
Format WILLTOPICUPD message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [in] flags Flags [in] topicName Topic name
- Returns
- Error code
Definition at line 744 of file mqtt_sn_message.c.
◆ mqttSnParseConnAck()
error_t mqttSnParseConnAck | ( | const MqttSnMessage * | message, |
MqttSnReturnCode * | returnCode | ||
) |
Parse CONNACK message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] returnCode Return code
- Returns
- Error code
Definition at line 906 of file mqtt_sn_message.c.
◆ mqttSnParseDisconnect()
error_t mqttSnParseDisconnect | ( | const MqttSnMessage * | message, |
uint16_t * | duration | ||
) |
Parse DISCONNECT message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] duration Value of the sleep timer
- Returns
- Error code
Definition at line 1304 of file mqtt_sn_message.c.
◆ mqttSnParseGwInfo()
error_t mqttSnParseGwInfo | ( | const MqttSnMessage * | message, |
uint8_t * | gwId, | ||
const uint8_t ** | gwAdd, | ||
size_t * | gwAddLen | ||
) |
Parse GWINFO message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] gwId Gateway identifier [out] gwAdd Gateway address [out] gwAddLen Length of the gateway address
- Returns
- Error code
Definition at line 871 of file mqtt_sn_message.c.
◆ mqttSnParseHeader()
error_t mqttSnParseHeader | ( | MqttSnMessage * | message, |
MqttSnMsgType * | type | ||
) |
Format MQTT-SN message header.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] type Message type
- Returns
- Error code
Definition at line 807 of file mqtt_sn_message.c.
◆ mqttSnParsePingReq()
error_t mqttSnParsePingReq | ( | const MqttSnMessage * | message, |
const char_t ** | clientId | ||
) |
Parse PINGREQ message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] clientId Client identifier
- Returns
- Error code
Definition at line 1268 of file mqtt_sn_message.c.
◆ mqttSnParsePingResp()
error_t mqttSnParsePingResp | ( | const MqttSnMessage * | message | ) |
Parse PINGRESP message.
- Parameters
-
[in] message Pointer to the MQTT-SN message
- Returns
- Error code
Definition at line 1290 of file mqtt_sn_message.c.
◆ mqttSnParsePubAck()
error_t mqttSnParsePubAck | ( | const MqttSnMessage * | message, |
uint16_t * | msgId, | ||
uint16_t * | topicId, | ||
MqttSnReturnCode * | returnCode | ||
) |
Parse PUBACK message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] msgId Message identifier [out] topicId Topic identifier [out] returnCode Return code
- Returns
- Error code
Definition at line 1079 of file mqtt_sn_message.c.
◆ mqttSnParsePubComp()
error_t mqttSnParsePubComp | ( | const MqttSnMessage * | message, |
uint16_t * | msgId | ||
) |
Parse PUBCOMP message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] msgId Message identifier
- Returns
- Error code
Definition at line 1171 of file mqtt_sn_message.c.
◆ mqttSnParsePublish()
error_t mqttSnParsePublish | ( | const MqttSnMessage * | message, |
MqttSnFlags * | flags, | ||
uint16_t * | msgId, | ||
uint16_t * | topicId, | ||
const uint8_t ** | data, | ||
size_t * | dataLen | ||
) |
Parse PUBLISH message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] flags Flags [out] msgId Message identifier [out] topicId Topic identifier [out] data Pointer to the published data [out] dataLen Length of the published data
- Returns
- Error code
Definition at line 1038 of file mqtt_sn_message.c.
◆ mqttSnParsePubRec()
error_t mqttSnParsePubRec | ( | const MqttSnMessage * | message, |
uint16_t * | msgId | ||
) |
Parse PUBREC message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] msgId Message identifier
- Returns
- Error code
Definition at line 1113 of file mqtt_sn_message.c.
◆ mqttSnParsePubRel()
error_t mqttSnParsePubRel | ( | const MqttSnMessage * | message, |
uint16_t * | msgId | ||
) |
Parse PUBREL message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] msgId Message identifier
- Returns
- Error code
Definition at line 1142 of file mqtt_sn_message.c.
◆ mqttSnParseRegAck()
error_t mqttSnParseRegAck | ( | const MqttSnMessage * | message, |
uint16_t * | msgId, | ||
uint16_t * | topicId, | ||
MqttSnReturnCode * | returnCode | ||
) |
Parse REGACK message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] msgId Message identifier [out] topicId Topic identifier [out] returnCode Return code
- Returns
- Error code
Definition at line 1000 of file mqtt_sn_message.c.
◆ mqttSnParseRegister()
error_t mqttSnParseRegister | ( | const MqttSnMessage * | message, |
uint16_t * | msgId, | ||
uint16_t * | topicId, | ||
const char_t ** | topicName | ||
) |
Parse REGISTER message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] msgId Message identifier [out] topicId Topic identifier [out] topicName Topic name
- Returns
- Error code
Definition at line 964 of file mqtt_sn_message.c.
◆ mqttSnParseSubAck()
error_t mqttSnParseSubAck | ( | const MqttSnMessage * | message, |
MqttSnFlags * | flags, | ||
uint16_t * | msgId, | ||
uint16_t * | topicId, | ||
MqttSnReturnCode * | returnCode | ||
) |
Parse SUBACK message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] flags Flags [out] msgId Message identifier [out] topicId Topic identifier [out] returnCode Return code
- Returns
- Error code
Definition at line 1203 of file mqtt_sn_message.c.
◆ mqttSnParseUnsubAck()
error_t mqttSnParseUnsubAck | ( | const MqttSnMessage * | message, |
uint16_t * | msgId | ||
) |
Parse UNSUBACK message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] msgId Message identifier
- Returns
- Error code
Definition at line 1239 of file mqtt_sn_message.c.
◆ mqttSnParseWillMsgReq()
error_t mqttSnParseWillMsgReq | ( | const MqttSnMessage * | message | ) |
Parse WILLMSGREQ message.
- Parameters
-
[in] message Pointer to the MQTT-SN message
- Returns
- Error code
Definition at line 948 of file mqtt_sn_message.c.
◆ mqttSnParseWillMsgResp()
error_t mqttSnParseWillMsgResp | ( | const MqttSnMessage * | message, |
MqttSnReturnCode * | returnCode | ||
) |
Parse WILLMSGRESP message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] returnCode Return code
- Returns
- Error code
Definition at line 1373 of file mqtt_sn_message.c.
◆ mqttSnParseWillTopicReq()
error_t mqttSnParseWillTopicReq | ( | const MqttSnMessage * | message | ) |
Parse WILLTOPICREQ message.
- Parameters
-
[in] message Pointer to the MQTT-SN message
- Returns
- Error code
Definition at line 935 of file mqtt_sn_message.c.
◆ mqttSnParseWillTopicResp()
error_t mqttSnParseWillTopicResp | ( | const MqttSnMessage * | message, |
MqttSnReturnCode * | returnCode | ||
) |
Parse WILLTOPICRESP message.
- Parameters
-
[in] message Pointer to the MQTT-SN message [out] returnCode Return code
- Returns
- Error code
Definition at line 1343 of file mqtt_sn_message.c.