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 committed Jul 28, 2023
1 parent be4e665 commit 22ccf99
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 132 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}
)

162 changes: 81 additions & 81 deletions MQTTPacket/samples/v5log.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,87 +142,87 @@ const char* v5reasoncode_to_string(enum ReasonCodes reasoncode)
{
switch (reasoncode)
{
case SUCCESS:
return "SUCCESS";
case NO_MATCHING_SUBSCRIBERS:
return "NO_MATCHING_SUBSCRIBERS";
case NO_SUBSCRIPTION_FOUND:
return "NO_SUBSCRIPTION_FOUND";
case CONTINUE_AUTHENTICATION:
return "CONTINUE_AUTHENTICATION";
case RE_AUTHENTICATE:
return "RE_AUTHENTICATE";
case UNSPECIFIED_ERROR:
return "UNSPECIFIED_ERROR";
case MALFORMED_PACKET:
return "MALFORMED_PACKET";
case PROTOCOL_ERROR:
return "PROTOCOL_ERROR";
case IMPLEMENTATION_SPECIFIC_ERROR:
return "IMPLEMENTATION_SPECIFIC_ERROR";
case UNSUPPORTED_PROTOCOL_VERSION:
return "UNSUPPORTED_PROTOCOL_VERSION";
case CLIENT_IDENTIFIER_NOT_VALID:
return "CLIENT_IDENTIFIER_NOT_VALID";
case BAD_USER_NAME_OR_PASSWORD:
return "BAD_USER_NAME_OR_PASSWORD";
case NOT_AUTHORIZED:
return "NOT_AUTHORIZED";
case SERVER_UNAVAILABLE:
return "SERVER_UNAVAILABLE";
case SERVER_BUSY:
return "SERVER_BUSY";
case BANNED:
return "BANNED";
case SERVER_SHUTTING_DOWN:
return "SERVER_SHUTTING_DOWN";
case BAD_AUTHENTICATION_METHOD:
return "BAD_AUTHENTICATION_METHOD";
case KEEP_ALIVE_TIMEOUT:
return "KEEP_ALIVE_TIMEOUT";
case SESSION_TAKEN_OVER:
return "SESSION_TAKEN_OVER";
case TOPIC_FILTER_INVALID:
return "TOPIC_FILTER_INVALID";
case TOPIC_NAME_INVALID:
return "TOPIC_NAME_INVALID";
case PACKET_IDENTIFIER_IN_USE:
return "PACKET_IDENTIFIER_IN_USE";
case PACKET_IDENTIFIER_NOT_FOUND:
return "PACKET_IDENTIFIER_NOT_FOUND";
case RECEIVE_MAXIMUM_EXCEEDED:
return "RECEIVE_MAXIMUM_EXCEEDED";
case TOPIC_ALIAS_INVALID:
return "TOPIC_ALIAS_INVALID";
case PACKET_TOO_LARGE:
return "PACKET_TOO_LARGE";
case MESSAGE_RATE_TOO_HIGH:
return "MESSAGE_RATE_TOO_HIGH";
case QUOTA_EXCEEDED:
return "QUOTA_EXCEEDED";
case ADMINISTRATIVE_ACTION:
return "ADMINISTRATIVE_ACTION";
case PAYLOAD_FORMAT_INVALID:
return "PAYLOAD_FORMAT_INVALID";
case RETAIN_NOT_SUPPORTED:
return "RETAIN_NOT_SUPPORTED";
case QOS_NOT_SUPPORTED:
return "QOS_NOT_SUPPORTED";
case USE_ANOTHER_SERVER:
return "USE_ANOTHER_SERVER";
case SERVER_MOVED:
return "SERVER_MOVED";
case SHARED_SUBSCRIPTION_NOT_SUPPORTED:
return "SHARED_SUBSCRIPTION_NOT_SUPPORTED";
case CONNECTION_RATE_EXCEEDED:
return "CONNECTION_RATE_EXCEEDED";
case MAXIMUM_CONNECT_TIME:
return "MAXIMUM_CONNECT_TIME";
case SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED:
return "SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED";
case WILDCARD_SUBSCRIPTION_NOT_SUPPORTED:
return "WILDCARD_SUBSCRIPTION_NOT_SUPPORTED";
case MQTTV5_SUCCESS:
return "MQTTV5_SUCCESS";
case MQTTV5_NO_MATCHING_SUBSCRIBERS:
return "MQTTV5_NO_MATCHING_SUBSCRIBERS";
case MQTTV5_NO_SUBSCRIPTION_FOUND:
return "MQTTV5_NO_SUBSCRIPTION_FOUND";
case MQTTV5_CONTINUE_AUTHENTICATION:
return "MQTTV5_CONTINUE_AUTHENTICATION";
case MQTTV5_RE_AUTHENTICATE:
return "MQTTV5_RE_AUTHENTICATE";
case MQTTV5_UNSPECIFIED_ERROR:
return "MQTTV5_UNSPECIFIED_ERROR";
case MQTTV5_MALFORMED_PACKET:
return "MQTTV5_MALFORMED_PACKET";
case MQTTV5_PROTOCOL_ERROR:
return "MQTTV5_PROTOCOL_ERROR";
case MQTTV5_IMPLEMENTATION_SPECIFIC_ERROR:
return "MQTTV5_IMPLEMENTATION_SPECIFIC_ERROR";
case MQTTV5_UNSUPPORTED_PROTOCOL_VERSION:
return "MQTTV5_UNSUPPORTED_PROTOCOL_VERSION";
case MQTTV5_CLIENT_IDENTIFIER_NOT_VALID:
return "MQTTV5_CLIENT_IDENTIFIER_NOT_VALID";
case MQTTV5_BAD_USER_NAME_OR_PASSWORD:
return "MQTTV5_BAD_USER_NAME_OR_PASSWORD";
case MQTTV5_NOT_AUTHORIZED:
return "MQTTV5_NOT_AUTHORIZED";
case MQTTV5_SERVER_UNAVAILABLE:
return "MQTTV5_SERVER_UNAVAILABLE";
case MQTTV5_SERVER_BUSY:
return "MQTTV5_SERVER_BUSY";
case MQTTV5_BANNED:
return "MQTTV5_BANNED";
case MQTTV5_SERVER_SHUTTING_DOWN:
return "MQTTV5_SERVER_SHUTTING_DOWN";
case MQTTV5_BAD_AUTHENTICATION_METHOD:
return "MQTTV5_BAD_AUTHENTICATION_METHOD";
case MQTTV5_KEEP_ALIVE_TIMEOUT:
return "MQTTV5_KEEP_ALIVE_TIMEOUT";
case MQTTV5_SESSION_TAKEN_OVER:
return "MQTTV5_SESSION_TAKEN_OVER";
case MQTTV5_TOPIC_FILTER_INVALID:
return "MQTTV5_TOPIC_FILTER_INVALID";
case MQTTV5_TOPIC_NAME_INVALID:
return "MQTTV5_TOPIC_NAME_INVALID";
case MQTTV5_PACKET_IDENTIFIER_IN_USE:
return "MQTTV5_PACKET_IDENTIFIER_IN_USE";
case MQTTV5_PACKET_IDENTIFIER_NOT_FOUND:
return "MQTTV5_PACKET_IDENTIFIER_NOT_FOUND";
case MQTTV5_RECEIVE_MAXIMUM_EXCEEDED:
return "MQTTV5_RECEIVE_MAXIMUM_EXCEEDED";
case MQTTV5_TOPIC_ALIAS_INVALID:
return "MQTTV5_TOPIC_ALIAS_INVALID";
case MQTTV5_PACKET_TOO_LARGE:
return "MQTTV5_PACKET_TOO_LARGE";
case MQTTV5_MESSAGE_RATE_TOO_HIGH:
return "MQTTV5_MESSAGE_RATE_TOO_HIGH";
case MQTTV5_QUOTA_EXCEEDED:
return "MQTTV5_QUOTA_EXCEEDED";
case MQTTV5_ADMINISTRATIVE_ACTION:
return "MQTTV5_ADMINISTRATIVE_ACTION";
case MQTTV5_PAYLOAD_FORMAT_INVALID:
return "MQTTV5_PAYLOAD_FORMAT_INVALID";
case MQTTV5_RETAIN_NOT_SUPPORTED:
return "MQTTV5_RETAIN_NOT_SUPPORTED";
case MQTTV5_QOS_NOT_SUPPORTED:
return "MQTTV5_QOS_NOT_SUPPORTED";
case MQTTV5_USE_ANOTHER_SERVER:
return "MQTTV5_USE_ANOTHER_SERVER";
case MQTTV5_SERVER_MOVED:
return "MQTTV5_SERVER_MOVED";
case MQTTV5_SHARED_SUBSCRIPTION_NOT_SUPPORTED:
return "MQTTV5_SHARED_SUBSCRIPTION_NOT_SUPPORTED";
case MQTTV5_CONNECTION_RATE_EXCEEDED:
return "MQTTV5_CONNECTION_RATE_EXCEEDED";
case MQTTV5_MAXIMUM_CONNECT_TIME:
return "MQTTV5_MAXIMUM_CONNECT_TIME";
case MQTTV5_SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED:
return "MQTTV5_SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED";
case MQTTV5_WILDCARD_SUBSCRIPTION_NOT_SUPPORTED:
return "MQTTV5_WILDCARD_SUBSCRIPTION_NOT_SUPPORTED";
default:
return "UNKNOWN";
return "MQTTV5_UNKNOWN";
}
}
2 changes: 1 addition & 1 deletion MQTTPacket/samples/v5ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int main(int argc, char *argv[])
printf("disconnecting\n");

