mqtt_client_misc.h File Reference

Helper functions for MQTT client. More...

#include "core/net.h"
#include "mqtt/mqtt_client.h"

Go to the source code of this file.

Functions

void mqttClientChangeState (MqttClientContext *context, MqttClientState newState)
 Update MQTT client state. More...
 
error_t mqttClientProcessEvents (MqttClientContext *context, systime_t timeout)
 Process MQTT client events. More...
 
error_t mqttClientCheckKeepAlive (MqttClientContext *context)
 Check keep-alive time interval. More...
 
error_t mqttSerializeHeader (uint8_t *buffer, size_t *pos, MqttPacketType type, bool_t dup, MqttQosLevel qos, bool_t retain, size_t remainingLen)
 Serialize fixed header. More...
 
error_t mqttSerializeByte (uint8_t *buffer, size_t bufferLen, size_t *pos, uint8_t value)
 Write a 8-bit integer to the output buffer. More...
 
error_t mqttSerializeShort (uint8_t *buffer, size_t bufferLen, size_t *pos, uint16_t value)
 Write a 16-bit integer to the output buffer. More...
 
error_t mqttSerializeString (uint8_t *buffer, size_t bufferLen, size_t *pos, const void *string, size_t stringLen)
 Serialize string. More...
 
error_t mqttSerializeData (uint8_t *buffer, size_t bufferLen, size_t *pos, const void *data, size_t dataLen)
 Serialize raw data. More...
 
error_t mqttDeserializeHeader (uint8_t *buffer, size_t bufferLen, size_t *pos, MqttPacketType *type, bool_t *dup, MqttQosLevel *qos, bool_t *retain, size_t *remainingLen)
 Deserialize fixed header. More...
 
error_t mqttDeserializeByte (uint8_t *buffer, size_t bufferLen, size_t *pos, uint8_t *value)
 Read a 8-bit integer from the input buffer. More...
 
error_t mqttDeserializeShort (uint8_t *buffer, size_t bufferLen, size_t *pos, uint16_t *value)
 Read a 16-bit integer from the input buffer. More...
 
error_t mqttDeserializeString (uint8_t *buffer, size_t bufferLen, size_t *pos, char_t **string, size_t *stringLen)
 Deserialize string. More...
 
error_t mqttClientCheckTimeout (MqttClientContext *context)
 Determine whether a timeout error has occurred. More...
 

Detailed Description

Helper functions for MQTT 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_client_misc.h.

Function Documentation

◆ mqttClientChangeState()

void mqttClientChangeState ( MqttClientContext context,
MqttClientState  newState 
)

Update MQTT client state.

Parameters
[in]contextPointer to the MQTT client context
[in]newStateNew state to switch to

Definition at line 52 of file mqtt_client_misc.c.

◆ mqttClientCheckKeepAlive()

error_t mqttClientCheckKeepAlive ( MqttClientContext context)

Check keep-alive time interval.

Parameters
[in]contextPointer to the MQTT client context
Returns
Error code

Definition at line 165 of file mqtt_client_misc.c.

◆ mqttClientCheckTimeout()

error_t mqttClientCheckTimeout ( MqttClientContext context)

Determine whether a timeout error has occurred.

Parameters
[in]contextPointer to the MQTT client context
Returns
Error code

Definition at line 627 of file mqtt_client_misc.c.

◆ mqttClientProcessEvents()

error_t mqttClientProcessEvents ( MqttClientContext context,
systime_t  timeout 
)

Process MQTT client events.

Parameters
[in]contextPointer to the MQTT client context
[in]timeoutMaximum time to wait before returning
Returns
Error code

Definition at line 67 of file mqtt_client_misc.c.

◆ mqttDeserializeByte()

error_t mqttDeserializeByte ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
uint8_t *  value 
)

Read a 8-bit integer from the input buffer.

Parameters
[in]bufferPointer to the input buffer
[in]bufferLenLength of the input buffer
[in,out]posCurrent position
[out]valueValue of the 8-bit integer
Returns
Error code

