MQTT-SN client. More...
#include "core/net.h"
#include "mqtt_sn/mqtt_sn_client.h"
#include "mqtt_sn/mqtt_sn_client_message.h"
#include "mqtt_sn/mqtt_sn_client_transport.h"
#include "mqtt_sn/mqtt_sn_client_misc.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL MQTT_SN_TRACE_LEVEL |
Detailed Description
MQTT-SN client.
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_client.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL MQTT_SN_TRACE_LEVEL |
Definition at line 32 of file mqtt_sn_client.c.
Function Documentation
◆ mqttSnClientBindToInterface()
error_t mqttSnClientBindToInterface | ( | MqttSnClientContext * | context, |
NetInterface * | interface | ||
) |
Bind the MQTT-SN client to a particular network interface.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] interface Network interface to be used
- Returns
- Error code
Definition at line 319 of file mqtt_sn_client.c.
◆ mqttSnClientConnect()
error_t mqttSnClientConnect | ( | MqttSnClientContext * | context, |
bool_t | cleanSession | ||
) |
Establish connection with the MQTT-SN gateway.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] cleanSession If this flag is set, then the client and server must discard any previous session and start a new one
- Returns
- Error code
Definition at line 479 of file mqtt_sn_client.c.
◆ mqttSnClientDeinit()
void mqttSnClientDeinit | ( | MqttSnClientContext * | context | ) |
Release MQTT-SN client context.
- Parameters
-
[in] context Pointer to the MQTT-SN client context
Definition at line 1468 of file mqtt_sn_client.c.
◆ mqttSnClientDisconnect()
error_t mqttSnClientDisconnect | ( | MqttSnClientContext * | context, |
systime_t | duration | ||
) |
Disconnect from the MQTT-SN gateway.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] duration Sleep duration, in milliseconds
- Returns
- Error code
Definition at line 1374 of file mqtt_sn_client.c.
◆ mqttSnClientGetReturnCode()
error_t mqttSnClientGetReturnCode | ( | MqttSnClientContext * | context, |
MqttSnReturnCode * | returnCode | ||
) |
Retrieve return code.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [out] returnCode Return code
- Returns
- Error code
Definition at line 1318 of file mqtt_sn_client.c.
◆ mqttSnClientInit()
error_t mqttSnClientInit | ( | MqttSnClientContext * | context | ) |
Initialize MQTT-SN client context.
- Parameters
-
[in] context Pointer to the MQTT-SN client context
- Returns
- Error code
Definition at line 52 of file mqtt_sn_client.c.
◆ mqttSnClientPing()
error_t mqttSnClientPing | ( | MqttSnClientContext * | context | ) |
Send ping request.
- Parameters
-
[in] context Pointer to the MQTT-SN client context
- Returns
- Error code
Definition at line 1073 of file mqtt_sn_client.c.
◆ mqttSnClientPublish()
error_t mqttSnClientPublish | ( | MqttSnClientContext * | context, |
const char_t * | topicName, | ||
const void * | message, | ||
size_t | length, | ||
MqttSnQosLevel | qos, | ||
bool_t | retain, | ||
bool_t | dup, | ||
uint16_t * | msgId | ||
) |
Publish message.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] topicName Topic name [in] message Message payload [in] length Length of the message payload [in] qos QoS level to be used when publishing the message [in] retain This flag specifies if the message is to be retained [in] dup This flag specifies if the message is sent for the first time or if the message is retransmitted [in,out] msgId Message identifier used to send the PUBLISH message
- Returns
- Error code
Definition at line 633 of file mqtt_sn_client.c.
◆ mqttSnClientRegisterDtlsInitCallback()
error_t mqttSnClientRegisterDtlsInitCallback | ( | MqttSnClientContext * | context, |
MqttSnClientDtlsInitCallback | callback | ||
) |
Register DTLS initialization callback function.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] callback DTLS initialization callback function
- Returns
- Error code
Definition at line 122 of file mqtt_sn_client.c.
◆ mqttSnClientRegisterPublishCallback()
error_t mqttSnClientRegisterPublishCallback | ( | MqttSnClientContext * | context, |
MqttSnClientPublishCallback | callback | ||
) |
Register publish callback function.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] callback Callback function to be called when a PUBLISH message is received
- Returns
- Error code
Definition at line 147 of file mqtt_sn_client.c.
◆ mqttSnClientSearchGateway()
error_t mqttSnClientSearchGateway | ( | MqttSnClientContext * | context, |
const IpAddr * | destIpAddr, | ||
uint16_t | destPort | ||
) |
Search for a gateway.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] destIpAddr Destination IP address [in] destPort Destination port number
- Returns
- Error code
Definition at line 366 of file mqtt_sn_client.c.
◆ mqttSnClientSetGateway()
error_t mqttSnClientSetGateway | ( | MqttSnClientContext * | context, |
const IpAddr * | gwIpAddr, | ||
uint16_t | gwPort | ||
) |
Specify the address of the gateway.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] gwIpAddr Gateway IP address [in] gwPort Gateway port number
- Returns
- Error code
Definition at line 342 of file mqtt_sn_client.c.
◆ mqttSnClientSetIdentifier()
error_t mqttSnClientSetIdentifier | ( | MqttSnClientContext * | context, |
const char_t * | clientId | ||
) |
Set client identifier.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] clientId NULL-terminated string containing the client identifier
- Returns
- Error code
Definition at line 239 of file mqtt_sn_client.c.
◆ mqttSnClientSetKeepAlive()
error_t mqttSnClientSetKeepAlive | ( | MqttSnClientContext * | context, |
systime_t | keepAlive | ||
) |
Set keep-alive value.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] keepAlive Keep-alive interval, in milliseconds
- Returns
- Error code
Definition at line 218 of file mqtt_sn_client.c.
◆ mqttSnClientSetPredefinedTopics()
error_t mqttSnClientSetPredefinedTopics | ( | MqttSnClientContext * | context, |
MqttSnPredefinedTopic * | predefinedTopics, | ||
uint_t | size | ||
) |
Set the list of predefined topics.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] predefinedTopics List of predefined topics [in] size Number of predefined topics
- Returns
- Error code
Definition at line 170 of file mqtt_sn_client.c.
◆ mqttSnClientSetTimeout()
error_t mqttSnClientSetTimeout | ( | MqttSnClientContext * | context, |
systime_t | timeout | ||
) |
Set communication timeout.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] timeout Timeout value, in milliseconds
- Returns
- Error code
Definition at line 197 of file mqtt_sn_client.c.
◆ mqttSnClientSetTransportProtocol()
error_t mqttSnClientSetTransportProtocol | ( | MqttSnClientContext * | context, |
MqttSnTransportProtocol | transportProtocol | ||
) |
Set the transport protocol to be used.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] transportProtocol Transport protocol to be used (UDP or DTLS)
- Returns
- Error code
Definition at line 98 of file mqtt_sn_client.c.
◆ mqttSnClientSetWillMessage()
error_t mqttSnClientSetWillMessage | ( | MqttSnClientContext * | context, |
const char_t * | topic, | ||
const void * | message, | ||
size_t | length, | ||
MqttSnQosLevel | qos, | ||
bool_t | retain | ||
) |
Specify the Will message.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] topic Will topic name [in] message Will message [in] length Length of the Will message [in] qos QoS level to be used when publishing the Will message [in] retain This flag specifies if the Will message is to be retained
- Returns
- Error code
Definition at line 269 of file mqtt_sn_client.c.
◆ mqttSnClientSubscribe()
error_t mqttSnClientSubscribe | ( | MqttSnClientContext * | context, |
const char_t * | topicName, | ||
MqttSnQosLevel | qos | ||
) |
Subscribe to topic.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] topicName Topic filter [in] qos Maximum QoS level at which the server can send application messages to the client
- Returns
- Error code
Definition at line 874 of file mqtt_sn_client.c.
◆ mqttSnClientTask()
error_t mqttSnClientTask | ( | MqttSnClientContext * | context, |
systime_t | timeout | ||
) |
Process MQTT-SN client events.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] timeout Maximum time to wait before returning
- Returns
- Error code
Definition at line 1340 of file mqtt_sn_client.c.
◆ mqttSnClientUnsubscribe()
error_t mqttSnClientUnsubscribe | ( | MqttSnClientContext * | context, |
const char_t * | topicName | ||
) |
Unsubscribe from topic.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] topicName Topic filter
- Returns
- Error code
Definition at line 983 of file mqtt_sn_client.c.
◆ mqttSnClientUpdateWillMessage()
error_t mqttSnClientUpdateWillMessage | ( | MqttSnClientContext * | context, |
const char_t * | topic, | ||
const void * | message, | ||
size_t | length, | ||
MqttSnQosLevel | qos, | ||
bool_t | retain | ||
) |
Update the Will message.
- Parameters
-
[in] context Pointer to the MQTT-SN client context [in] topic Will topic name [in] message Will message [in] length Length of the Will message [in] qos QoS level to be used when publishing the Will message [in] retain This flag specifies if the Will message is to be retained
- Returns
- Error code
Definition at line 1171 of file mqtt_sn_client.c.