mqtt_client_misc.c File Reference

Helper functions for MQTT client. More...

Go to the source code of this file.

Macros

#define TRACE_LEVEL   MQTT_TRACE_LEVEL
 

Functions

void mqttClientChangeState (MqttClientContext *context, MqttClientState newState)
 Update MQTT client state. 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...
 

Detailed Description

Helper functions for MQTT client.

License

Copyright (C) 2010-2018 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
1.9.0

Definition in file mqtt_client_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   MQTT_TRACE_LEVEL

Definition at line 30 of file mqtt_client_misc.c.

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 50 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 63 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 414 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 336 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 446 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 479 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 197 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 300 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 128 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 229 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 263 of file mqtt_client_misc.c.