1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | #ifndef MQTTCONST_H
|
---|
5 | #define MQTTCONST_H
|
---|
6 |
|
---|
7 | #include "azure_c_shared_utility/crt_abstractions.h"
|
---|
8 | #include "azure_c_shared_utility/macro_utils.h"
|
---|
9 |
|
---|
10 | #ifdef __cplusplus
|
---|
11 | #include <cstddef>
|
---|
12 | #include <cstdint>
|
---|
13 | extern "C" {
|
---|
14 | #else
|
---|
15 | #include <stddef.h>
|
---|
16 | #include <stdint.h>
|
---|
17 | #endif /* __cplusplus */
|
---|
18 |
|
---|
19 | #define CONTROL_PACKET_TYPE_VALUES \
|
---|
20 | CONNECT_TYPE = 0x10, \
|
---|
21 | CONNACK_TYPE = 0x20, \
|
---|
22 | PUBLISH_TYPE = 0x30, \
|
---|
23 | PUBACK_TYPE = 0x40, \
|
---|
24 | PUBREC_TYPE = 0x50, \
|
---|
25 | PUBREL_TYPE = 0x60, \
|
---|
26 | PUBCOMP_TYPE = 0x70, \
|
---|
27 | SUBSCRIBE_TYPE = 0x80, \
|
---|
28 | SUBACK_TYPE = 0x90, \
|
---|
29 | UNSUBSCRIBE_TYPE = 0xA0, \
|
---|
30 | UNSUBACK_TYPE = 0xB0, \
|
---|
31 | PINGREQ_TYPE = 0xC0, \
|
---|
32 | PINGRESP_TYPE = 0xD0, \
|
---|
33 | DISCONNECT_TYPE = 0xE0, \
|
---|
34 | PACKET_TYPE_ERROR, \
|
---|
35 | UNKNOWN_TYPE
|
---|
36 |
|
---|
37 | MU_DEFINE_ENUM(CONTROL_PACKET_TYPE, CONTROL_PACKET_TYPE_VALUES)
|
---|
38 |
|
---|
39 | #define QOS_VALUE_VALUES \
|
---|
40 | DELIVER_AT_MOST_ONCE = 0x00, \
|
---|
41 | DELIVER_AT_LEAST_ONCE = 0x01, \
|
---|
42 | DELIVER_EXACTLY_ONCE = 0x02, \
|
---|
43 | DELIVER_FAILURE = 0x80
|
---|
44 |
|
---|
45 | MU_DEFINE_ENUM(QOS_VALUE, QOS_VALUE_VALUES)
|
---|
46 |
|
---|
47 | typedef struct APP_PAYLOAD_TAG
|
---|
48 | {
|
---|
49 | uint8_t* message;
|
---|
50 | size_t length;
|
---|
51 | } APP_PAYLOAD;
|
---|
52 |
|
---|
53 | typedef struct MQTT_CLIENT_OPTIONS_TAG
|
---|
54 | {
|
---|
55 | char* clientId;
|
---|
56 | char* willTopic;
|
---|
57 | char* willMessage;
|
---|
58 | char* username;
|
---|
59 | char* password;
|
---|
60 | uint16_t keepAliveInterval;
|
---|
61 | bool messageRetain;
|
---|
62 | bool useCleanSession;
|
---|
63 | QOS_VALUE qualityOfServiceValue;
|
---|
64 | bool log_trace;
|
---|
65 | } MQTT_CLIENT_OPTIONS;
|
---|
66 |
|
---|
67 | typedef enum CONNECT_RETURN_CODE_TAG
|
---|
68 | {
|
---|
69 | CONNECTION_ACCEPTED = 0x00,
|
---|
70 | CONN_REFUSED_UNACCEPTABLE_VERSION = 0x01,
|
---|
71 | CONN_REFUSED_ID_REJECTED = 0x02,
|
---|
72 | CONN_REFUSED_SERVER_UNAVAIL = 0x03,
|
---|
73 | CONN_REFUSED_BAD_USERNAME_PASSWORD = 0x04,
|
---|
74 | CONN_REFUSED_NOT_AUTHORIZED = 0x05,
|
---|
75 | CONN_REFUSED_UNKNOWN
|
---|
76 | } CONNECT_RETURN_CODE;
|
---|
77 |
|
---|
78 | typedef struct CONNECT_ACK_TAG
|
---|
79 | {
|
---|
80 | bool isSessionPresent;
|
---|
81 | CONNECT_RETURN_CODE returnCode;
|
---|
82 | } CONNECT_ACK;
|
---|
83 |
|
---|
84 | typedef struct SUBSCRIBE_PAYLOAD_TAG
|
---|
85 | {
|
---|
86 | const char* subscribeTopic;
|
---|
87 | QOS_VALUE qosReturn;
|
---|
88 | } SUBSCRIBE_PAYLOAD;
|
---|
89 |
|
---|
90 | typedef struct SUBSCRIBE_ACK_TAG
|
---|
91 | {
|
---|
92 | uint16_t packetId;
|
---|
93 | QOS_VALUE* qosReturn;
|
---|
94 | size_t qosCount;
|
---|
95 | } SUBSCRIBE_ACK;
|
---|
96 |
|
---|
97 | typedef struct UNSUBSCRIBE_ACK_TAG
|
---|
98 | {
|
---|
99 | uint16_t packetId;
|
---|
100 | } UNSUBSCRIBE_ACK;
|
---|
101 |
|
---|
102 | typedef struct PUBLISH_ACK_TAG
|
---|
103 | {
|
---|
104 | uint16_t packetId;
|
---|
105 | } PUBLISH_ACK;
|
---|
106 |
|
---|
107 | #ifdef __cplusplus
|
---|
108 | }
|
---|
109 | #endif /* __cplusplus */
|
---|
110 |
|
---|
111 | #endif // MQTTCONST_H
|
---|