Skip to content

Commit

Permalink
update enum
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Nov 25, 2023
1 parent d118c61 commit 7def6d1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
16 changes: 8 additions & 8 deletions bin/mqtt5_canary/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static int s_AwsMqtt5CanaryOperationUnsubscribeBad(struct AwsMqtt5CanaryTestClie
unsubscription, [testClient](int, std::shared_ptr<Mqtt5::UnSubAckPacket> packet) {
if (packet == nullptr)
return;
if (packet->getReasonCodes()[0] == AWS_MQTT5_UARC_SUCCESS)
if (packet->getReasonCodes()[0] == UnSubAckReasonCode::AWS_MQTT5_UARC_SUCCESS)
{
AWS_LOGF_ERROR(
AWS_LS_MQTT5_CANARY,
Expand Down Expand Up @@ -558,7 +558,7 @@ static int s_AwsMqtt5CanaryOperationPublishQos0(struct AwsMqtt5CanaryTestClient

Aws::Crt::String topic = "topic1";
AWS_LOGF_INFO(AWS_LS_MQTT5_CANARY, "ID:%s Publish qos0", testClient->clientId.c_str());
return s_AwsMqtt5CanaryOperationPublish(testClient, topic, AWS_MQTT5_QOS_AT_MOST_ONCE, allocator);
return s_AwsMqtt5CanaryOperationPublish(testClient, topic, QOS::AWS_MQTT5_QOS_AT_MOST_ONCE, allocator);
}

static int s_AwsMqtt5CanaryOperationPublishQos1(struct AwsMqtt5CanaryTestClient *testClient, Allocator *allocator)
Expand All @@ -569,7 +569,7 @@ static int s_AwsMqtt5CanaryOperationPublishQos1(struct AwsMqtt5CanaryTestClient
}
Aws::Crt::String topic = "topic1";
AWS_LOGF_INFO(AWS_LS_MQTT5_CANARY, "ID:%s Publish qos1", testClient->clientId.c_str());
return s_AwsMqtt5CanaryOperationPublish(testClient, topic, AWS_MQTT5_QOS_AT_LEAST_ONCE, allocator);
return s_AwsMqtt5CanaryOperationPublish(testClient, topic, QOS::AWS_MQTT5_QOS_AT_LEAST_ONCE, allocator);
}

static int s_AwsMqtt5CanaryOperationPublishToSubscribedTopicQos0(
Expand All @@ -591,7 +591,7 @@ static int s_AwsMqtt5CanaryOperationPublishToSubscribedTopicQos0(

AWS_LOGF_INFO(
AWS_LS_MQTT5_CANARY, "ID:%s Publish qos 0 to subscribed topic: %s", testClient->clientId.c_str(), topicArray);
return s_AwsMqtt5CanaryOperationPublish(testClient, topicArray, AWS_MQTT5_QOS_AT_MOST_ONCE, allocator);
return s_AwsMqtt5CanaryOperationPublish(testClient, topicArray, QOS::AWS_MQTT5_QOS_AT_MOST_ONCE, allocator);
}

static int s_AwsMqtt5CanaryOperationPublishToSubscribedTopicQos1(
Expand All @@ -614,7 +614,7 @@ static int s_AwsMqtt5CanaryOperationPublishToSubscribedTopicQos1(

AWS_LOGF_INFO(
AWS_LS_MQTT5_CANARY, "ID:%s Publish qos 1 to subscribed topic: %s", testClient->clientId.c_str(), topicArray);
return s_AwsMqtt5CanaryOperationPublish(testClient, topicArray, AWS_MQTT5_QOS_AT_LEAST_ONCE, allocator);
return s_AwsMqtt5CanaryOperationPublish(testClient, topicArray, QOS::AWS_MQTT5_QOS_AT_LEAST_ONCE, allocator);
}

static int s_AwsMqtt5CanaryOperationPublishToSharedTopicQos0(
Expand All @@ -630,7 +630,7 @@ static int s_AwsMqtt5CanaryOperationPublishToSharedTopicQos0(
"ID:%s Publish qos 0 to shared topic: %s",
testClient->clientId.c_str(),
testClient->sharedTopic.c_str());
return s_AwsMqtt5CanaryOperationPublish(testClient, testClient->sharedTopic, AWS_MQTT5_QOS_AT_MOST_ONCE, allocator);
return s_AwsMqtt5CanaryOperationPublish(testClient, testClient->sharedTopic, QOS::AWS_MQTT5_QOS_AT_MOST_ONCE, allocator);
}

static int s_AwsMqtt5CanaryOperationPublishToSharedTopicQos1(
Expand All @@ -647,7 +647,7 @@ static int s_AwsMqtt5CanaryOperationPublishToSharedTopicQos1(
testClient->clientId.c_str(),
testClient->sharedTopic.c_str());
return s_AwsMqtt5CanaryOperationPublish(
testClient, testClient->sharedTopic, AWS_MQTT5_QOS_AT_LEAST_ONCE, allocator);
testClient, testClient->sharedTopic, QOS::AWS_MQTT5_QOS_AT_LEAST_ONCE, allocator);
}

static struct AwsMqtt5CanaryOperationsFunctionTable s_AwsMqtt5CanaryOperationTable = {{
Expand Down Expand Up @@ -828,7 +828,7 @@ int main(int argc, char **argv)
.WithSocketOptions(socketOptions)
.WithBootstrap(&clientBootstrap)
.WithPingTimeoutMs(10000)
.WithReconnectOptions({AWS_EXPONENTIAL_BACKOFF_JITTER_NONE, 1000, 120000, 3000});
.WithReconnectOptions({JitterMode::AWS_EXPONENTIAL_BACKOFF_JITTER_NONE, 1000, 120000, 3000});

if (appCtx.use_tls)
{
Expand Down
14 changes: 7 additions & 7 deletions source/mqtt/Mqtt5Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ namespace Aws
*/
Mqtt5ClientOptions::Mqtt5ClientOptions(Crt::Allocator *allocator) noexcept
: m_bootstrap(nullptr), m_sessionBehavior(ClientSessionBehaviorType::AWS_MQTT5_CSBT_DEFAULT),
m_extendedValidationAndFlowControlOptions(AWS_MQTT5_EVAFCO_AWS_IOT_CORE_DEFAULTS),
m_offlineQueueBehavior(AWS_MQTT5_COQBT_DEFAULT),
m_reconnectionOptions({AWS_EXPONENTIAL_BACKOFF_JITTER_DEFAULT, 0, 0, 0}), m_pingTimeoutMs(0),
m_extendedValidationAndFlowControlOptions(ClientExtendedValidationAndFlowControl::AWS_MQTT5_EVAFCO_AWS_IOT_CORE_DEFAULTS),
m_offlineQueueBehavior(ClientOperationQueueBehaviorType::AWS_MQTT5_COQBT_DEFAULT),
m_reconnectionOptions({ExponentialBackoffJitterMode::AWS_EXPONENTIAL_BACKOFF_JITTER_DEFAULT, 0, 0, 0}), m_pingTimeoutMs(0),
m_connackTimeoutMs(0), m_ackTimeoutSec(0), m_allocator(allocator)
{
m_socketOptions.SetSocketType(Io::SocketType::Stream);
Expand Down Expand Up @@ -218,10 +218,10 @@ namespace Aws
}

raw_options.connect_options = &m_packetConnectViewStorage;
raw_options.session_behavior = m_sessionBehavior;
raw_options.extended_validation_and_flow_control_options = m_extendedValidationAndFlowControlOptions;
raw_options.offline_queue_behavior = m_offlineQueueBehavior;
raw_options.retry_jitter_mode = m_reconnectionOptions.m_reconnectMode;
raw_options.session_behavior = (enum aws_mqtt5_client_session_behavior_type)m_sessionBehavior;
raw_options.extended_validation_and_flow_control_options = (enum aws_mqtt5_extended_validation_and_flow_control_options)m_extendedValidationAndFlowControlOptions;
raw_options.offline_queue_behavior = (enum aws_mqtt5_client_operation_queue_behavior_type)m_offlineQueueBehavior;
raw_options.retry_jitter_mode = (enum aws_exponential_backoff_jitter_mode)m_reconnectionOptions.m_reconnectMode;
raw_options.max_reconnect_delay_ms = m_reconnectionOptions.m_maxReconnectDelayMs;
raw_options.min_reconnect_delay_ms = m_reconnectionOptions.m_minReconnectDelayMs;
raw_options.min_connected_time_to_reset_reconnect_delay_ms =
Expand Down
32 changes: 16 additions & 16 deletions source/mqtt/Mqtt5Packets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ namespace Aws
}

PublishPacket::PublishPacket(const aws_mqtt5_packet_publish_view &packet, Allocator *allocator) noexcept
: m_allocator(allocator), m_qos(packet.qos), m_retain(packet.retain),
: m_allocator(allocator), m_qos((QOS)packet.qos), m_retain(packet.retain),
m_topicName((const char *)packet.topic.ptr, packet.topic.len), m_userPropertiesStorage(nullptr)
{
AWS_ZERO_STRUCT(m_payloadStorage);
Expand All @@ -462,7 +462,7 @@ namespace Aws

WithPayload(packet.payload);

setPacketOptional(m_payloadFormatIndicator, packet.payload_format);
setPacketOptional(m_payloadFormatIndicator, (PayloadFormatIndicator*)packet.payload_format);
setPacketOptional(m_messageExpiryIntervalSec, packet.message_expiry_interval_seconds);
setPacketOptional(m_topicAlias, packet.topic_alias);
setPacketStringOptional(m_responseTopic, m_responseTopicString, packet.response_topic);
Expand Down Expand Up @@ -582,7 +582,7 @@ namespace Aws
{
AWS_ZERO_STRUCT(raw_options);
raw_options.payload = m_payload;
raw_options.qos = m_qos;
raw_options.qos = (aws_mqtt5_qos)m_qos;
raw_options.retain = m_retain;
raw_options.topic = ByteCursorFromString(m_topicName);

Expand Down Expand Up @@ -671,7 +671,7 @@ namespace Aws
}

DisconnectPacket::DisconnectPacket(Allocator *allocator) noexcept
: m_allocator(allocator), m_reasonCode(AWS_MQTT5_DRC_NORMAL_DISCONNECTION),
: m_allocator(allocator), m_reasonCode(DisconnectReasonCode::AWS_MQTT5_DRC_NORMAL_DISCONNECTION),
m_userPropertiesStorage(nullptr)
{
}
Expand All @@ -680,7 +680,7 @@ namespace Aws
{
AWS_ZERO_STRUCT(raw_options);

raw_options.reason_code = m_reasonCode;
raw_options.reason_code = (aws_mqtt5_disconnect_reason_code)m_reasonCode;

if (m_sessionExpiryIntervalSec.has_value())
{
Expand Down Expand Up @@ -775,7 +775,7 @@ namespace Aws
Allocator *allocator) noexcept
: m_allocator(allocator), m_userPropertiesStorage(nullptr)
{
m_reasonCode = packet.reason_code;
m_reasonCode = (DisconnectReasonCode)packet.reason_code;

setPacketOptional(m_sessionExpiryIntervalSec, packet.session_expiry_interval_seconds);
setPacketStringOptional(m_reasonString, packet.reason_string);
Expand All @@ -793,7 +793,7 @@ namespace Aws

PubAckPacket::PubAckPacket(const aws_mqtt5_packet_puback_view &packet, Allocator * /*allocator*/) noexcept
{
m_reasonCode = packet.reason_code;
m_reasonCode = (PubAckReasonCode)packet.reason_code;
setPacketStringOptional(m_reasonString, packet.reason_string);
setUserProperties(m_userProperties, packet.user_properties, packet.user_property_count);
}
Expand All @@ -812,10 +812,10 @@ namespace Aws
Allocator * /*allocator*/) noexcept
{
m_sessionPresent = packet.session_present;
m_reasonCode = packet.reason_code;
m_reasonCode = (enum ConnectReasonCode)packet.reason_code;
setPacketOptional(m_sessionExpiryIntervalSec, packet.session_expiry_interval);
setPacketOptional(m_receiveMaximum, packet.receive_maximum);
setPacketOptional(m_maximumQOS, packet.maximum_qos);
setPacketOptional(m_maximumQOS, (QOS*)packet.maximum_qos);
setPacketOptional(m_retainAvailable, packet.retain_available);
setPacketOptional(m_maximumPacketSize, packet.maximum_packet_size);
setPacketStringOptional(m_assignedClientIdentifier, packet.assigned_client_identifier);
Expand Down Expand Up @@ -899,14 +899,14 @@ namespace Aws

Subscription::Subscription(Allocator *allocator)
: m_allocator(allocator), m_topicFilter(""), m_qos(QOS::AWS_MQTT5_QOS_AT_MOST_ONCE), m_noLocal(false),
m_retainAsPublished(false), m_retainHnadlingType(AWS_MQTT5_RHT_SEND_ON_SUBSCRIBE)
m_retainAsPublished(false), m_retainHnadlingType(RetainHandlingType::AWS_MQTT5_RHT_SEND_ON_SUBSCRIBE)

{
}

Subscription::Subscription(Crt::String topicFilter, Mqtt5::QOS qos, Allocator *allocator)
: m_allocator(allocator), m_topicFilter(std::move(topicFilter)), m_qos(qos), m_noLocal(false),
m_retainAsPublished(false), m_retainHnadlingType(AWS_MQTT5_RHT_SEND_ON_SUBSCRIBE)
m_retainAsPublished(false), m_retainHnadlingType(RetainHandlingType::AWS_MQTT5_RHT_SEND_ON_SUBSCRIBE)
{
}

Expand Down Expand Up @@ -942,9 +942,9 @@ namespace Aws
AWS_ZERO_STRUCT(raw_options);
raw_options.topic_filter = ByteCursorFromString(m_topicFilter);
raw_options.no_local = m_noLocal;
raw_options.qos = m_qos;
raw_options.qos = (enum aws_mqtt5_qos)m_qos;
raw_options.retain_as_published = m_retainAsPublished;
raw_options.retain_handling_type = m_retainHnadlingType;
raw_options.retain_handling_type = (enum aws_mqtt5_retain_handling_type)m_retainHnadlingType;
return true;
}

Expand Down Expand Up @@ -1074,7 +1074,7 @@ namespace Aws
setUserProperties(m_userProperties, packet.user_properties, packet.user_property_count);
for (size_t i = 0; i < packet.reason_code_count; i++)
{
m_reasonCodes.push_back(*(packet.reason_codes + i));
m_reasonCodes.push_back(*((enum SubAckReasonCode*)(packet.reason_codes + i)));
}
}

Expand Down Expand Up @@ -1160,7 +1160,7 @@ namespace Aws

for (size_t i = 0; i < packet.reason_code_count; i++)
{
m_reasonCodes.push_back(*(packet.reason_codes + i));
m_reasonCodes.push_back(*(enum UnSubAckReasonCode*)(packet.reason_codes + i));
}
setUserProperties(m_userProperties, packet.user_properties, packet.user_property_count);
}
Expand All @@ -1186,7 +1186,7 @@ namespace Aws
{
(void)allocator;

m_maximumQOS = negotiated_settings.maximum_qos;
m_maximumQOS = (enum QOS)negotiated_settings.maximum_qos;
m_sessionExpiryIntervalSec = negotiated_settings.session_expiry_interval;
m_receiveMaximumFromServer = negotiated_settings.receive_maximum_from_server;

Expand Down

0 comments on commit 7def6d1

Please sign in to comment.