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-2024 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 2.4.4
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
45  MqttClientState newState);
46 
49 
50 error_t mqttSerializeHeader(uint8_t *buffer, size_t *pos, MqttPacketType type,
51  bool_t dup, MqttQosLevel qos, bool_t retain, size_t remainingLen);
52 
53 error_t mqttSerializeByte(uint8_t *buffer, size_t bufferLen,
54  size_t *pos, uint8_t value);
55 
56 error_t mqttSerializeShort(uint8_t *buffer, size_t bufferLen,
57  size_t *pos, uint16_t value);
58 
59 error_t mqttSerializeString(uint8_t *buffer, size_t bufferLen,
60  size_t *pos, const void *string, size_t stringLen);
61 
62 error_t mqttSerializeData(uint8_t *buffer, size_t bufferLen,
63  size_t *pos, const void *data, size_t dataLen);
64 
65 error_t mqttDeserializeHeader(uint8_t *buffer, size_t bufferLen, size_t *pos,
66  MqttPacketType *type, bool_t *dup, MqttQosLevel *qos, bool_t *retain, size_t *remainingLen);
67 
68 error_t mqttDeserializeByte(uint8_t *buffer, size_t bufferLen,
69  size_t *pos, uint8_t *value);
70 
71 error_t mqttDeserializeShort(uint8_t *buffer, size_t bufferLen,
72  size_t *pos, uint16_t *value);
73 
74 error_t mqttDeserializeString(uint8_t *buffer, size_t bufferLen,
75  size_t *pos, char_t **string, size_t *stringLen);
76 
78 
79 //C++ guard
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif
int bool_t
Definition: compiler_port.h:53
uint8_t data[]
Definition: ethernet.h:222
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.
uint8_t type
Definition: coap_common.h:176
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:181
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.
error_t
Error codes.
Definition: error.h:43
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:87
uint32_t dataLen
Definition: sftp_common.h:229
uint32_t systime_t
System time.
char char_t
Definition: compiler_port.h:48
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:160
error_t mqttClientCheckKeepAlive(MqttClientContext *context)
Check keep-alive time interval.
uint8_t value[]
Definition: tcp.h:369
uint8_t dup
Definition: mqtt_common.h:182
error_t mqttDeserializeString(uint8_t *buffer, size_t bufferLen, size_t *pos, char_t **string, size_t *stringLen)
Deserialize string.
error_t mqttClientCheckTimeout(MqttClientContext *context)
Determine whether a timeout error has occurred.
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:147
TCP/IP stack core.
MqttPacketType
MQTT control packet type.
Definition: mqtt_common.h:99
MQTT client.