mqtt_client_misc.h
Go to the documentation of this file.
1 /**
2  * @file mqtt_client_misc.h
3  * @brief Helper functions for MQTT client
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.6
29  **/
30 
31 #ifndef _MQTT_CLIENT_MISC_H
32 #define _MQTT_CLIENT_MISC_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "mqtt/mqtt_client.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //MQTT client related functions
47 
48 error_t mqttSerializeHeader(uint8_t *buffer, size_t *pos, MqttPacketType type,
49  bool_t dup, MqttQosLevel qos, bool_t retain, size_t remainingLen);
50 
51 error_t mqttSerializeByte(uint8_t *buffer, size_t bufferLen,
52  size_t *pos, uint8_t value);
53 
54 error_t mqttSerializeShort(uint8_t *buffer, size_t bufferLen,
55  size_t *pos, uint16_t value);
56 
57 error_t mqttSerializeString(uint8_t *buffer, size_t bufferLen,
58  size_t *pos, const void *string, size_t stringLen);
59 
60 error_t mqttSerializeData(uint8_t *buffer, size_t bufferLen,
61  size_t *pos, const void *data, size_t dataLen);
62 
63 error_t mqttDeserializeHeader(uint8_t *buffer, size_t bufferLen, size_t *pos,
64  MqttPacketType *type, bool_t *dup, MqttQosLevel *qos, bool_t *retain, size_t *remainingLen);
65 
66 error_t mqttDeserializeByte(uint8_t *buffer, size_t bufferLen,
67  size_t *pos, uint8_t *value);
68 
69 error_t mqttDeserializeShort(uint8_t *buffer, size_t bufferLen,
70  size_t *pos, uint16_t *value);
71 
72 error_t mqttDeserializeString(uint8_t *buffer, size_t bufferLen,
73  size_t *pos, char_t **string, size_t *stringLen);
74 
75 //C++ guard
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
int bool_t
Definition: compiler_port.h:49
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.
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.
uint8_t qos
Definition: mqtt_common.h:179
error_t mqttClientProcessEvents(MqttClientContext *context, systime_t timeout)
Process MQTT client events.
error_t mqttSerializeByte(uint8_t *buffer, size_t bufferLen, size_t *pos, uint8_t value)
Write a 8-bit integer to the output buffer.
char_t type
error_t
Error codes.
Definition: error.h:42
error_t mqttSerializeData(uint8_t *buffer, size_t bufferLen, size_t *pos, const void *data, size_t dataLen)
Serialize raw data.
void mqttClientChangeState(MqttClientContext *context, MqttClientState newState)
Update MQTT client state.
MqttQosLevel
Quality of service level.
Definition: mqtt_common.h:86
uint8_t retain
Definition: mqtt_common.h:178
char char_t
Definition: compiler_port.h:43
error_t mqttSerializeString(uint8_t *buffer, size_t bufferLen, size_t *pos, const void *string, size_t stringLen)
Serialize string.
error_t mqttDeserializeShort(uint8_t *buffer, size_t bufferLen, size_t *pos, uint16_t *value)
Read a 16-bit integer from the input buffer.
error_t mqttSerializeShort(uint8_t *buffer, size_t bufferLen, size_t *pos, uint16_t value)
Write a 16-bit integer to the output buffer.
MqttClientState
MQTT client states.
Definition: mqtt_client.h:154
error_t mqttClientCheckKeepAlive(MqttClientContext *context)
Check keep-alive time interval.
uint8_t dup
Definition: mqtt_common.h:180
error_t mqttDeserializeString(uint8_t *buffer, size_t bufferLen, size_t *pos, char_t **string, size_t *stringLen)
Deserialize string.
error_t mqttDeserializeByte(uint8_t *buffer, size_t bufferLen, size_t *pos, uint8_t *value)
Read a 8-bit integer from the input buffer.
#define MqttClientContext
Definition: mqtt_client.h:142
uint8_t value[]
Definition: dtls_misc.h:150
TCP/IP stack core.
uint8_t data[]
Definition: dtls_misc.h:176
uint32_t systime_t
Definition: compiler_port.h:46
MqttPacketType
MQTT control packet type.
Definition: mqtt_common.h:98
MQTT client.