reason_code.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /////////////////////////////////////////////////////////////////////////////
  2. /// @file reason_code.h
  3. ///
  4. /// MQTT v5 reason codes for the Paho MQTT C++ library.
  5. ///
  6. /// @date July 5, 2024
  7. /// @author Frank Pagliughi
  8. /////////////////////////////////////////////////////////////////////////////
  9. /*******************************************************************************
  10. * Copyright (c) 2024 Frank Pagliughi <fpagliughi@mindspring.com>
  11. *
  12. * All rights reserved. This program and the accompanying materials
  13. * are made available under the terms of the Eclipse Public License v2.0
  14. * and Eclipse Distribution License v1.0 which accompany this distribution.
  15. *
  16. * The Eclipse Public License is available at
  17. * http://www.eclipse.org/legal/epl-v20.html
  18. * and the Eclipse Distribution License is available at
  19. * http://www.eclipse.org/org/documents/edl-v10.php.
  20. *
  21. * Contributors:
  22. * Frank Pagliughi - initial implementation and documentation
  23. *******************************************************************************/
  24. #ifndef __reason_code_h
  25. #define __reason_code_h
  26. #include <iostream>
  27. #include <string>
  28. namespace mqtt {
  29. /////////////////////////////////////////////////////////////////////////////
  30. /**
  31. * The MQTT v5 Reason Codes.
  32. */
  33. enum ReasonCode {
  34. SUCCESS = 0,
  35. NORMAL_DISCONNECTION = 0,
  36. GRANTED_QOS_0 = 0,
  37. GRANTED_QOS_1 = 1,
  38. GRANTED_QOS_2 = 2,
  39. DISCONNECT_WITH_WILL_MESSAGE = 4,
  40. NO_MATCHING_SUBSCRIBERS = 16,
  41. NO_SUBSCRIPTION_FOUND = 17,
  42. CONTINUE_AUTHENTICATION = 24,
  43. RE_AUTHENTICATE = 25,
  44. UNSPECIFIED_ERROR = 128,
  45. MALFORMED_PACKET = 129,
  46. PROTOCOL_ERROR = 130,
  47. IMPLEMENTATION_SPECIFIC_ERROR = 131,
  48. UNSUPPORTED_PROTOCOL_VERSION = 132,
  49. CLIENT_IDENTIFIER_NOT_VALID = 133,
  50. BAD_USER_NAME_OR_PASSWORD = 134,
  51. NOT_AUTHORIZED = 135,
  52. SERVER_UNAVAILABLE = 136,
  53. SERVER_BUSY = 137,
  54. BANNED = 138,
  55. SERVER_SHUTTING_DOWN = 139,
  56. BAD_AUTHENTICATION_METHOD = 140,
  57. KEEP_ALIVE_TIMEOUT = 141,
  58. SESSION_TAKEN_OVER = 142,
  59. TOPIC_FILTER_INVALID = 143,
  60. TOPIC_NAME_INVALID = 144,
  61. PACKET_IDENTIFIER_IN_USE = 145,
  62. PACKET_IDENTIFIER_NOT_FOUND = 146,
  63. RECEIVE_MAXIMUM_EXCEEDED = 147,
  64. TOPIC_ALIAS_INVALID = 148,
  65. PACKET_TOO_LARGE = 149,
  66. MESSAGE_RATE_TOO_HIGH = 150,
  67. QUOTA_EXCEEDED = 151,
  68. ADMINISTRATIVE_ACTION = 152,
  69. PAYLOAD_FORMAT_INVALID = 153,
  70. RETAIN_NOT_SUPPORTED = 154,
  71. QOS_NOT_SUPPORTED = 155,
  72. USE_ANOTHER_SERVER = 156,
  73. SERVER_MOVED = 157,
  74. SHARED_SUBSCRIPTIONS_NOT_SUPPORTED = 158,
  75. CONNECTION_RATE_EXCEEDED = 159,
  76. MAXIMUM_CONNECT_TIME = 160,
  77. SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED = 161,
  78. WILDCARD_SUBSCRIPTIONS_NOT_SUPPORTED = 162,
  79. // This is not a protocol code; used internally by the library (obsolete)
  80. MQTTPP_V3_CODE = 0
  81. };
  82. /**
  83. * Get the string representation of the reason code.
  84. *
  85. * @param reasonCode An MQTT v5 reason code.
  86. * @return The string representation of the reason code.
  87. */
  88. std::string to_string(ReasonCode reasonCode);
  89. /**
  90. * ostream inserter for reason codes
  91. *
  92. * @param os The output stream
  93. * @param reasonCode The reason code.
  94. *
  95. * @return Reference to the output stream
  96. */
  97. std::ostream& operator<<(std::ostream& os, ReasonCode reasonCode);
  98. /////////////////////////////////////////////////////////////////////////////
  99. } // namespace mqtt
  100. #endif // __reason_code_h