Skip to content

Commit

Permalink
Renaming V5 reason code public API to avoid collisions. Disabling dep…
Browse files Browse the repository at this point in the history
…recation warnings for tests to avoid build warnings.
  • Loading branch information
CIPop authored and Jacob Brunson committed Oct 25, 2024
1 parent cfbfa12 commit bbcc716
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 49 deletions.
4 changes: 4 additions & 0 deletions MQTTClient-C/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ ADD_TEST(
NAME testc1
COMMAND "testc1" "--host" ${MQTT_TEST_BROKER_HOST}
)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(testc1 PRIVATE -Wno-deprecated-declarations)
5 changes: 5 additions & 0 deletions MQTTClient/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ target_compile_definitions(testcpp1 PRIVATE MQTTCLIENT_QOS1=1 MQTTCLIENT_QOS2=1)
target_include_directories(testcpp1 PRIVATE "../src" "../src/linux")
target_link_libraries(testcpp1 MQTTPacketClient MQTTPacketServer)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(testcpp1 PRIVATE -Wno-deprecated-declarations)

ADD_TEST(
NAME testcpp1
COMMAND "testcpp1" "--host" ${MQTT_TEST_BROKER_HOST}
)

90 changes: 45 additions & 45 deletions MQTTPacket/src/V5/MQTTReasonCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,49 @@
*******************************************************************************/

enum ReasonCodes {
SUCCESS = 0,
NORMAL_DISCONNECTION = 0,
GRANTED_QOS_0 = 0,
GRANTED_QOS_1 = 1,
GRANTED_QOS_2 = 2,
DISCONNECT_WITH_WILL_MESSAGE = 4,
NO_MATCHING_SUBSCRIBERS = 16,
NO_SUBSCRIPTION_FOUND = 17,
CONTINUE_AUTHENTICATION = 24,
RE_AUTHENTICATE = 25,
UNSPECIFIED_ERROR = 128,
MALFORMED_PACKET = 129,
PROTOCOL_ERROR = 130,
IMPLEMENTATION_SPECIFIC_ERROR = 131,
UNSUPPORTED_PROTOCOL_VERSION = 132,
CLIENT_IDENTIFIER_NOT_VALID = 133,
BAD_USER_NAME_OR_PASSWORD = 134,
NOT_AUTHORIZED = 135,
SERVER_UNAVAILABLE = 136,
SERVER_BUSY = 137,
BANNED = 138,
SERVER_SHUTTING_DOWN = 139,
BAD_AUTHENTICATION_METHOD = 140,
KEEP_ALIVE_TIMEOUT = 141,
SESSION_TAKEN_OVER = 142,
TOPIC_FILTER_INVALID = 143,
TOPIC_NAME_INVALID = 144,
PACKET_IDENTIFIER_IN_USE = 145,
PACKET_IDENTIFIER_NOT_FOUND = 146,
RECEIVE_MAXIMUM_EXCEEDED = 147,
TOPIC_ALIAS_INVALID = 148,
PACKET_TOO_LARGE = 149,
MESSAGE_RATE_TOO_HIGH = 150,
QUOTA_EXCEEDED = 151,
ADMINISTRATIVE_ACTION = 152,
PAYLOAD_FORMAT_INVALID = 153,
RETAIN_NOT_SUPPORTED = 154,
QOS_NOT_SUPPORTED = 155,
USE_ANOTHER_SERVER = 156,
SERVER_MOVED = 157,
SHARED_SUBSCRIPTION_NOT_SUPPORTED = 158,
CONNECTION_RATE_EXCEEDED = 159,
MAXIMUM_CONNECT_TIME = 160,
SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED = 161,
WILDCARD_SUBSCRIPTION_NOT_SUPPORTED = 162
MQTTV5_SUCCESS = 0,
MQTTV5_NORMAL_DISCONNECTION = 0,
MQTTV5_GRANTED_QOS_0 = 0,
MQTTV5_GRANTED_QOS_1 = 1,
MQTTV5_GRANTED_QOS_2 = 2,
MQTTV5_DISCONNECT_WITH_WILL_MESSAGE = 4,
MQTTV5_NO_MATCHING_SUBSCRIBERS = 16,
MQTTV5_NO_SUBSCRIPTION_FOUND = 17,
MQTTV5_CONTINUE_AUTHENTICATION = 24,
MQTTV5_RE_AUTHENTICATE = 25,
MQTTV5_UNSPECIFIED_ERROR = 128,
MQTTV5_MALFORMED_PACKET = 129,
MQTTV5_PROTOCOL_ERROR = 130,
MQTTV5_IMPLEMENTATION_SPECIFIC_ERROR = 131,
MQTTV5_UNSUPPORTED_PROTOCOL_VERSION = 132,
MQTTV5_CLIENT_IDENTIFIER_NOT_VALID = 133,
MQTTV5_BAD_USER_NAME_OR_PASSWORD = 134,
MQTTV5_NOT_AUTHORIZED = 135,
MQTTV5_SERVER_UNAVAILABLE = 136,
MQTTV5_SERVER_BUSY = 137,
MQTTV5_BANNED = 138,
MQTTV5_SERVER_SHUTTING_DOWN = 139,
MQTTV5_BAD_AUTHENTICATION_METHOD = 140,
MQTTV5_KEEP_ALIVE_TIMEOUT = 141,
MQTTV5_SESSION_TAKEN_OVER = 142,
MQTTV5_TOPIC_FILTER_INVALID = 143,
MQTTV5_TOPIC_NAME_INVALID = 144,
MQTTV5_PACKET_IDENTIFIER_IN_USE = 145,
MQTTV5_PACKET_IDENTIFIER_NOT_FOUND = 146,
MQTTV5_RECEIVE_MAXIMUM_EXCEEDED = 147,
MQTTV5_TOPIC_ALIAS_INVALID = 148,
MQTTV5_PACKET_TOO_LARGE = 149,
MQTTV5_MESSAGE_RATE_TOO_HIGH = 150,
MQTTV5_QUOTA_EXCEEDED = 151,
MQTTV5_ADMINISTRATIVE_ACTION = 152,
MQTTV5_PAYLOAD_FORMAT_INVALID = 153,
MQTTV5_RETAIN_NOT_SUPPORTED = 154,
MQTTV5_QOS_NOT_SUPPORTED = 155,
MQTTV5_USE_ANOTHER_SERVER = 156,
MQTTV5_SERVER_MOVED = 157,
MQTTV5_SHARED_SUBSCRIPTION_NOT_SUPPORTED = 158,
MQTTV5_CONNECTION_RATE_EXCEEDED = 159,
MQTTV5_MAXIMUM_CONNECT_TIME = 160,
MQTTV5_SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED = 161,
MQTTV5_WILDCARD_SUBSCRIPTION_NOT_SUPPORTED = 162
};
77 changes: 77 additions & 0 deletions MQTTPacket/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ ADD_EXECUTABLE(
test1.c
)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(test1 PRIVATE -Wno-deprecated-declarations)

