7#if !defined(ASYNC_MQTT_PACKET_REASON_CODE_HPP)
8#define ASYNC_MQTT_PACKET_REASON_CODE_HPP
17enum class connect_reason_code : std::uint8_t {
19 unspecified_error = 0x80,
20 malformed_packet = 0x81,
21 protocol_error = 0x82,
22 implementation_specific_error = 0x83,
23 unsupported_protocol_version = 0x84,
24 client_identifier_not_valid = 0x85,
25 bad_user_name_or_password = 0x86,
26 not_authorized = 0x87,
27 server_unavailable = 0x88,
30 server_shutting_down = 0x8b,
31 bad_authentication_method = 0x8c,
32 topic_name_invalid = 0x90,
33 packet_too_large = 0x95,
34 quota_exceeded = 0x97,
35 payload_format_invalid = 0x99,
36 retain_not_supported = 0x9a,
37 qos_not_supported = 0x9b,
38 use_another_server = 0x9c,
40 connection_rate_exceeded = 0x9f,
44char const* connect_reason_code_to_str(connect_reason_code v) {
47 case connect_reason_code::success:
return "success";
48 case connect_reason_code::unspecified_error:
return "unspecified_error";
49 case connect_reason_code::malformed_packet:
return "malformed_packet";
50 case connect_reason_code::protocol_error:
return "protocol_error";
51 case connect_reason_code::implementation_specific_error:
return "implementation_specific_error";
52 case connect_reason_code::unsupported_protocol_version:
return "unsupported_protocol_version";
53 case connect_reason_code::client_identifier_not_valid:
return "client_identifier_not_valid";
54 case connect_reason_code::bad_user_name_or_password:
return "bad_user_name_or_password";
55 case connect_reason_code::not_authorized:
return "not_authorized";
56 case connect_reason_code::server_unavailable:
return "server_unavailable";
57 case connect_reason_code::server_busy:
return "server_busy";
58 case connect_reason_code::banned:
return "banned";
59 case connect_reason_code::server_shutting_down:
return "server_shutting_down";
60 case connect_reason_code::bad_authentication_method:
return "bad_authentication_method";
61 case connect_reason_code::topic_name_invalid:
return "topic_name_invalid";
62 case connect_reason_code::packet_too_large:
return "packet_too_large";
63 case connect_reason_code::quota_exceeded:
return "quota_exceeded";
64 case connect_reason_code::payload_format_invalid:
return "payload_format_invalid";
65 case connect_reason_code::retain_not_supported:
return "retain_not_supported";
66 case connect_reason_code::qos_not_supported:
return "qos_not_supported";
67 case connect_reason_code::use_another_server:
return "use_another_server";
68 case connect_reason_code::server_moved:
return "server_moved";
69 case connect_reason_code::connection_rate_exceeded:
return "connection_rate_exceeded";
70 default:
return "unknown_connect_reason_code";
75std::ostream& operator<<(std::ostream& os, connect_reason_code val)
77 os << connect_reason_code_to_str(val);
81enum class disconnect_reason_code : std::uint8_t {
82 normal_disconnection = 0x00,
83 disconnect_with_will_message = 0x04,
84 unspecified_error = 0x80,
85 malformed_packet = 0x81,
86 protocol_error = 0x82,
87 implementation_specific_error = 0x83,
88 not_authorized = 0x87,
90 server_shutting_down = 0x8b,
91 keep_alive_timeout = 0x8d,
92 session_taken_over = 0x8e,
93 topic_filter_invalid = 0x8f,
94 topic_name_invalid = 0x90,
95 receive_maximum_exceeded = 0x93,
96 topic_alias_invalid = 0x94,
97 packet_too_large = 0x95,
98 message_rate_too_high = 0x96,
99 quota_exceeded = 0x97,
100 administrative_action = 0x98,
101 payload_format_invalid = 0x99,
102 retain_not_supported = 0x9a,
103 qos_not_supported = 0x9b,
104 use_another_server = 0x9c,
106 shared_subscriptions_not_supported = 0x9e,
107 connection_rate_exceeded = 0x9f,
108 maximum_connect_time = 0xa0,
109 subscription_identifiers_not_supported = 0xa1,
110 wildcard_subscriptions_not_supported = 0xa2,
114char const* disconnect_reason_code_to_str(disconnect_reason_code v) {
117 case disconnect_reason_code::normal_disconnection:
return "normal_disconnection";
118 case disconnect_reason_code::disconnect_with_will_message:
return "disconnect_with_will_message";
119 case disconnect_reason_code::unspecified_error:
return "unspecified_error";
120 case disconnect_reason_code::malformed_packet:
return "malformed_packet";
121 case disconnect_reason_code::protocol_error:
return "protocol_error";
122 case disconnect_reason_code::implementation_specific_error:
return "implementation_specific_error";
123 case disconnect_reason_code::not_authorized:
return "not_authorized";
124 case disconnect_reason_code::server_busy:
return "server_busy";
125 case disconnect_reason_code::server_shutting_down:
return "server_shutting_down";
126 case disconnect_reason_code::keep_alive_timeout:
return "keep_alive_timeout";
127 case disconnect_reason_code::session_taken_over:
return "session_taken_over";
128 case disconnect_reason_code::topic_filter_invalid:
return "topic_filter_invalid";
129 case disconnect_reason_code::topic_name_invalid:
return "topic_name_invalid";
130 case disconnect_reason_code::receive_maximum_exceeded:
return "receive_maximum_exceeded";
131 case disconnect_reason_code::topic_alias_invalid:
return "topic_alias_invalid";
132 case disconnect_reason_code::packet_too_large:
return "packet_too_large";
133 case disconnect_reason_code::message_rate_too_high:
return "message_rate_too_high";
134 case disconnect_reason_code::quota_exceeded:
return "quota_exceeded";
135 case disconnect_reason_code::administrative_action:
return "administrative_action";
136 case disconnect_reason_code::payload_format_invalid:
return "payload_format_invalid";
137 case disconnect_reason_code::retain_not_supported:
return "retain_not_supported";
138 case disconnect_reason_code::qos_not_supported:
return "qos_not_supported";
139 case disconnect_reason_code::use_another_server:
return "use_another_server";
140 case disconnect_reason_code::server_moved:
return "server_moved";
141 case disconnect_reason_code::shared_subscriptions_not_supported:
return "shared_subscriptions_not_supported";
142 case disconnect_reason_code::connection_rate_exceeded:
return "connection_rate_exceeded";
143 case disconnect_reason_code::maximum_connect_time:
return "maximum_connect_time";
144 case disconnect_reason_code::subscription_identifiers_not_supported:
return "subscription_identifiers_not_supported";
145 case disconnect_reason_code::wildcard_subscriptions_not_supported:
return "wildcard_subscriptions_not_supported";
146 default:
return "unknown_disconnect_reason_code";
151std::ostream& operator<<(std::ostream& os, disconnect_reason_code val)
153 os << disconnect_reason_code_to_str(val);
158enum class suback_reason_code : std::uint8_t {
159 granted_qos_0 = 0x00,
160 granted_qos_1 = 0x01,
161 granted_qos_2 = 0x02,
162 unspecified_error = 0x80,
163 implementation_specific_error = 0x83,
164 not_authorized = 0x87,
165 topic_filter_invalid = 0x8f,
166 packet_identifier_in_use = 0x91,
167 quota_exceeded = 0x97,
168 shared_subscriptions_not_supported = 0x9e,
169 subscription_identifiers_not_supported = 0xa1,
170 wildcard_subscriptions_not_supported = 0xa2,
174char const* suback_reason_code_to_str(suback_reason_code v) {
177 case suback_reason_code::granted_qos_0:
return "granted_qos_0";
178 case suback_reason_code::granted_qos_1:
return "granted_qos_1";
179 case suback_reason_code::granted_qos_2:
return "granted_qos_2";
180 case suback_reason_code::unspecified_error:
return "unspecified_error";
181 case suback_reason_code::implementation_specific_error:
return "implementation_specific_error";
182 case suback_reason_code::not_authorized:
return "not_authorized";
183 case suback_reason_code::topic_filter_invalid:
return "topic_filter_invalid";
184 case suback_reason_code::packet_identifier_in_use:
return "packet_identifier_in_use";
185 case suback_reason_code::quota_exceeded:
return "quota_exceeded";
186 case suback_reason_code::shared_subscriptions_not_supported:
return "shared_subscriptions_not_supported";
187 case suback_reason_code::subscription_identifiers_not_supported:
return "subscription_identifiers_not_supported";
188 case suback_reason_code::wildcard_subscriptions_not_supported:
return "wildcard_subscriptions_not_supported";
189 default:
return "unknown_suback_reason_code";
194std::ostream& operator<<(std::ostream& os, suback_reason_code val)
196 os << suback_reason_code_to_str(val);
200constexpr suback_reason_code qos_to_suback_reason_code(qos q) {
201 return static_cast<suback_reason_code
>(q);
204enum class unsuback_reason_code : std::uint8_t {
206 no_subscription_existed = 0x11,
207 unspecified_error = 0x80,
208 implementation_specific_error = 0x83,
209 not_authorized = 0x87,
210 topic_filter_invalid = 0x8f,
211 packet_identifier_in_use = 0x91,
215char const* unsuback_reason_code_to_str(unsuback_reason_code v) {
218 case unsuback_reason_code::success:
return "success";
219 case unsuback_reason_code::no_subscription_existed:
return "no_subscription_existed";
220 case unsuback_reason_code::unspecified_error:
return "unspecified_error";
221 case unsuback_reason_code::implementation_specific_error:
return "implementation_specific_error";
222 case unsuback_reason_code::not_authorized:
return "not_authorized";
223 case unsuback_reason_code::topic_filter_invalid:
return "topic_filter_invalid";
224 case unsuback_reason_code::packet_identifier_in_use:
return "packet_identifier_in_use";
225 default:
return "unknown_unsuback_reason_code";
230std::ostream& operator<<(std::ostream& os, unsuback_reason_code val)
232 os << unsuback_reason_code_to_str(val);
236enum class puback_reason_code : std::uint8_t {
238 no_matching_subscribers = 0x10,
239 unspecified_error = 0x80,
240 implementation_specific_error = 0x83,
241 not_authorized = 0x87,
242 topic_name_invalid = 0x90,
243 packet_identifier_in_use = 0x91,
244 quota_exceeded = 0x97,
245 payload_format_invalid = 0x99,
249char const* puback_reason_code_to_str(puback_reason_code v) {
252 case puback_reason_code::success:
return "success";
253 case puback_reason_code::no_matching_subscribers:
return "no_matching_subscribers";
254 case puback_reason_code::unspecified_error:
return "unspecified_error";
255 case puback_reason_code::implementation_specific_error:
return "implementation_specific_error";
256 case puback_reason_code::not_authorized:
return "not_authorized";
257 case puback_reason_code::topic_name_invalid:
return "topic_name_invalid";
258 case puback_reason_code::packet_identifier_in_use:
return "packet_identifier_in_use";
259 case puback_reason_code::quota_exceeded:
return "quota_exceeded";
260 case puback_reason_code::payload_format_invalid:
return "payload_format_invalid";
261 default:
return "unknown_puback_reason_code";
266bool is_error(puback_reason_code v) {
267 return static_cast<std::uint8_t
>(v) >= 0x80;
271std::ostream& operator<<(std::ostream& os, puback_reason_code val)
273 os << puback_reason_code_to_str(val);
277enum class pubrec_reason_code : std::uint8_t {
279 no_matching_subscribers = 0x10,
280 unspecified_error = 0x80,
281 implementation_specific_error = 0x83,
282 not_authorized = 0x87,
283 topic_name_invalid = 0x90,
284 packet_identifier_in_use = 0x91,
285 quota_exceeded = 0x97,
286 payload_format_invalid = 0x99,
290char const* pubrec_reason_code_to_str(pubrec_reason_code v) {
293 case pubrec_reason_code::success:
return "success";
294 case pubrec_reason_code::no_matching_subscribers:
return "no_matching_subscribers";
295 case pubrec_reason_code::unspecified_error:
return "unspecified_error";
296 case pubrec_reason_code::implementation_specific_error:
return "implementation_specific_error";
297 case pubrec_reason_code::not_authorized:
return "not_authorized";
298 case pubrec_reason_code::topic_name_invalid:
return "topic_name_invalid";
299 case pubrec_reason_code::packet_identifier_in_use:
return "packet_identifier_in_use";
300 case pubrec_reason_code::quota_exceeded:
return "quota_exceeded";
301 case pubrec_reason_code::payload_format_invalid:
return "payload_format_invalid";
302 default:
return "unknown_pubrec_reason_code";
307bool is_error(pubrec_reason_code v) {
308 return static_cast<std::uint8_t
>(v) >= 0x80;
312std::ostream& operator<<(std::ostream& os, pubrec_reason_code val)
314 os << pubrec_reason_code_to_str(val);
318enum class pubrel_reason_code : std::uint8_t {
320 packet_identifier_not_found = 0x92,
324char const* pubrel_reason_code_to_str(pubrel_reason_code v) {
327 case pubrel_reason_code::success:
return "success";
328 case pubrel_reason_code::packet_identifier_not_found:
return "packet_identifier_not_found";
329 default:
return "unknown_pubrel_reason_code";
334std::ostream& operator<<(std::ostream& os, pubrel_reason_code val)
336 os << pubrel_reason_code_to_str(val);
340enum class pubcomp_reason_code : std::uint8_t {
342 packet_identifier_not_found = 0x92,
346char const* pubcomp_reason_code_to_str(pubcomp_reason_code v) {
349 case pubcomp_reason_code::success:
return "success";
350 case pubcomp_reason_code::packet_identifier_not_found:
return "packet_identifier_not_found";
351 default:
return "unknown_pubcomp_reason_code";
356std::ostream& operator<<(std::ostream& os, pubcomp_reason_code val)
358 os << pubcomp_reason_code_to_str(val);
362enum class auth_reason_code : std::uint8_t {
364 continue_authentication = 0x18,
365 re_authenticate = 0x19,
369char const* auth_reason_code_to_str(auth_reason_code v) {
372 case auth_reason_code::success:
return "success";
373 case auth_reason_code::continue_authentication:
return "continue_authentication";
374 case auth_reason_code::re_authenticate:
return "re_authenticate";
375 default:
return "unknown_auth_reason_code";
380std::ostream& operator<<(std::ostream& os, auth_reason_code val)
382 os << auth_reason_code_to_str(val);