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