TARGET_LINK_LIBRARIES(
test1
paho-embed-mqtt3c
Expand All @@ -33,3 +37,76 @@ SET_TESTS_PROPERTIES(
test1
PROPERTIES TIMEOUT 540
)

ADD_EXECUTABLE(
test15
test1.c
)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(test15 PRIVATE -Wno-deprecated-declarations)

TARGET_LINK_LIBRARIES(
test15
paho-embed-mqtt5c
)

ADD_TEST(
NAME test15
COMMAND "test15" "--connection" ${MQTT_TEST_BROKER}
)

SET_TESTS_PROPERTIES(
test15
PROPERTIES TIMEOUT 540
)

ADD_EXECUTABLE(
test2
test2.c
)

TARGET_LINK_LIBRARIES(
test2
paho-embed-mqtt5c
)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(test2 PRIVATE -Wno-deprecated-declarations)

ADD_TEST(
NAME test2
COMMAND "test2" "--connection" ${MQTT_TEST_BROKER}
)

SET_TESTS_PROPERTIES(
test2
PROPERTIES TIMEOUT 540
)


ADD_EXECUTABLE(
test3
test3.c
)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(test3 PRIVATE -Wno-deprecated-declarations)

TARGET_LINK_LIBRARIES(
test3
paho-embed-mqtt5c
)

ADD_TEST(
NAME test3
COMMAND "test3" "--connection" ${MQTT_TEST_BROKER}
)

SET_TESTS_PROPERTIES(
test3
PROPERTIES TIMEOUT 540
)
8 changes: 4 additions & 4 deletions MQTTPacket/test/test2.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ int test7(struct Options options)
one.identifier = SESSION_EXPIRY_INTERVAL;
one.value.integer4 = 45;
rc = MQTTProperties_add(&disconnectProperties, &one);
reasonCode = TOPIC_ALIAS_INVALID; // (148) test signed char to unsigned char conversion.
reasonCode = MQTTV5_TOPIC_ALIAS_INVALID; // (148) test signed char to unsigned char conversion.

rc = MQTTV5Serialize_disconnect(buf, buflen, reasonCode, &disconnectProperties);
assert("good rc from serialize disconnect", rc > 0, "rc was %d\n", rc);
Expand Down Expand Up @@ -834,7 +834,7 @@ int test8(struct Options options)
int count = TOPIC_COUNT;
int reasonCodes[TOPIC_COUNT] = {
2,
QOS_NOT_SUPPORTED // (155) test signed char to unsigned char conversion.
MQTTV5_QOS_NOT_SUPPORTED // (155) test signed char to unsigned char conversion.
};

unsigned short msgid2 = 2223;
Expand Down Expand Up @@ -893,8 +893,8 @@ int test9(struct Options options)
int rc = 0;
unsigned char buf[100];
int buflen = sizeof(buf);
int reasonCode = BAD_AUTHENTICATION_METHOD; // // (140) test signed char to unsigned char conversion.
int reasonCode2 = 44;
unsigned char reasonCode = MQTTV5_BAD_AUTHENTICATION_METHOD; // (140) test signed char to unsigned char conversion.
unsigned char reasonCode2 = 44;

MQTTProperties properties = MQTTProperties_initializer;
MQTTProperties outProperties = MQTTProperties_initializer;
Expand Down

0 comments on commit bbcc716

Please sign in to comment.