MQTTProperties disconn_properties = MQTTProperties_initializer;
len = MQTTV5Serialize_disconnect(buf, buflen, NORMAL_DISCONNECTION, &disconn_properties);
len = MQTTV5Serialize_disconnect(buf, buflen, MQTTV5_NORMAL_DISCONNECTION, &disconn_properties);

rc = transport_sendPacketBuffer(mysock, buf, len);

Expand Down
2 changes: 1 addition & 1 deletion MQTTPacket/samples/v5ping_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int main(int argc, char *argv[])
printf("disconnecting\n");

MQTTProperties disconn_properties = MQTTProperties_initializer;
len = MQTTV5Serialize_disconnect(buf, buflen, NORMAL_DISCONNECTION, &disconn_properties);
len = MQTTV5Serialize_disconnect(buf, buflen, MQTTV5_NORMAL_DISCONNECTION, &disconn_properties);

rc = transport_sendPacketBuffer(mysock, buf, len);

Expand Down
2 changes: 1 addition & 1 deletion MQTTPacket/samples/v5qos0pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char *argv[])
len += MQTTV5Serialize_publish((unsigned char *)(buf + len), buflen - len, 0, 1, 0, 123, topicString, &pub_properties, (unsigned char *)payload, payloadlen);

MQTTProperties disconnect_properties = MQTTProperties_initializer;
len += MQTTV5Serialize_disconnect((unsigned char *)(buf + len), buflen - len, NORMAL_DISCONNECTION, &disconnect_properties);
len += MQTTV5Serialize_disconnect((unsigned char *)(buf + len), buflen - len, MQTTV5_NORMAL_DISCONNECTION, &disconnect_properties);

rc = transport_sendPacketBuffer(mysock, (unsigned char*)buf, len);
if (rc == len)
Expand Down
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
};
16 changes: 16 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 @@ -39,6 +43,10 @@ ADD_EXECUTABLE(
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
Expand All @@ -64,6 +72,10 @@ TARGET_LINK_LIBRARIES(
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}
Expand All @@ -80,6 +92,10 @@ ADD_EXECUTABLE(
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
Expand Down
6 changes: 3 additions & 3 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;
unsigned char 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,7 +893,7 @@ int test9(struct Options options)
int rc = 0;
unsigned char buf[100];
int buflen = sizeof(buf);
unsigned char reasonCode = BAD_AUTHENTICATION_METHOD; // (140) test signed char to unsigned char conversion.
unsigned char reasonCode = MQTTV5_BAD_AUTHENTICATION_METHOD; // (140) test signed char to unsigned char conversion.
unsigned char reasonCode2 = 44;

MQTTProperties properties = MQTTProperties_initializer;
Expand Down

0 comments on commit 22ccf99

Please sign in to comment.