mqtt_sn_client.c File Reference

MQTT-SN client. More...

Go to the source code of this file.

Macros

#define TRACE_LEVEL   MQTT_SN_TRACE_LEVEL
 

Functions

error_t mqttSnClientInit (MqttSnClientContext *context)
 Initialize MQTT-SN client context. More...
 
error_t mqttSnClientSetTransportProtocol (MqttSnClientContext *context, MqttSnTransportProtocol transportProtocol)
 Set the transport protocol to be used. More...
 
error_t mqttSnClientRegisterDtlsInitCallback (MqttSnClientContext *context, MqttSnClientDtlsInitCallback callback)
 Register DTLS initialization callback function. More...
 
error_t mqttSnClientRegisterPublishCallback (MqttSnClientContext *context, MqttSnClientPublishCallback callback)
 Register publish callback function. More...
 
error_t mqttSnClientSetPredefinedTopics (MqttSnClientContext *context, MqttSnPredefinedTopic *predefinedTopics, uint_t size)
 Set the list of predefined topics. More...
 
error_t mqttSnClientSetTimeout (MqttSnClientContext *context, systime_t timeout)
 Set communication timeout. More...
 
error_t mqttSnClientSetKeepAlive (MqttSnClientContext *context, systime_t keepAlive)
 Set keep-alive value. More...
 
error_t mqttSnClientSetIdentifier (MqttSnClientContext *context, const char_t *clientId)
 Set client identifier. More...
 
error_t mqttSnClientSetWillMessage (MqttSnClientContext *context, const char_t *topic, const void *message, size_t length, MqttSnQosLevel qos, bool_t retain)
 Specify the Will message. More...
 
error_t mqttSnClientBindToInterface (MqttSnClientContext *context, NetInterface *interface)
 Bind the MQTT-SN client to a particular network interface. More...
 
error_t mqttSnClientSetGateway (MqttSnClientContext *context, const IpAddr *gwIpAddr, uint16_t gwPort)
 Specify the address of the gateway. More...
 
error_t mqttSnClientSearchGateway (MqttSnClientContext *context, const IpAddr *destIpAddr, uint16_t destPort)
 Search for a gateway. More...
 
error_t mqttSnClientConnect (MqttSnClientContext *context, bool_t cleanSession)
 Establish connection with the MQTT-SN gateway. More...
 
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. More...
 
error_t mqttSnClientSubscribe (MqttSnClientContext *context, const char_t *topicName, MqttSnQosLevel qos)
 Subscribe to topic. More...
 
error_t mqttSnClientUnsubscribe (MqttSnClientContext *context, const char_t *topicName)
 Unsubscribe from topic. More...
 
error_t mqttSnClientPing (MqttSnClientContext *context)
 Send ping request. More...
 
error_t mqttSnClientUpdateWillMessage (MqttSnClientContext *context, const char_t *topic, const void *message, size_t length, MqttSnQosLevel qos, bool_t retain)
 Update the Will message. More...
 
error_t mqttSnClientGetReturnCode (MqttSnClientContext *context, MqttSnReturnCode *returnCode)
 Retrieve return code. More...
 
error_t mqttSnClientTask (MqttSnClientContext *context, systime_t timeout)
 Process MQTT-SN client events. More...
 
error_t mqttSnClientDisconnect (MqttSnClientContext *context, systime_t duration)
 Disconnect from the MQTT-SN gateway. More...
 
void mqttSnClientDeinit (MqttSnClientContext *context)
 Release MQTT-SN client context. More...
 

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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
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]contextPointer to the MQTT-SN client context
[in]interfaceNetwork 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]contextPointer to the MQTT-SN client context
[in]cleanSessionIf 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]contextPointer 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]contextPointer to the MQTT-SN client context
[in]durationSleep 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]contextPointer to the MQTT-SN client context
[out]returnCodeReturn 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]contextPointer 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]contextPointer 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]contextPointer to the MQTT-SN client context
[in]topicNameTopic name
[in]messageMessage payload
[in]lengthLength of the message payload
[in]qosQoS level to be used when publishing the message
[in]retainThis flag specifies if the message is to be retained
[in]dupThis flag specifies if the message is sent for the first time or if the message is retransmitted
[in,out]msgIdMessage 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]contextPointer to the MQTT-SN client context
[in]callbackDTLS 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]contextPointer to the MQTT-SN client context
[in]callbackCallback 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]contextPointer to the MQTT-SN client context
[in]destIpAddrDestination IP address
[in]destPortDestination 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]contextPointer to the MQTT-SN client context
[in]gwIpAddrGateway IP address
[in]gwPortGateway 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]contextPointer to the MQTT-SN client context
[in]clientIdNULL-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]contextPointer to the MQTT-SN client context
[in]keepAliveKeep-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]contextPointer to the MQTT-SN client context
[in]predefinedTopicsList of predefined topics
[in]sizeNumber 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]contextPointer to the MQTT-SN client context
[in]timeoutTimeout 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]contextPointer to the MQTT-SN client context
[in]transportProtocolTransport 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]contextPointer to the MQTT-SN client context
[in]topicWill topic name
[in]messageWill message
[in]lengthLength of the Will message
[in]qosQoS level to be used when publishing the Will message
[in]retainThis 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]contextPointer to the MQTT-SN client context
[in]topicNameTopic filter
[in]qosMaximum 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]contextPointer to the MQTT-SN client context
[in]timeoutMaximum 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]contextPointer to the MQTT-SN client context
[in]topicNameTopic 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]contextPointer to the MQTT-SN client context
[in]topicWill topic name
[in]messageWill message
[in]lengthLength of the Will message
[in]qosQoS level to be used when publishing the Will message
[in]retainThis flag specifies if the Will message is to be retained
Returns
Error code

Definition at line 1171 of file mqtt_sn_client.c.