Definition at line 526 of file mqtt_client_misc.c.

◆ mqttDeserializeHeader()

error_t mqttDeserializeHeader ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
MqttPacketType type,
bool_t dup,
MqttQosLevel qos,
bool_t retain,
size_t *  remainingLen 
)

Deserialize fixed header.

Parameters
[in]bufferPointer to the input buffer
[in]bufferLenLength of the input buffer
[in,out]posCurrent position
[out]typeMQTT control packet type
[out]dupDUP flag from the fixed header
[out]qosQoS field from the fixed header
[out]retainRETAIN flag from the fixed header
[out]remainingLenLength of the variable header and the payload
Returns
Error code

Definition at line 448 of file mqtt_client_misc.c.

◆ mqttDeserializeShort()

error_t mqttDeserializeShort ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
uint16_t *  value 
)

Read a 16-bit integer from the input buffer.

Parameters
[in]bufferPointer to the input buffer
[in]bufferLenLength of the input buffer
[in,out]posCurrent position
[out]valueValue of the 16-bit integer
Returns
Error code

Definition at line 558 of file mqtt_client_misc.c.

◆ mqttDeserializeString()

error_t mqttDeserializeString ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
char_t **  string,
size_t *  stringLen 
)

Deserialize string.

Parameters
[in]bufferPointer to the input buffer
[in]bufferLenLength of the input buffer
[in,out]posCurrent position
[out]stringPointer to the string
[out]stringLenLength of the string, in bytes
Returns
Error code

Definition at line 591 of file mqtt_client_misc.c.

◆ mqttSerializeByte()

error_t mqttSerializeByte ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
uint8_t  value 
)

Write a 8-bit integer to the output buffer.

Parameters
[in]bufferPointer to the output buffer
[in]bufferLenMaximum number of bytes the output buffer can hold
[in,out]posCurrent position
[in]value8-bit integer to be serialized
Returns
Error code

Definition at line 309 of file mqtt_client_misc.c.

◆ mqttSerializeData()

error_t mqttSerializeData ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
const void *  data,
size_t  dataLen 
)

Serialize raw data.

Parameters
[in]bufferPointer to the output buffer
[in]bufferLenMaximum number of bytes the output buffer can hold
[in,out]posCurrent position
[in]dataPointer to the raw data to be serialized
[in]dataLenLength of the raw data, in bytes
Returns
Error code

Definition at line 412 of file mqtt_client_misc.c.

◆ mqttSerializeHeader()

error_t mqttSerializeHeader ( uint8_t *  buffer,
size_t *  pos,
MqttPacketType  type,
bool_t  dup,
MqttQosLevel  qos,
bool_t  retain,
size_t  remainingLen 
)

Serialize fixed header.

Parameters
[in]bufferPointer to the output buffer
[in,out]posCurrent position
[in]typeMQTT control packet type
[in]dupDUP flag
[in]qosQoS field
[in]retainRETAIN flag
[in]remainingLenLength of the variable header and the payload
Returns
Error code

Definition at line 230 of file mqtt_client_misc.c.

◆ mqttSerializeShort()

error_t mqttSerializeShort ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
uint16_t  value 
)

Write a 16-bit integer to the output buffer.

Parameters
[in]bufferPointer to the output buffer
[in]bufferLenMaximum number of bytes the output buffer can hold
[in,out]posCurrent position
[in]value16-bit integer to be serialized
Returns
Error code

Definition at line 341 of file mqtt_client_misc.c.

◆ mqttSerializeString()

error_t mqttSerializeString ( uint8_t *  buffer,
size_t  bufferLen,
size_t *  pos,
const void *  string,
size_t  stringLen 
)

Serialize string.

Parameters
[in]bufferPointer to the output buffer
[in]bufferLenMaximum number of bytes the output buffer can hold
[in,out]posCurrent position
[in]stringPointer to the string to be serialized
[in]stringLenLength of the string, in bytes
Returns
Error code

Definition at line 375 of file mqtt_client_misc.c.